1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-29 19:20:36 +02:00

Specify where, if at all, in the list that date/time should be

This commit is contained in:
Erik Johansson
2018-02-18 20:32:19 +01:00
parent ff152f54c2
commit 29b0960b9e
5 changed files with 19 additions and 17 deletions

View File

@@ -94,7 +94,8 @@ public class DataEntryActivity extends AppCompatActivity {
tableLayoutDataEntry = (TableLayout) findViewById(R.id.tableLayoutDataEntry);
dataEntryMeasurements = MeasurementView.getMeasurementList(context);
dataEntryMeasurements = MeasurementView.getMeasurementList(
context, MeasurementView.DateTimeOrder.LAST);
txtDataNr = (TextView) findViewById(R.id.txtDataNr);
btnLeft = (Button) findViewById(R.id.btnLeft);

View File

@@ -174,7 +174,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
}
});
measurementViews = MeasurementView.getMeasurementList(getContext());
measurementViews = MeasurementView.getMeasurementList(
getContext(), MeasurementView.DateTimeOrder.NONE);
popup = new PopupMenu(getContext(), optionMenu);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

View File

@@ -38,10 +38,8 @@ import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.utils.Converters;
import com.health.openscale.core.utils.DateTimeHelpers;
import com.health.openscale.gui.views.DateMeasurementView;
import com.health.openscale.gui.views.FloatMeasurementView;
import com.health.openscale.gui.views.MeasurementView;
import com.health.openscale.gui.views.TimeMeasurementView;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -120,13 +118,10 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
pieChartLast.setOnValueTouchListener(new PieChartLastTouchListener());
pieChartLast.setChartRotationEnabled(false);
measurementViews = MeasurementView.getMeasurementList(getContext());
measurementViews = MeasurementView.getMeasurementList(
getContext(), MeasurementView.DateTimeOrder.NONE);
for (MeasurementView measurement : measurementViews) {
if (measurement instanceof DateMeasurementView || measurement instanceof TimeMeasurementView) {
continue;
}
tableOverviewLayout.addView(measurement);
}
@@ -171,10 +166,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
updateLastLineChart(scaleMeasurementList);
for (MeasurementView measurement : measurementViews) {
if (measurement instanceof DateMeasurementView || measurement instanceof TimeMeasurementView) {
continue;
}
measurement.updatePreferences(prefs);
measurement.loadFrom(lastScaleMeasurement, prevScaleMeasurement);
}

View File

@@ -112,7 +112,8 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
selectedSubpageNr = savedInstanceState.getInt(SELECTED_SUBPAGE_NR_KEY);
}
measurementViews = MeasurementView.getMeasurementList(getContext());
measurementViews = MeasurementView.getMeasurementList(
getContext(), MeasurementView.DateTimeOrder.FIRST);
for (MeasurementView measurement : measurementViews) {
measurement.setUpdateViews(false);

View File

@@ -80,11 +80,15 @@ public abstract class MeasurementView extends TableLayout {
iconView.setImageDrawable(icon);
}
public static final List<MeasurementView> getMeasurementList(Context context) {
public enum DateTimeOrder { FIRST, LAST, NONE }
public static final List<MeasurementView> getMeasurementList(Context context, DateTimeOrder order) {
final List<MeasurementView> measurementViews = new ArrayList<>();
measurementViews.add(new DateMeasurementView(context));
measurementViews.add(new TimeMeasurementView(context));
if (order == DateTimeOrder.FIRST) {
measurementViews.add(new DateMeasurementView(context));
measurementViews.add(new TimeMeasurementView(context));
}
measurementViews.add(new WeightMeasurementView(context));
measurementViews.add(new BMIMeasurementView(context));
measurementViews.add(new WaterMeasurementView(context));
@@ -98,6 +102,10 @@ public abstract class MeasurementView extends TableLayout {
measurementViews.add(new WHRMeasurementView(context));
measurementViews.add(new BMRMeasurementView(context));
measurementViews.add(new CommentMeasurementView(context));
if (order == DateTimeOrder.LAST) {
measurementViews.add(new DateMeasurementView(context));
measurementViews.add(new TimeMeasurementView(context));
}
return measurementViews;
}