Browse Source

1.优化代码

王鹏鹏 2 years ago
parent
commit
7118941fd2

+ 2 - 2
baselib/build.gradle

@@ -40,7 +40,7 @@ android {
             buildConfigField "String", "BAIDU_SECRETKEY", "\"41Fzb2ZIuKRGNtrVcQOHxEI3vFM4Rkxi\""
             buildConfigField "Boolean", "SINGLE_MODULE", "${singleModule}"
             buildConfigField "String", "BUGLY_APPID", "\"d400f20398\""
-            buildConfigField "String", "API_URL", "\"http://192.168.0.122:8110\""
+            buildConfigField "String", "API_URL", "\"http://60.205.201.7:8110\""
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
 
@@ -54,7 +54,7 @@ android {
             buildConfigField "String", "BAIDU_SECRETKEY", "\"41Fzb2ZIuKRGNtrVcQOHxEI3vFM4Rkxi\""
             buildConfigField "Boolean", "SINGLE_MODULE", "${singleModule}"
             buildConfigField "String", "BUGLY_APPID", "\"ad3db4d529\""
-            buildConfigField "String", "API_URL", "\"http://192.168.0.122:8110\""
+            buildConfigField "String", "API_URL", "\"http://60.205.201.7:8110\""
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }

+ 12 - 6
game/src/main/java/com/yingyangfly/game/dialog/CountdownDialog.kt

@@ -100,23 +100,29 @@ class CountdownDialog : DialogFragment() {
             when (date.toString()) {
                 "1" -> {
                     imageCountdown!!.setBackgroundResource(R.mipmap.icon_one)
-                    val wavFile = resources.openRawResourceFd(R.raw.one)
-                    voicePlayer?.play(wavFile) {
+                    imageCountdown!!.post {
+                        val wavFile = resources.openRawResourceFd(R.raw.one)
+                        voicePlayer?.play(wavFile) {
 
+                        }
                     }
                 }
                 "2" -> {
                     imageCountdown!!.setBackgroundResource(R.mipmap.icon_two)
-                    val wavFile = resources.openRawResourceFd(R.raw.two)
-                    voicePlayer?.play(wavFile) {
+                    imageCountdown!!.post {
+                        val wavFile = resources.openRawResourceFd(R.raw.two)
+                        voicePlayer?.play(wavFile) {
 
+                        }
                     }
                 }
                 "3" -> {
                     imageCountdown!!.setBackgroundResource(R.mipmap.icon_three)
-                    val wavFile = resources.openRawResourceFd(R.raw.three)
-                    voicePlayer?.play(wavFile) {
+                    imageCountdown!!.post {
+                        val wavFile = resources.openRawResourceFd(R.raw.three)
+                        voicePlayer?.play(wavFile) {
 
+                        }
                     }
                 }
             }

+ 23 - 3
game/src/main/java/com/yingyangfly/game/play/PlayGameActivity.kt

@@ -12,13 +12,13 @@ import android.webkit.WebResourceRequest
 import android.webkit.WebSettings
 import android.webkit.WebView
 import android.webkit.WebViewClient
+import android.widget.FrameLayout
+import android.widget.LinearLayout
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
 import com.bumptech.glide.Glide
 import com.yingyangfly.baselib.db.VoicePlayerBean
-import com.yingyangfly.baselib.ext.getEndAnimation
-import com.yingyangfly.baselib.ext.getScaleAnimation
-import com.yingyangfly.baselib.ext.toast
+import com.yingyangfly.baselib.ext.*
 import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
 import com.yingyangfly.baselib.player.VoicePlayer
 import com.yingyangfly.baselib.router.RouterUrlCommon
@@ -37,6 +37,7 @@ import gorden.rxbus2.RxBus
 import gorden.rxbus2.Subscribe
 import gorden.rxbus2.ThreadMode
 
+
 /**
  * 玩游戏页面
  */
@@ -84,6 +85,16 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
     override fun initListener() {
         binding {
             tvPause.setOnTouchListener(this@PlayGameActivity)
+            tvFullScreen.setOnSingleClickListener {
+                binding.webView.post {
+                    val params = FrameLayout.LayoutParams(
+                        FrameLayout.LayoutParams.MATCH_PARENT,
+                        FrameLayout.LayoutParams.MATCH_PARENT
+                    )
+                    binding.gameLayout.layoutParams = params
+                    binding.gameFullLayout.show(true)
+                }
+            }
         }
     }
 
@@ -93,6 +104,11 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             .asGif()
             .load(R.drawable.fish)
             .into(binding.loadingImage)
+
+        Glide.with(mContext)
+            .asGif()
+            .load(R.drawable.fish)
+            .into(binding.loadingImages)
         initLiveData()
     }
 
@@ -303,6 +319,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             binding.tvTime.post {
                 if (TextUtils.isEmpty(it).not()) {
                     binding.tvTime.text = it
+                    binding.tvTimes.text = it
                 }
             }
         }
@@ -311,6 +328,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             binding.tvScore.post {
                 if (TextUtils.isEmpty(it).not()) {
                     binding.tvScore.text = it
+                    binding.tvScores.text = it
                 }
             }
         }
@@ -319,6 +337,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             binding.tvGameLevel.post {
                 if (TextUtils.isEmpty(it).not()) {
                     binding.tvGameLevel.text = "第" + it + "关"
+                    binding.tvGameLevels.text = "第" + it + "关"
                 }
             }
         }
@@ -354,6 +373,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
                 val msg = it.split("voice:")
                 if (msg.isNullOrEmpty().not()) {
                     binding.tvIntroduce.text = msg[1]
+                    binding.tvIntroduces.text = msg[1]
                     speak(msg[1])
                 }
             }

