Selaa lähdekoodia

1.修改游戏页面多次全屏缩放切换按钮消失bug

王鹏鹏 2 vuotta sitten
vanhempi
commit
ff82fcf421

+ 0 - 5
baselib/src/main/java/com/yingyangfly/baselib/utils/RxBusCodes.kt

@@ -83,11 +83,6 @@ object RxBusCodes {
      */
     const val COUNTDOWNSUCCESS = "countdownSuccess"
 
-    /**
-     * 游戏设置全屏
-     */
-    const val GAMEFULLSCREEN = "gameFullScreen"
-
     /**
      * 语音合成
      */

+ 0 - 11
game/src/main/java/com/yingyangfly/game/dialog/CountdownDialog.kt

@@ -34,7 +34,6 @@ class CountdownDialog : DialogFragment() {
     var onDialogClickListener: ((bean: String) -> Unit)? = null
     private var loadingImage: AppCompatImageView? = null
     private var tvTitle: AppCompatTextView? = null
-    private var countdown = false
     private var loadingOver = false
     private var content: Context? = null
     private var oneStep = ""
@@ -140,15 +139,12 @@ class CountdownDialog : DialogFragment() {
                 }
             }
             if (it == time) {
-                countdown = true
-                LiveEventBusUtil.send(RxBusCodes.GAMEFULLSCREEN, "")
                 if (loadingOver) {
                     rxTimer.cancel()
                     onDialogClickListener?.invoke("")
                     imageCountdown!!.postDelayed({
                         dismiss()
                     }, 200)
-
                 }
             } else {
                 if (it == totalTime) {
@@ -162,13 +158,6 @@ class CountdownDialog : DialogFragment() {
         //游戏加载完成
         LiveEventBusUtil.observer<String>(this, RxBusCodes.LOADINGOVER) {
             loadingOver = true
-            if (countdown) {
-                rxTimer.cancel()
-                onDialogClickListener?.invoke("")
-                imageCountdown!!.postDelayed({
-                    dismiss()
-                }, 200)
-            }
         }
     }
 }

+ 28 - 31
game/src/main/java/com/yingyangfly/game/play/PlayGameActivity.kt

@@ -121,7 +121,6 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             binding.tvPlay.text = gameShortDesn
             binding.tvIntroduce.text = gameShortDesn
         }
-        binding.tvFullScreen.show(TextUtils.equals("0", fullFlag))
         binding.tvGameLevel.show(TextUtils.equals("D", playClass).not())
     }
 
@@ -129,9 +128,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
     override fun initListener() {
         binding {
             imagePause.setOnTouchListener(this@PlayGameActivity)
-            iamgePauses.setOnTouchListener(this@PlayGameActivity)
             tvFullScreen.setOnTouchListener(this@PlayGameActivity)
-            tvReduce.setOnTouchListener(this@PlayGameActivity)
         }
         binding.gameLayout.viewTreeObserver.addOnGlobalLayoutListener(object :
             ViewTreeObserver.OnGlobalLayoutListener {
@@ -143,13 +140,26 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
         })
     }
 
