فهرست منبع

1.优化代码

王鹏鹏 2 سال پیش
والد
کامیت
20b11a43eb

+ 1 - 0
.idea/misc.xml

@@ -477,6 +477,7 @@
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/item_training_content_details.xml" value="0.4" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/layout_empty.xml" value="0.1" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/spinner_list_item.xml" value="0.1" />
+        <entry key="..\:/workspace/hcp-pads/baselib/src/main/res/drawable/bg_game_background_settlement.xml" value="0.151" />
         <entry key="..\:/workspace/hcp-pads/baselib/src/main/res/drawable/home_webview_progressbar_selector.xml" value="0.151" />
         <entry key="..\:/workspace/hcp-pads/baselib/src/main/res/layout/activity_base.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pads/baselib/src/main/res/layout/activity_base_web_view.xml" value="0.23697916666666666" />

+ 12 - 0
baselib/src/main/java/com/yingyangfly/baselib/utils/img/ImgUtil.java

@@ -28,6 +28,18 @@ import io.reactivex.annotations.Nullable;
  * Description:
  */
 public class ImgUtil {
+
+    public static void loadGameBackground(Context context, String url, final ImageView img) {
+        RequestOptions options = new RequestOptions()
+                .placeholder(R.drawable.bg_game_background_settlement)
+                .error(R.drawable.bg_game_background_settlement)
+                .diskCacheStrategy(DiskCacheStrategy.ALL);
+        Glide.with(context)
+                .load(url)
+                .apply(options)
+                .into(img);
+    }
+
     public static void loadImgFace(Context context, String face_url, final ImageView img) {
         RequestOptions options = new RequestOptions()
                 .placeholder(R.mipmap.icon_place_holder)

+ 17 - 0
baselib/src/main/res/drawable/bg_game_background_settlement.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <item>
+        <shape android:shape="rectangle">
+            <gradient
+                android:angle="90"
+                android:endColor="@color/color_FC426CFB"
+                android:startColor="@color/color_FF35BEFC"
+                android:type="linear"
+                android:useLevel="true" />
+        </shape>
+    </item>
+
+</layer-list>

+ 2 - 0
baselib/src/main/res/values/colors.xml

@@ -25,4 +25,6 @@
     <color name="color_FF222222">#F222222</color>
     <color name="color_FF4174FF">#FF4174FF</color>
     <color name="color_FF6D9AFF">#FF6D9AFF</color>
+    <color name="color_FC426CFB">#FC426CFB</color>
+    <color name="color_FF35BEFC">#FF35BEFC</color>
 </resources>

+ 3 - 8
game/src/main/java/com/yingyangfly/game/dialog/CountdownDialog.kt

@@ -9,8 +9,6 @@ import androidx.annotation.RequiresApi
 import androidx.appcompat.widget.AppCompatImageView
 import androidx.fragment.app.DialogFragment
 import com.bumptech.glide.Glide
-import com.bumptech.glide.load.engine.DiskCacheStrategy
-import com.bumptech.glide.request.RequestOptions
 import com.gyf.immersionbar.BarHide
 import com.gyf.immersionbar.ktx.immersionBar
 import com.yingyangfly.baselib.player.VoicePlayer
@@ -18,6 +16,7 @@ import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
 import com.yingyangfly.baselib.utils.RxTimer
 import com.yingyangfly.baselib.utils.ViewTool
+import com.yingyangfly.baselib.utils.img.ImgUtil
 import com.yingyangfly.game.R
 
 /**
@@ -33,8 +32,6 @@ class CountdownDialog : DialogFragment() {
     private var loadingImage: AppCompatImageView? = null
     private var countdown = false
     private var loadingOver = false
-
-
     private var voicePlayer: VoicePlayer? = null
 
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -56,6 +53,7 @@ class CountdownDialog : DialogFragment() {
         dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
     }
 
+    @RequiresApi(Build.VERSION_CODES.N)
     override fun onCreateView(
         inflater: LayoutInflater,
         container: ViewGroup?,
@@ -77,14 +75,11 @@ class CountdownDialog : DialogFragment() {
 
     private fun findId(rootView: View) {
         gameImage = rootView.findViewById(R.id.gameImage)
-        val options: RequestOptions = RequestOptions()
-            .diskCacheStrategy(DiskCacheStrategy.ALL)
-        Glide.with(requireActivity()).load(url).apply(options).into(gameImage!!)
+        ImgUtil.loadGameBackground(requireActivity(), url, gameImage!!)
         imageCountdown = rootView.findViewById(R.id.imageCountdown)
         loadingImage = rootView.findViewById(R.id.loadingImage)
     }
 
-    @RequiresApi(Build.VERSION_CODES.N)
     private fun initData() {
         Glide.with(requireActivity())
             .asGif()

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

@@ -8,9 +8,6 @@ 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
@@ -23,6 +20,7 @@ import com.yingyangfly.baselib.player.VoicePlayer
 import com.yingyangfly.baselib.router.RouterUrlCommon
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
+import com.yingyangfly.baselib.utils.img.ImgUtil
 import com.yingyangfly.game.R
 import com.yingyangfly.game.databinding.ActivityGameIntroductionBinding
 import com.yingyangfly.game.dialog.ExitGameDialog
@@ -63,11 +61,7 @@ class GameIntroductionActivity :
 
     override fun initViews() {
         voicePlayer = VoicePlayer.getInstance(mContext)
-        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)
+        ImgUtil.loadGameBackground(mContext, gameInbetweenImage, binding.imageBg)
     }
 
     @SuppressLint("ClickableViewAccessibility")

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

@@ -15,8 +15,6 @@ 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
@@ -27,6 +25,7 @@ import com.yingyangfly.baselib.router.RouterUrlCommon
 import com.yingyangfly.baselib.utils.GsonUtil
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
+import com.yingyangfly.baselib.utils.img.ImgUtil
 import com.yingyangfly.game.R
 import com.yingyangfly.game.databinding.ActivityPlayGameBinding
 import com.yingyangfly.game.dialog.CompletionTrainingDialog
@@ -74,11 +73,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
         if (TextUtils.isEmpty(url).not()) {
             initWebView(url)
         }
-        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)
+        ImgUtil.loadGameBackground(mContext, gameInbetweenImage, binding.imageBg)
         if (TextUtils.isEmpty(gameShortDesn).not()) {
             binding.tvPlay.text = gameShortDesn
             binding.tvIntroduce.text = gameShortDesn

+ 26 - 13
home/src/main/java/com/yingyangfly/home/activity/HomeActivity.kt

@@ -6,6 +6,7 @@ import android.view.MotionEvent
 import android.view.View
 import androidx.recyclerview.widget.GridLayoutManager
 import com.alibaba.android.arouter.facade.annotation.Route
+import com.alibaba.android.arouter.launcher.ARouter
 import com.bumptech.glide.Glide
 import com.tencent.imsdk.v2.V2TIMCallback
 import com.tencent.imsdk.v2.V2TIMManager
@@ -399,10 +400,15 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(),
      * 跳转游戏列表
      */
     private fun jumpWebView(bean: Record, isFull: Boolean) {
-        val str =
-            bean.gameUrl + "?gameCode=" + bean.gameCode + "&isFull=" + isFull + "&isSound=true&playClass=" + bean.playClass +
-                    "&userToken=" + User.getToken()
-        JumpUtil.jumpActivityWithUrl(RouterUrlCommon.WEB_VIEW_INTERACTION_JS, str, this)
+        ARouter.getInstance().build(RouterUrlCommon.gameLoading)
+            .withString("gameCode", bean.gameCode)
+            .withString("playClass", bean.playClass)
+            .withString("videoUrl", bean.gameVideoUrl)
+            .withString("gameInbetweenImage", bean.gameInbetweenImage)
+            .withString("gameBackgroundImage", bean.gameBackgroundImage)
+            .withString("desn", bean.desn)
+            .withTransition(R.anim.leftin, R.anim.leftout)
+            .navigation(mContext)
     }
 
     /**
@@ -567,15 +573,7 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(),
                     R.id.btnTask -> {
                         //开始专属训练
                         if (currentTaskRecord != null) {
-                            currentTaskRecord.let {
-                                val str =
-                                    it?.gameUrl + "?gameCode=" + it?.gameCode + "&isFull=true&isSound=true&playClass=A" + "&userToken=" + User.getToken()
-                                JumpUtil.jumpActivityWithUrl(
-                                    RouterUrlCommon.WEB_VIEW_INTERACTION_JS,
-                                    str,
-                                    mContext
-                                )
-                            }
+                            gameLoading(currentTaskRecord!!)
                         }
                     }
                     //开始训练蒙版
@@ -607,4 +605,19 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(),
         }
         return true
     }
+
+    /**
+     * 跳转游戏页面
+     */
+    private fun gameLoading(bean: Record) {
+        ARouter.getInstance().build(RouterUrlCommon.gameLoading)
+            .withString("gameCode", bean.gameCode)
+            .withString("playClass", bean.playClass)
+            .withString("videoUrl", bean.gameVideoUrl)
+            .withString("gameInbetweenImage", bean.gameInbetweenImage)
+            .withString("gameBackgroundImage", bean.gameBackgroundImage)
+            .withString("desn", bean.desn)
+            .withTransition(R.anim.leftin, R.anim.leftout)
+            .navigation(mContext)
+    }
 }

+ 8 - 0
home/src/main/res/anim/leftin.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="100%p"
+        android:toXDelta="0" />
+</set> 
+

+ 8 - 0
home/src/main/res/anim/leftout.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="0"
+        android:toXDelta="-100%p" />
+</set> 
+