+ 133 - 9
game/src/main/res/layout/activity_play_game.xml

@@ -44,6 +44,21 @@
                 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_65px"
+                android:layout_marginTop="@dimen/divider_32px"
+                android:layout_marginEnd="@dimen/divider_32px"
+                android:background="@drawable/bg_game_pause"
+                android:gravity="center"
+                android:text="全屏"
+                android:textColor="@color/color_FFFFA916"
+                android:textSize="@dimen/divider_28px"
+                android:textStyle="bold"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="parent" />
+
             <FrameLayout
                 android:layout_width="@dimen/divider_189px"
                 android:layout_height="wrap_content"
@@ -109,17 +124,126 @@
                 app:layout_constraintStart_toEndOf="@+id/loadingImage"
                 app:layout_constraintTop_toTopOf="parent">
 
-                <!-- webview 演示web调用Java -->
-                <com.github.lzyzsd.jsbridge.BridgeWebView
-                    android:id="@+id/webView"
+                <FrameLayout
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:background="@android:color/white"
-                    app:layout_constraintBottom_toBottomOf="parent"
-                    app:layout_constraintEnd_toEndOf="parent"
-                    app:layout_constraintStart_toStartOf="parent"
-                    app:layout_constraintTop_toTopOf="parent" />
+                    android:layout_height="match_parent">
+
+                    <!-- webview 演示web调用Java -->
+                    <com.github.lzyzsd.jsbridge.BridgeWebView
+                        android:id="@+id/webView"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:background="@android:color/white"
+                        app:layout_constraintBottom_toBottomOf="parent"
+                        app:layout_constraintEnd_toEndOf="parent"
+                        app:layout_constraintStart_toStartOf="parent"
+                        app:layout_constraintTop_toTopOf="parent" />
+
+                    <androidx.constraintlayout.widget.ConstraintLayout
+                        android:id="@+id/gameFullLayout"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:visibility="gone">
+
+                        <FrameLayout
+                            android:layout_width="@dimen/divider_189px"
+                            android:layout_height="wrap_content"
+                            android:layout_marginStart="@dimen/divider_14px"
+                            android:minHeight="@dimen/divider_246px"
+                            app:layout_constraintBottom_toTopOf="@+id/loadingImages"
+                            app:layout_constraintStart_toStartOf="parent">
+
+                            <androidx.appcompat.widget.AppCompatImageView
+                                android:layout_width="match_parent"
+                                android:layout_height="match_parent"
+                                android:background="@mipmap/icon_game_dialog"
+                                android:scaleType="fitXY" />
+
+                            <androidx.appcompat.widget.AppCompatTextView
+                                android:id="@+id/tvIntroduces"
+                                android:layout_width="match_parent"
+                                android:layout_height="wrap_content"
+                                android:layout_marginStart="@dimen/divider_33px"
+                                android:layout_marginTop="@dimen/divider_28px"
+                                android:layout_marginEnd="@dimen/divider_31px"
+                                android:textColor="@color/color_FFA94A09"
+                                android:textSize="@dimen/divider_25px"
+                                android:textStyle="bold" />
+                        </FrameLayout>
+
+                        <androidx.appcompat.widget.AppCompatImageView
+                            android:id="@+id/loadingImages"
+                            android:layout_width="@dimen/divider_176px"
+                            android:layout_height="@dimen/divider_289px"
+                            android:layout_marginStart="@dimen/divider_21px"
+                            android:layout_marginBottom="@dimen/divider_61px"
+                            android:scaleType="centerInside"
+                            app:layout_constraintBottom_toBottomOf="parent"
+                            app:layout_constraintStart_toStartOf="parent" />
+
+                        <LinearLayout
+                            android:id="@+id/scoreLayouts"
+                            android:layout_width="@dimen/divider_153px"
+                            android:layout_height="@dimen/divider_158px"
+                            android:layout_marginStart="@dimen/divider_26px"
+                            android:layout_marginTop="@dimen/divider_130px"
+                            android:layout_marginEnd="@dimen/divider_28px"
+                            android:background="@mipmap/icon_play_score"
+                            android:gravity="center_horizontal"
+                            android:orientation="vertical"
+                            app:layout_constraintEnd_toEndOf="parent"
+                            app:layout_constraintTop_toTopOf="parent">
+
+                            <androidx.appcompat.widget.AppCompatTextView
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:layout_marginTop="@dimen/divider_54px"
+                                android:text="@string/score"
+                                android:textColor="@color/color_FFA94A09"
+                                android:textSize="@dimen/divider_32px"
+                                android:textStyle="bold" />
+
+                            <androidx.appcompat.widget.AppCompatTextView
+                                android:id="@+id/tvScores"
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:text="@string/zero"
+                                android:textColor="@color/color_FFA94A09"
+                                android:textSize="@dimen/divider_32px"
+                                android:textStyle="bold" />
+                        </LinearLayout>
+
+                        <androidx.appcompat.widget.AppCompatTextView
+                            android:id="@+id/tvTimes"
+                            android:layout_width="@dimen/divider_153px"
+                            android:layout_height="@dimen/divider_124px"
+                            android:layout_marginStart="@dimen/divider_26px"
+                            android:layout_marginTop="@dimen/divider_40px"
+                            android:layout_marginEnd="@dimen/divider_28px"
+                            android:background="@drawable/bg_game_score"
+                            android:gravity="center"
+                            android:textColor="@color/color_FFA94A09"
+                            android:textSize="@dimen/divider_48px"
+                            android:textStyle="bold"
+                            app:layout_constraintEnd_toEndOf="parent"
+                            app:layout_constraintTop_toBottomOf="@+id/scoreLayouts" />
+
+                        <androidx.appcompat.widget.AppCompatTextView
+                            android:id="@+id/tvGameLevels"
+                            android:layout_width="@dimen/divider_153px"
+                            android:layout_height="@dimen/divider_124px"
+                            android:layout_marginStart="@dimen/divider_26px"
+                            android:layout_marginTop="@dimen/divider_53px"
+                            android:layout_marginEnd="@dimen/divider_28px"
+                            android:background="@drawable/bg_game_score"
+                            android:gravity="center"
+                            android:textColor="@color/color_FFA94A09"
+                            android:textSize="@dimen/divider_48px"
+                            app:layout_constraintEnd_toEndOf="parent"
+                            app:layout_constraintTop_toBottomOf="@+id/tvTimes" />
 
+                    </androidx.constraintlayout.widget.ConstraintLayout>
+                </FrameLayout>
             </com.google.android.material.card.MaterialCardView>
 
             <LinearLayout