|
|
@@ -3,6 +3,7 @@ package com.yingyangfly.game.play
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
+import android.util.Log
|
|
|
import android.webkit.WebResourceRequest
|
|
|
import android.webkit.WebSettings
|
|
|
import android.webkit.WebView
|
|
|
@@ -13,10 +14,12 @@ import com.yingyangfly.baselib.R
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
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.game.databinding.ActivityPlayGameBinding
|
|
|
import com.yingyangfly.game.entity.GameBean
|
|
|
+import com.yingyangfly.game.entity.GameDataBean
|
|
|
import com.yingyangfly.game.utils.AndroidToJs
|
|
|
|
|
|
/**
|
|
|
@@ -35,10 +38,11 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
|
|
|
override fun initViews() {
|
|
|
if (gameBean != null) {
|
|
|
- val url =
|
|
|
- gameBean!!.gameUrl + "?startLv=" + gameBean!!.gameLevel + "&maxLv=" + gameBean!!.totalNum +
|
|
|
- "&gameSetTime=" + gameBean!!.gameDuration + "&difficultyRate=" + gameBean!!.gameDifficultyRate +
|
|
|
- "&totalTime=" + gameBean!!.gameTotalTime + "&totalScore=" + gameBean!!.gameTotalScore
|
|
|
+ val url = gameBean!!.gameUrl + "?startLv=" + gameBean!!.gameLevel + "&maxLv=" +
|
|
|
+ gameBean!!.totalNum + "&gameSetTime=" + gameBean!!.gameDuration + "&difficultyRate=" +
|
|
|
+ gameBean!!.gameDifficultyRate + "&totalTime=" + gameBean!!.gameTotalTime +
|
|
|
+ "&totalScore=" + gameBean!!.gameTotalScore
|
|
|
+ Log.e("wpp", url)
|
|
|
initWebView(url)
|
|
|
} else {
|
|
|
"数据错误".toast()
|
|
|
@@ -54,21 +58,38 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
.asGif()
|
|
|
.load(R.drawable.fish)
|
|
|
.into(binding.loadingImage)
|
|
|
-
|
|
|
//游戏时间
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.SETTIME) {
|
|
|
binding.tvTime.post {
|
|
|
+ val data = it.split("setTime:")
|
|
|
+ Log.e("wpp", "setTime:"+data)
|
|
|
binding.tvTime.text = it
|
|
|
}
|
|
|
}
|
|
|
//分数
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.SETSCORE) {
|
|
|
binding.tvScore.post {
|
|
|
+ val data = it.split("setScore:")
|
|
|
+ Log.e("wpp", "setScore:"+data)
|
|
|
binding.tvScore.text = it
|
|
|
}
|
|
|
}
|
|
|
+ //游戏进度
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.SAVEDATA) {
|
|
|
+ binding.tvScore.post {
|
|
|
+ Log.e("wpp", it)
|
|
|
+ val data = it.split("saveData:")
|
|
|
+ if (data.isNullOrEmpty().not()) {
|
|
|
+ if (data[1].isNullOrEmpty().not()) {
|
|
|
+ Log.e("wpp", data[1])
|
|
|
+// var gameDataBean = GsonUtil.GsonToBean(data[1], GameDataBean::class.java)
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@SuppressLint("JavascriptInterface", "SetJavaScriptEnabled")
|