1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-17 22:11:35 +02:00

don't show the last day in the overview diagram to reduce space

calculate days between two dates with DAY_OF_YEAR function
This commit is contained in:
OliE
2017-06-04 16:39:05 +02:00
parent 88def160b7
commit d36cc0ed1b

View File

@@ -53,7 +53,6 @@ import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import lecho.lib.hellocharts.formatter.SimpleLineChartValueFormatter; import lecho.lib.hellocharts.formatter.SimpleLineChartValueFormatter;
import lecho.lib.hellocharts.listener.LineChartOnValueSelectListener; import lecho.lib.hellocharts.listener.LineChartOnValueSelectListener;
@@ -273,11 +272,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
long days = 0 - daysBetween(lastDate, histDate); long days = 0 - daysBetween(lastDate, histDate);
if (days == 0 && !scaleDataList.isEmpty()) { axisValues.add(new AxisValue(i, String.format("%d " + getResources().getString(R.string.label_days), days).toCharArray()));
axisValues.add(new AxisValue(i, DateFormat.getDateInstance(DateFormat.SHORT).format(scaleDataList.get(0).getDateTime()).toCharArray()));
} else {
axisValues.add(new AxisValue(i, String.format("%d " + getResources().getString(R.string.label_days), days).toCharArray()));
}
} }
Line lineWeight = new Line(valuesWeight). Line lineWeight = new Line(valuesWeight).
@@ -343,7 +338,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
lineData.setAxisYLeft(new Axis(). lineData.setAxisYLeft(new Axis().
setHasLines(true). setHasLines(true).
setMaxLabelChars(3). setMaxLabelChars(5).
setTextColor(Color.BLACK) setTextColor(Color.BLACK)
); );
@@ -399,9 +394,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
} }
private long daysBetween(Calendar startDate, Calendar endDate) { private long daysBetween(Calendar startDate, Calendar endDate) {
long end = endDate.getTimeInMillis(); return startDate.get(Calendar.DAY_OF_YEAR) - endDate.get(Calendar.DAY_OF_YEAR);
long start = startDate.getTimeInMillis();
return TimeUnit.MILLISECONDS.toDays(Math.abs(end - start));
} }
public void btnOnClickInsertData() public void btnOnClickInsertData()