~anjan/lift

9832b374ce28bcfc44f93119c5546b7efdec0c17 — Anjandev Momi 4 years ago c1a17de
fix incrementing rout when pause. Also destroy workout on press
M app/src/main/java/ca/momi/lift/MainActivity.java => app/src/main/java/ca/momi/lift/MainActivity.java +10 -4
@@ 49,6 49,11 @@ public class MainActivity extends AppCompatActivity {

    public static Boolean DEBUGMODE = false;

    protected void onResume() {
        super.onResume();
        setNextWorkout();
    }

    private void getSavedPref(Context context){
          SharedPreferences sharedPref = context.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE);
          program = sharedPref.getString("program",AssignedExcers.FIVE_x_5);


@@ 148,11 153,11 @@ public class MainActivity extends AppCompatActivity {
        }
        AssignedExcers assExcersize = new AssignedExcers();

        int curIdx;
        int nextIdx;
        if (latestwork.onPause) {
            curIdx = assExcersize.routineDescriber.indexOf(latestwork.routineName);
            nextIdx = assExcersize.routineDescriber.indexOf(latestwork.routineName);
        } else {
            curIdx = -1;
            int curIdx = -1;


            for (int i = 0; i < assExcersize.routineDescriber.size(); i++) {


@@ 160,9 165,10 @@ public class MainActivity extends AppCompatActivity {
                    curIdx = i;
                }
            }

            nextIdx = assExcersize.nextRoutineIdx(curIdx);
        }

        int nextIdx = assExcersize.nextRoutineIdx(curIdx);

        RadioButton nextButton = (RadioButton) routinesRadGroup.getChildAt(nextIdx);
        nextButton.setChecked(true);

M app/src/main/java/ca/momi/lift/Workout.java => app/src/main/java/ca/momi/lift/Workout.java +4 -6
@@ 50,9 50,10 @@ public class Workout extends AppCompatActivity {

    private boolean pausing = false;

    protected void onResume() {
        super.onResume();
    protected void onDestroy() {
        super.onDestroy();
        pausing = false;
        doneWork.performClick();
    }

    protected void onPause() {


@@ 396,9 397,6 @@ public class Workout extends AppCompatActivity {
        });

        this.doneWork = doneWork;
        // by default, the activity assumes the button will click doneWork via user input
        // However, if activity is paused, onPause is called and sets pausing true.
        this.pausing = false;
    }

    private void writeData(String routineName, String dateString, String programName, boolean onPause, View v) {


@@ 422,7 420,7 @@ public class Workout extends AppCompatActivity {

        if (checkStoragePermissionAndWrite((Activity) v.getContext(),  dateString, workoutSessionText)){
            if (!onPause) {
                finish();
                System.exit(0);
            }
        } else {
            Log.d(TAG, "writeData: failed. Try again");