|
@@ -1,6 +1,7 @@
|
|
|
package com.yingyangfly.game.play
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.content.Intent
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
import android.text.TextUtils
|
|
@@ -28,6 +29,9 @@ import com.yingyangfly.game.dialog.GameResultDialog
|
|
|
import com.yingyangfly.game.entity.GameBean
|
|
|
import com.yingyangfly.game.entity.GameDataBean
|
|
|
import com.yingyangfly.game.utils.AndroidToJs
|
|
|
+import gorden.rxbus2.RxBus
|
|
|
+import gorden.rxbus2.Subscribe
|
|
|
+import gorden.rxbus2.ThreadMode
|
|
|
|
|
|
/**
|
|
|
* 玩游戏页面
|
|
@@ -45,6 +49,17 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
super.onCreate(savedInstanceState)
|
|
|
}
|
|
|
|
|
|
+ override fun onNewIntent(intent: Intent?) {
|
|
|
+ super.onNewIntent(intent)
|
|
|
+ runOnUiThread {
|
|
|
+ binding.webView.evaluateJavascript(
|
|
|
+ "javascript:CallContinueGame()"
|
|
|
+ ) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override fun initViews() {
|
|
|
if (gameBean != null) {
|
|
|
val url = gameBean!!.gameUrl + "?startLv=" + gameBean!!.gameLevel + "&maxLv=" +
|
|
@@ -118,7 +133,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}, success = {
|
|
|
runOnUiThread {
|
|
|
if (TextUtils.equals("2", gameDataBean.isPass)) {
|
|
|
- //退出游戏
|
|
|
+ RxBus.get().send(RxBusCodes.QUITGAME)
|
|
|
finish()
|
|
|
} else if (TextUtils.equals("3", gameDataBean.isPass)) {
|
|
|
//游戏通关
|
|
@@ -219,6 +234,11 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
binding.webView.evaluateJavascript(
|
|
|
"javascript:CallPauseGame()"
|
|
|
) {
|
|
|
+ ARouter.getInstance().build(RouterUrlCommon.gameIntroduction)
|
|
|
+ .withString("gameCode", gameBean!!.gameCode)
|
|
|
+ .withString("playClass", gameBean!!.playClass)
|
|
|
+ .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
+ .navigation(mContext)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -268,4 +288,15 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Subscribe(code = RxBusCodes.CALLQUITGAME, threadMode = ThreadMode.MAIN)
|
|
|
+ fun callQuitGame() {
|
|
|
+ runOnUiThread {
|
|
|
+ binding.webView.evaluateJavascript(
|
|
|
+ "javascript:CallQuitGame()"
|
|
|
+ ) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|