diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java index 4b370a9..f2ded90 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java @@ -27,7 +27,7 @@ public class InputProcessor { private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data private float exerciseRepetitionDurationInSeconds = 0.0f; - private int exercisesRemaining = 0; + private int exercisesRemaining = 1; private float errorCheckInterval_s; private int checksPerformed = 0; @@ -134,6 +134,7 @@ public class InputProcessor { * @param exercise The exercise to move on to. */ private void nextExercise(Exercise exercise) { + Log.i("InputProcessor", "Acquired next exercise: " + exercise.name); if (this.exercisesRemaining-- <= 0) { // Move to end screen on main activity @@ -147,9 +148,6 @@ public class InputProcessor { this.checksPerformed = 0; this.totalChecks = ExerciseManager.DEFAULT_EXERCISE_REPETITIONS * 6; - - Log.i("InputProcessor", "Exercise error checking interval: " + this.errorCheckInterval_s); - this.selfRotationVectorPaths = new ArrayList[2]; this.selfRotationVectorPaths[0] = new ArrayList<>(); this.selfRotationVectorPaths[1] = new ArrayList<>(); @@ -161,7 +159,10 @@ public class InputProcessor { this.secondsPassed = 0.0D; this.lastTime = System.currentTimeMillis(); - this.errorCheckInterval_s = this.exerciseRepetitionDurationInSeconds * ExerciseManager.DEFAULT_EXERCISE_REPETITIONS / 6.0f; + Log.i("InputProcessor", "Repetition time: " + exercise.exerciseTimeInSeconds); + this.exerciseRepetitionDurationInSeconds = Math.max(this.exerciseRepetitionDurationInSeconds, 2); + this.errorCheckInterval_s = exercise.exerciseTimeInSeconds / 6.0f; + Log.i("InputProcessor", "Exercise error checking interval: " + this.errorCheckInterval_s); } /** @@ -170,7 +171,7 @@ public class InputProcessor { public void onAdequateRepetition() { ExerciseManager.TOTAL_REPETITIONS_PERFORMED++; Log.i("InputProcessor", "Adequate repetition performed"); - this.parentActivity.incrementProgress(); + this.parentActivity.runOnUiThread(this.parentActivity::incrementProgress); } /** @@ -178,7 +179,7 @@ public class InputProcessor { */ public void onInadequateRepetition() { Log.i("InputProcessor", "Inadequate repetition performed"); - this.parentActivity.triggerColorBurst(false); + this.parentActivity.runOnUiThread(() -> this.parentActivity.triggerColorBurst(false)); } /** @@ -239,7 +240,6 @@ public class InputProcessor { * Upon successful retrieval, it will call the nextExercise method. */ private void acquireExercise() { - this.exercisesRemaining--; Log.i("MotionProcessor", "Fetching exercise data.");