Selaa lähdekoodia

修复闲玩任务为闲玩奖励;
优化视频播放功能

zengjiebin 7 vuotta sitten
vanhempi
commit
422da8f85f

+ 9 - 15
app/src/main/java/com/sheep/gamegroup/view/activity/ActPlayVideo.java

@@ -10,7 +10,7 @@ import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.WindowManager;
-import android.widget.ImageView;
+import android.widget.MediaController;
 import android.widget.VideoView;
 
 import com.kfzs.duanduan.utils.StatusBarUtils;
@@ -37,8 +37,6 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
 
     @BindView(R.id.videoView)
     VideoView videoView;
-    @BindView(R.id.play_or_pause)
-    ImageView play_or_pause;
     @BindView(R.id.video_loading)
     View video_loading;
 
@@ -57,6 +55,7 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
         videoView.setOnErrorListener(this);
         videoView.setOnCompletionListener(this);
         videoView.addOnLayoutChangeListener(this);
+        videoView.setMediaController(new MediaController(this));
         videoView.setVideoURI(uri);
     }
 
@@ -73,10 +72,9 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
     }
     private GestureDetector mGestureDetector;
 
-    private boolean isPlaying;
     //播放或者暂停
     private void playOrPause() {
-        if(isPlaying){
+        if(videoView.isPlaying()){
             pause();
         } else {
             play();
@@ -87,27 +85,21 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
         if(videoView == null){
             return;
         }
-        play_or_pause.setVisibility(View.GONE);
         videoView.start();
-        isPlaying = true;
     }
     //暂停
     private void pause(){
         if(videoView == null){
             return;
         }
-        play_or_pause.setVisibility(View.VISIBLE);
         videoView.pause();
-        isPlaying = false;
     }
     //销毁
     private void destroy(){
         if(videoView == null){
             return;
         }
-        play_or_pause.setVisibility(View.VISIBLE);
         videoView.stopPlayback();
-        isPlaying = false;
     }
 
 
@@ -127,8 +119,10 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
     @Override
     protected void onPause() {
         super.onPause();
-        if(isPlaying)
+        if(videoView != null && videoView.isPlaying())
             isPauseByUser = false;
+        if(video_loading != null)
+            video_loading.setVisibility(View.VISIBLE);
         pause();
     }
 
@@ -161,9 +155,9 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
         @Override
         public boolean onSingleTapConfirmed(MotionEvent e) {
             LogUtil.println("mGestureListener", "onSingleTapConfirmed");
-            if(isPlaying)
-                isPauseByUser = true;
-            playOrPause();
+//            if(isPlaying)
+//                isPauseByUser = true;
+//            playOrPause();
             return super.onSingleTapConfirmed(e);
         }
         @Override

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActXinwanWeb.java

@@ -126,7 +126,7 @@ public class ActXinwanWeb extends BaseActivity {
                 super.onReceivedTitle(view, title);
                 TitleBarUtils
                         .getInstance()
-                        .setTitle(activity, title);
+                        .setTitle(activity, title.replaceAll("任务", "奖励"));
             }
         });
         mWebView.setWebViewClient(new WebViewClient() {

+ 2 - 13
app/src/main/res/layout/act_play_video.xml

@@ -2,7 +2,8 @@
 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:background="#000000">
 
     <VideoView
         android:id="@+id/videoView"
@@ -11,18 +12,6 @@
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintTop_toTopOf="parent"/>
 
-    <ImageView
-        android:id="@+id/play_or_pause"
-        android:layout_width="51dp"
-        android:layout_height="51dp"
-        android:focusable="false"
-        android:focusableInTouchMode="false"
-        android:src="@drawable/ic_play_but_image"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
-
     <com.github.ybq.android.spinkit.SpinKitView
         android:id="@+id/video_loading"
         style="@style/SpinKitView.Large.ThreeBounce"