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.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -70,6 +73,13 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
this.exerciseShortDescriptionTextView = findViewById(R.id.textViewFitnessShortDescription);
|
this.exerciseShortDescriptionTextView = findViewById(R.id.textViewFitnessShortDescription);
|
||||||
//this.exerciseDescriptionTextView = findViewById(R.id.textViewDialogDescription);
|
//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
|
// Navigation Buttons
|
||||||
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
|
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
|
||||||
NavigationManager.setupButtonNavigation(this, R.id.skipButtonFitness, MainActivity.class); //Needs to skip exercises once those are implemented
|
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);
|
// exerciseDescriptionTextView.setText(exercise.description);
|
||||||
exerciseVideoUrl = exercise.videoUrl;
|
exerciseVideoUrl = exercise.videoUrl;
|
||||||
|
|
||||||
findViewById(R.id.loadingPanel).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
// Play the video
|
// Play the video
|
||||||
VideoView videoView = findViewById(R.id.videoView);
|
VideoView videoView = findViewById(R.id.videoView);
|
||||||
playVideo(videoView, this);
|
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() {
|
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCompletion(MediaPlayer mp) {
|
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 videoView The VideoView to play the video in
|
||||||
* @param context The context to use
|
* @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
|
// Set up the video player
|
||||||
if (videoView != null) {
|
if (videoView != null) {
|
||||||
videoView.setVideoPath(exerciseVideoUrl);
|
videoView.setVideoPath(exerciseVideoUrl);
|
||||||
|
@@ -37,9 +37,11 @@
|
|||||||
android:gravity="center" >
|
android:gravity="center" >
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
android:id="@+id/loadingCircle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:indeterminate="true" />
|
android:indeterminate="true"
|
||||||
|
android:progressTint="@color/white"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
Reference in New Issue
Block a user