Fixed thread issues
This commit is contained in:
@@ -145,7 +145,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
int randomMessageIndex = (int) Math.floor(Math.random() * EXERCISE_NOT_FOUND_MESSAGES.length);
|
||||
Pepper.say(EXERCISE_NOT_FOUND_MESSAGES[randomMessageIndex]);
|
||||
Pepper.say(EXERCISE_NOT_FOUND_SEEK_HELP_MESSAGE);
|
||||
NavigationManager.navigateToActivity(this, EndScreenActivity.class);
|
||||
// Run on main thread to prevent crashes (wack)
|
||||
this.runOnUiThread(() -> NavigationManager.navigateToActivity(this, EndScreenActivity.class));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -160,7 +161,10 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
new Thread(() -> {
|
||||
Exercise exercise = ExerciseManager.fetchExerciseFromDatabase();
|
||||
if (exercise == null) {
|
||||
runOnUiThread(() -> onFailedFetch.handle(null));
|
||||
onFailedFetch.handle(null);
|
||||
|
||||
// Main thread stuff
|
||||
runOnUiThread(() -> NavigationManager.navigateToActivity(this, MainActivity.class));
|
||||
} else {
|
||||
onSuccessfulFetch.handle(exercise);
|
||||
runOnUiThread(() -> {
|
||||
|
@@ -132,7 +132,9 @@ public class InputProcessor {
|
||||
*/
|
||||
private void nextExercise(Exercise exercise) {
|
||||
if (this.exercisesRemaining-- <= 0) {
|
||||
NavigationManager.navigateToActivity(this.parentActivity, EndScreenActivity.class);
|
||||
|
||||
// Move to end screen on main activity
|
||||
this.parentActivity.runOnUiThread(() -> NavigationManager.navigateToActivity(this.parentActivity, EndScreenActivity.class));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -234,7 +236,6 @@ public class InputProcessor {
|
||||
this.parentActivity.fetchExerciseAsync(this::nextExercise, (nil) -> {
|
||||
|
||||
Log.i("MotionProcessor", "Failed to fetch exercise data.");
|
||||
NavigationManager.navigateToActivity(this.parentActivity, MainActivity.class);
|
||||
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user