added loading icon while video is getting fetched

This commit is contained in:
SebasKoedam
2024-06-04 15:20:47 +02:00
parent 8a02bf1daa
commit ad83c7e450
2 changed files with 16 additions and 2 deletions

View File

@@ -129,7 +129,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void fetchExerciseAsync(Exercise.ExerciseFetchHandler onSuccessfulFetch, Exercise.ExerciseFetchHandler onFailedFetch) {
// For some stupid reason we cannot perform network operations on the main thread.
// therefore we'll have to do it like this...
(new Thread(() -> {
new Thread(() -> {
Exercise exercise = ExerciseManager.fetchExerciseFromDatabase();
if (exercise == null) {
onFailedFetch.handle(null);
@@ -141,6 +141,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// exerciseDescriptionTextView.setText(exercise.description);
exerciseVideoUrl = exercise.videoUrl;
findViewById(R.id.loadingPanel).setVisibility(View.GONE);
// Play the video
VideoView videoView = findViewById(R.id.videoView);
playVideo(videoView, this);
@@ -156,7 +158,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
});
});
}
})).start();
}).start();
}
/**

View File

@@ -30,6 +30,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
<Button
android:id="@+id/infoButtonFitness"
android:layout_width="50dp"