-    @SuppressLint("SetTextI18n")
     override fun initData() {
         Glide.with(mContext)
             .asGif()
             .load(R.drawable.fish)
             .into(binding.loadingImage)
         initLiveData()
+        setScreenData()
+    }
+
+    /**
+     * 设置屏幕样式
+     */
+    private fun setScreenData() {
+        binding.tvFullScreen.show(TextUtils.equals("0", fullFlag))
+        if (TextUtils.equals("0", fullFlag)) {
+            binding.tvFullScreen.text = "全屏"
+        } else {
+            binding.tvFullScreen.text = "缩放"
+        }
+        setReduce()
     }
 
     override fun onNewIntent(intent: Intent?) {
@@ -249,14 +259,14 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
     override fun onTouch(v: View, event: MotionEvent): Boolean {
         when (event.action) {
             MotionEvent.ACTION_DOWN -> {
-                if (v.id == R.id.imagePause || v.id == R.id.iamgePauses || v.id == R.id.tvFullScreen || v.id == R.id.tvReduce) {
+                if (v.id == R.id.imagePause || v.id == R.id.tvFullScreen) {
                     v.startAnimation(getScaleAnimation())
                 }
             }
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 when (v.id) {
-                    R.id.imagePause, R.id.iamgePauses -> {
+                    R.id.imagePause -> {
                         runOnUiThread {
                             if (TextUtils.equals("D", playClass)) {
                                 finish()
@@ -277,18 +287,20 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
                     }
                     R.id.tvFullScreen -> {
                         runOnUiThread {
-                            setReduce(false)
-                        }
-                    }
-                    R.id.tvReduce -> {
-                        runOnUiThread {
-                            setReduce(true)
+                            if (TextUtils.equals("0", fullFlag)) {
+                                fullFlag = "1"
+                                binding.tvFullScreen.text = "全屏"
+                            } else {
+                                fullFlag = "0"
+                                binding.tvFullScreen.text = "缩放"
+                            }
+                            setReduce()
                         }
                     }
                 }
             }
             MotionEvent.ACTION_CANCEL -> {
-                if (v.id == R.id.imagePause || v.id == R.id.iamgePauses || v.id == R.id.tvFullScreen || v.id == R.id.tvReduce) {
+                if (v.id == R.id.imagePause || v.id == R.id.tvFullScreen) {
                     v.startAnimation(getEndAnimation())
                 }
             }
@@ -521,14 +533,6 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
         LiveEventBusUtil.observer<String>(this, RxBusCodes.COUNTDOWNSUCCESS) {
             countdownSuccess = true
         }
-        //游戏设置全屏
-        LiveEventBusUtil.observer<String>(this, RxBusCodes.GAMEFULLSCREEN) {
-            binding.webView.post {
-                if (TextUtils.equals("0", fullFlag)) {
-                    setReduce(false)
-                }
-            }
-        }
         //播放音乐
         LiveEventBusUtil.observer<String>(this, RxBusCodes.STARTMUSIC) {
             callPlayBgMusic()
@@ -669,24 +673,18 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
     /**
      * 是否缩放
      */
-    private fun setReduce(isReduce: Boolean) {
+    private fun setReduce() {
         binding.webView.post {
             binding {
-                tvFullScreen.show(isReduce)
-                tvReduce.show(isReduce.not())
-                tvScores.show(isReduce.not())
-                tvTimes.show(isReduce.not())
-                iamgePauses.show(isReduce.not())
-                tvGameLevels.show(isReduce.not())
+                gameFullLayout.show(TextUtils.equals("0", fullFlag))
             }
-            if (isReduce) {
+            if (TextUtils.equals("0", fullFlag).not()) {
                 val params = ConstraintLayout.LayoutParams(
                     mWebViewWidth,
                     mWebViewHeight
                 )
                 binding.gameLayout.radius = 49F
                 binding.gameLayout.layoutParams = params
-                binding.gameFullLayout.show(isReduce)
                 mConstrainSet_one?.applyTo(binding.gameParentLayout)
             } else {
                 val params = FrameLayout.LayoutParams(
@@ -695,7 +693,6 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
                 )
                 binding.gameLayout.radius = 0F
                 binding.gameLayout.layoutParams = params
-                binding.gameFullLayout.show(isReduce.not())
             }
         }
     }

+ 25 - 52
game/src/main/res/layout/activity_play_game.xml

@@ -30,31 +30,6 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
-            <androidx.appcompat.widget.AppCompatImageView
-                android:id="@+id/imagePause"
-                android:layout_width="@dimen/divider_270px"
-                android:layout_height="@dimen/divider_284px"
-                android:layout_marginTop="@dimen/divider_4px"
-                android:background="@mipmap/bg_game_pause"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toTopOf="parent" />
-
-            <androidx.appcompat.widget.AppCompatTextView
-                android:id="@+id/tvFullScreen"
-                android:layout_width="@dimen/divider_169px"
-                android:layout_height="@dimen/divider_75px"
-                android:layout_marginTop="@dimen/divider_32px"
-                android:layout_marginEnd="@dimen/divider_32px"
-                android:background="@drawable/bg_game_pause"
-                android:fontFamily="@font/lcb"
-                android:gravity="center"
-                android:includeFontPadding="false"
-                android:text="@string/full_screen"
-                android:textColor="@color/color_FFFFA916"
-                android:textSize="@dimen/divider_28px"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toTopOf="parent" />
-
             <FrameLayout
                 android:id="@+id/gameFrameLayout"
                 android:layout_width="@dimen/divider_189px"
@@ -146,36 +121,11 @@
                         android:layout_gravity="top"
                         android:visibility="gone">
 
-                        <androidx.appcompat.widget.AppCompatImageView
-                            android:id="@+id/iamgePauses"
-                            android:layout_width="@dimen/divider_270px"
-                            android:layout_height="@dimen/divider_284px"
-                            android:layout_marginTop="@dimen/divider_4px"
-                            android:background="@mipmap/bg_game_pause"
-                            app:layout_constraintStart_toStartOf="parent"
-                            app:layout_constraintTop_toTopOf="parent" />
-
-                        <androidx.appcompat.widget.AppCompatTextView
-                            android:id="@+id/tvReduce"
-                            android:layout_width="@dimen/divider_169px"
-                            android:layout_height="@dimen/divider_65px"
-                            android:layout_marginStart="@dimen/divider_32px"
-                            android:layout_marginTop="@dimen/divider_32px"
-                            android:layout_marginEnd="@dimen/divider_32px"
-                            android:background="@drawable/bg_game_pause"
-                            android:fontFamily="@font/lcb"
-                            android:gravity="center"
-                            android:includeFontPadding="false"
-                            android:text="@string/scale"
-                            android:textColor="@color/color_FFFFA916"
-                            android:textSize="@dimen/divider_28px"
-                            app:layout_constraintEnd_toEndOf="parent"
-                            app:layout_constraintTop_toTopOf="parent" />
-
                         <androidx.appcompat.widget.AppCompatTextView
                             android:id="@+id/tvScores"
                             android:layout_width="@dimen/divider_195px"
                             android:layout_height="@dimen/divider_74px"
+                            android:layout_marginStart="@dimen/divider_200px"
                             android:layout_marginTop="@dimen/divider_23px"
                             android:background="@drawable/bg_full_game_text"
                             android:fontFamily="@font/lcb"
@@ -184,7 +134,7 @@
                             android:text="@string/zero"
                             android:textColor="@android:color/white"
                             android:textSize="@dimen/divider_32px"
-                            app:layout_constraintStart_toEndOf="@+id/iamgePauses"
+                            app:layout_constraintStart_toStartOf="parent"
                             app:layout_constraintTop_toTopOf="parent" />
 
                         <androidx.appcompat.widget.AppCompatTextView
@@ -331,5 +281,28 @@
                 app:layout_constraintStart_toEndOf="@+id/gameLayout"
                 app:layout_constraintTop_toBottomOf="@+id/timeLayout" />
         </androidx.constraintlayout.widget.ConstraintLayout>
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/imagePause"
+            android:layout_width="@dimen/divider_270px"
+            android:layout_height="@dimen/divider_284px"
+            android:layout_gravity="start|top"
+            android:layout_marginTop="@dimen/divider_4px"
+            android:background="@mipmap/bg_game_pause" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvFullScreen"
+            android:layout_width="@dimen/divider_169px"
+            android:layout_height="@dimen/divider_75px"
+            android:layout_gravity="top|end"
+            android:layout_marginTop="@dimen/divider_32px"
+            android:layout_marginEnd="@dimen/divider_32px"
+            android:background="@drawable/bg_game_pause"
+            android:fontFamily="@font/lcb"
+            android:gravity="center"
+            android:includeFontPadding="false"
+            android:text="@string/full_screen"
+            android:textColor="@color/color_FFFFA916"
+            android:textSize="@dimen/divider_28px" />
     </FrameLayout>
 </layout>

+ 0 - 5
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/detail/LiveBroadcastActivity.kt

@@ -160,11 +160,6 @@ class LiveBroadcastActivity :
             extraInfo: Bundle?
         ) {
             super.onVideoPlaying(player, firstPlay, extraInfo)
-            if (firstPlay) {
-                Log.e("wpp", "--------------------------777")
-            } else {
-                Log.e("wpp", "--------------------------666")
-            }
         }
     }