added working loading circle
This commit is contained in:
@@ -2,11 +2,14 @@ package com.example.fitbot.ui.activities;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
@@ -70,6 +73,13 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
this.exerciseShortDescriptionTextView = findViewById(R.id.textViewFitnessShortDescription);
|
||||
//this.exerciseDescriptionTextView = findViewById(R.id.textViewDialogDescription);
|
||||
|
||||
// Set the repetition count for the exercise
|
||||
EXERCISE_REP = 1;
|
||||
|
||||
// Set color of loading circle
|
||||
ProgressBar loadingCircle = findViewById(R.id.loadingCircle);
|
||||
loadingCircle.setIndeterminateTintList(ColorStateList.valueOf(Color.RED));
|
||||
|
||||
// Navigation Buttons
|
||||
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
|
||||
NavigationManager.setupButtonNavigation(this, R.id.skipButtonFitness, MainActivity.class); //Needs to skip exercises once those are implemented
|
||||
@@ -141,12 +151,20 @@ 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);
|
||||
|
||||
// When the video has started playing remove the loading circle
|
||||
videoView.setOnInfoListener((mp, what, extra) -> {
|
||||
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
|
||||
ProgressBar loadingCircle = findViewById(R.id.loadingCircle);
|
||||
loadingCircle.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
@@ -167,7 +185,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
* @param videoView The VideoView to play the video in
|
||||
* @param context The context to use
|
||||
*/
|
||||
public static void playVideo(VideoView videoView, Context context) {
|
||||
public void playVideo(VideoView videoView, Context context) {
|
||||
// Set up the video player
|
||||
if (videoView != null) {
|
||||
videoView.setVideoPath(exerciseVideoUrl);
|
||||
|
@@ -37,9 +37,11 @@
|
||||
android:gravity="center" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loadingCircle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true" />
|
||||
android:indeterminate="true"
|
||||
android:progressTint="@color/white"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
|
Reference in New Issue
Block a user