From 29b0960b9e8b0b53ee5f5334166c0897ca464bb0 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sun, 18 Feb 2018 20:32:19 +0100 Subject: [PATCH] Specify where, if at all, in the list that date/time should be --- .../gui/activities/DataEntryActivity.java | 3 ++- .../openscale/gui/fragments/GraphFragment.java | 3 ++- .../openscale/gui/fragments/OverviewFragment.java | 13 ++----------- .../openscale/gui/fragments/TableFragment.java | 3 ++- .../openscale/gui/views/MeasurementView.java | 14 +++++++++++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index 7ca1bd65..4385dcfe 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -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); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java index 88614fff..56c29826 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java @@ -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() { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java index 3060c1d2..7689e84d 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java @@ -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); } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java index b53fa6a8..f8f234c1 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java @@ -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); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java index 7d4c7e2a..5123a988 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java @@ -80,11 +80,15 @@ public abstract class MeasurementView extends TableLayout { iconView.setImageDrawable(icon); } - public static final List getMeasurementList(Context context) { + public enum DateTimeOrder { FIRST, LAST, NONE } + + public static final List getMeasurementList(Context context, DateTimeOrder order) { final List 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; }