mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 10:05:49 +01:00
Format center-text for week-sleep-pie
This commit is contained in:
parent
437ec6c9b7
commit
49e1b55ad8
@ -23,7 +23,6 @@ import com.github.mikephil.charting.formatter.IValueFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@ -60,7 +59,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
MyChartsData mcd = (MyChartsData) chartsData;
|
||||
|
||||
// setupLegend(mWeekChart);
|
||||
mTodayPieChart.setCenterText(NumberFormat.getNumberInstance(mLocale).format(mcd.getDayData().totalValue));
|
||||
mTodayPieChart.setCenterText(mcd.getDayData().centerText);
|
||||
mTodayPieChart.setData(mcd.getDayData().data);
|
||||
|
||||
mWeekChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
||||
@ -128,9 +127,11 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
//this hides the values (numeric) added to the set. These would be shown aside the strings set with addXValue above
|
||||
data.setDrawValues(false);
|
||||
|
||||
return new DayData(data, totalValue);
|
||||
return new DayData(data, formatPieValue(totalValue));
|
||||
}
|
||||
|
||||
protected abstract String formatPieValue(int value);
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@ -234,11 +235,11 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
|
||||
private static class DayData {
|
||||
private final PieData data;
|
||||
private final int totalValue;
|
||||
private final CharSequence centerText;
|
||||
|
||||
DayData(PieData data, int totalValue) {
|
||||
DayData(PieData data, String centerText) {
|
||||
this.data = data;
|
||||
this.totalValue = totalValue;
|
||||
this.centerText = centerText;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,17 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
return (int) (totalSeconds / 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatPieValue(int value) {
|
||||
return DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
IValueFormatter getFormatter() {
|
||||
return new IValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
||||
return DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.MINUTES);
|
||||
return formatPieValue((int) value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
return analysis.calculateTotalSteps(activitySamples);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatPieValue(int value) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
IValueFormatter getFormatter() {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user