2024-06-04 10:33:43 +02:00
5 changed files with 50 additions and 14 deletions

View File

@@ -42,6 +42,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
private final Object lock = new Object();
private static String exerciseVideoUrl;
// Some nice little messages for the user
private static final String[] EXERCISE_NOT_FOUND_MESSAGES = new String[]{
"Ik heb momenteel helaas wat moeite met het ophalen van oefeningen, sorry.",
@@ -71,7 +73,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Find the VideoView by its ID
VideoView videoView = findViewById(R.id.videoView);
playVideo(videoView, this);
// playVideo(videoView, this);
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
NavigationManager.setupButtonNavigation(this, R.id.skipButtonFitness, MainActivity.class); //Needs to skip exercises once those are implemented
@@ -137,6 +139,10 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
if (exercise == null) {
onFailedFetch.handle(null);
} else {
exerciseNameTextView.setText(exercise.name);
exerciseShortDescriptionTextView.setText(exercise.shortDescription);
exerciseDescriptionTextView.setText(exercise.description);
exerciseVideoUrl = exercise.videoUrl;
onSuccessfulFetch.handle(exercise);
this.runOnUiThread(() -> {
exerciseNameTextView.setText(exercise.name);
@@ -157,14 +163,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public static void playVideo(VideoView videoView, Context context) {
// Set up the video player
if (videoView != null) {
Uri videoUri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.bicepvideo);
videoView.setVideoURI(videoUri);
videoView.setOnCompletionListener(mp -> {
// Repeat the video when it finishes playing
videoView.start();
});
videoView.setVideoPath(exerciseVideoUrl);
videoView.start();
} else {
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");

View File

@@ -47,7 +47,10 @@
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:layout_margin="50dp" />
android:layout_marginStart="50dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="50dp" />
</RelativeLayout>

View File

@@ -40,7 +40,7 @@
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="119.500008" frame="299">
<Key value="-119.500008" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
@@ -177,14 +177,14 @@
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RShoulderPitch" mute="false" unit="degree">
<Key value="119.500008" frame="101">
<Key value="-119.500008" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-119.500008" frame="199">
<Key value="119.500008" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="112.970039" frame="299">
<Key value="-119.500008" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>