Przeglądaj źródła

1.添加游戏超时或失败记录只保存一次

王鹏鹏 2 lat temu
rodzic
commit
60d01b8f80

+ 8 - 1
game/src/main/java/com/yingyangfly/game/introduction/GameIntroductionActivity.kt

@@ -9,6 +9,9 @@ import android.view.MotionEvent
 import android.view.View
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
+import com.bumptech.glide.Glide
+import com.bumptech.glide.load.engine.DiskCacheStrategy
+import com.bumptech.glide.request.RequestOptions
 import com.tencent.liteav.demo.superplayer.SuperPlayerModel
 import com.yingyangfly.baselib.config.AccountConfig
 import com.yingyangfly.baselib.db.VoicePlayerBean
@@ -64,7 +67,11 @@ class GameIntroductionActivity :
     override fun initViews() {
         voicePlayer = VoicePlayer.getInstance(mContext)
         if (TextUtils.isEmpty(gameInbetweenImage).not()) {
-            binding.image = gameInbetweenImage
+            val options: RequestOptions = RequestOptions()
+                .placeholder(R.drawable.bg_game_settlement)
+                .error(R.drawable.bg_game_settlement)
+                .diskCacheStrategy(DiskCacheStrategy.ALL)
+            Glide.with(mContext).load(gameInbetweenImage).apply(options).into(binding.imageBg)
         }
     }
 

+ 7 - 2
game/src/main/java/com/yingyangfly/game/play/PlayGameActivity.kt

@@ -15,6 +15,8 @@ import android.webkit.WebViewClient
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
 import com.bumptech.glide.Glide
+import com.bumptech.glide.load.engine.DiskCacheStrategy
+import com.bumptech.glide.request.RequestOptions
 import com.yingyangfly.baselib.db.VoicePlayerBean
 import com.yingyangfly.baselib.ext.getEndAnimation
 import com.yingyangfly.baselib.ext.getScaleAnimation
@@ -35,7 +37,6 @@ import com.yingyangfly.game.utils.AndroidToJs
 import gorden.rxbus2.RxBus
 import gorden.rxbus2.Subscribe
 import gorden.rxbus2.ThreadMode
-import java.util.concurrent.ThreadFactory
 
 /**
  * 玩游戏页面
@@ -74,7 +75,11 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
             initWebView(url)
         }
         if (TextUtils.isEmpty(gameBackgroundImage).not()) {
-            binding.image = gameBackgroundImage
+            val options: RequestOptions = RequestOptions()
+                .placeholder(R.drawable.bg_game_settlement)
+                .error(R.drawable.bg_game_settlement)
+                .diskCacheStrategy(DiskCacheStrategy.ALL)
+            Glide.with(mContext).load(gameInbetweenImage).apply(options).into(binding.imageBg)
         }
         if (TextUtils.isEmpty(gameShortDesn).not()) {
             binding.tvPlay.text = gameShortDesn

+ 2 - 3
game/src/main/res/layout/activity_game_introduction.xml

@@ -20,11 +20,10 @@
         android:layout_height="match_parent">
 
         <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/imageBg"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:scaleType="centerCrop"
-            app:isCircle="@{false}"
-            app:loadHeadImg="@{image}" />
+            android:scaleType="centerCrop" />
 
         <androidx.constraintlayout.widget.ConstraintLayout
             android:id="@+id/gameLayout"

+ 2 - 3
game/src/main/res/layout/activity_play_game.xml

@@ -20,11 +20,10 @@
         android:layout_height="match_parent">
 
         <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/imageBg"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:scaleType="centerCrop"
-            app:isCircle="@{false}"
-            app:loadHeadImg="@{image}" />
+            android:scaleType="centerCrop" />
 
         <androidx.constraintlayout.widget.ConstraintLayout
             android:layout_width="match_parent"