From b7f7d031d534e9bc600746478c67ce6b68d6ad02 Mon Sep 17 00:00:00 2001 From: mikem Date: Mon, 21 Jul 2014 15:12:30 -0700 Subject: Fixing a bug where the values for reps/weight would drop to 0 when making the first edit of the activity for that week. Now it starts properly at last week's value. --- .../java/com/mikemiller/gymlog/ActivityFragment.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'GymLog/src/main/java/com/mikemiller/gymlog/ActivityFragment.java') diff --git a/GymLog/src/main/java/com/mikemiller/gymlog/ActivityFragment.java b/GymLog/src/main/java/com/mikemiller/gymlog/ActivityFragment.java index 748f844..249db8c 100644 --- a/GymLog/src/main/java/com/mikemiller/gymlog/ActivityFragment.java +++ b/GymLog/src/main/java/com/mikemiller/gymlog/ActivityFragment.java @@ -192,9 +192,17 @@ public class ActivityFragment extends Fragment { refreshButton(); } public int getWeight() { + if (getActivityStats().weight == 0) { + return getLastWeight(); + } + return getActivityStats().weight; } public int getReps() { + if (getActivityStats().reps == 0) { + return getLastReps(); + } + return getActivityStats().reps; } private int getLastWeight() { @@ -222,10 +230,15 @@ public class ActivityFragment extends Fragment { getActivity().sendBroadcast(new Intent(STAT_UPDATED)); } + private boolean refreshingButton = false; private void refreshButton() { - int weight = getWeight() == 0 ? getLastWeight() : getWeight(); - int reps = getReps() == 0 ? getLastReps() : getReps(); - mSummaryButton.setText(mActivity.getSummary(weight, reps, getLastWeight(), getLastReps())); + if (!refreshingButton && mSummaryButton != null) { + refreshingButton = true; + int weight = getWeight(); + int reps = getReps(); + mSummaryButton.setText(mActivity.getSummary(weight, reps, getLastWeight(), getLastReps())); + refreshingButton = false; + } } -- cgit v1.2.3-70-g09d2