|
|
@@ -21,6 +21,7 @@ import androidx.constraintlayout.widget.ConstraintSet
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
import com.bumptech.glide.Glide
|
|
|
+import com.tencent.bugly.crashreport.CrashReport
|
|
|
import com.yingyangfly.baselib.bean.GameDataBean
|
|
|
import com.yingyangfly.baselib.bean.GetSaveGameRecordBean
|
|
|
import com.yingyangfly.baselib.db.VoicePlayerBean
|
|
|
@@ -35,7 +36,9 @@ import com.yingyangfly.baselib.utils.GsonUtil
|
|
|
import com.yingyangfly.baselib.utils.JumpUtil
|
|
|
import com.yingyangfly.baselib.utils.LiveEventBusUtil
|
|
|
import com.yingyangfly.baselib.utils.RxBusCodes
|
|
|
+import com.yingyangfly.baselib.utils.User
|
|
|
import com.yingyangfly.baselib.utils.img.ImgUtil
|
|
|
+import com.yingyangfly.game.BuildConfig
|
|
|
import com.yingyangfly.game.R
|
|
|
import com.yingyangfly.game.databinding.ActivityPlayGameBinding
|
|
|
import com.yingyangfly.game.dialog.CompletionTrainingDialog
|
|
|
@@ -64,7 +67,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
/**
|
|
|
* 是否第一次启动activity
|
|
|
*/
|
|
|
- private var newStartGame = true
|
|
|
+ private var isNewPlayGameJump = false
|
|
|
|
|
|
/**
|
|
|
* 倒计时是否结束
|
|
|
@@ -103,6 +106,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
url = intent.getStringExtra("url") ?: ""
|
|
|
gameType = intent.getStringExtra("gameType") ?: ""
|
|
|
gameTotalScore = intent.getStringExtra("gameTotalScore") ?: ""
|
|
|
+ isNewPlayGameJump = intent.getBooleanExtra("isPlayGameJump", false)
|
|
|
if (TextUtils.isEmpty(gameTotalScore)) {
|
|
|
gameTotalScore = "0"
|
|
|
}
|
|
|
@@ -172,13 +176,13 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
id = intent.getStringExtra("id") ?: ""
|
|
|
gameCode = intent.getStringExtra("gameCode") ?: ""
|
|
|
playClass = intent.getStringExtra("playClass") ?: ""
|
|
|
+ isNewPlayGameJump = intent.getBooleanExtra("isPlayGameJump", false)
|
|
|
}
|
|
|
- newStartGame = false
|
|
|
runOnUiThread {
|
|
|
binding.webView.evaluateJavascript(
|
|
|
"javascript:CallContinueGame()"
|
|
|
) {
|
|
|
-
|
|
|
+ Log.e("wpp", "----------------继续游戏")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -275,19 +279,27 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
when (v.id) {
|
|
|
R.id.imagePause -> {
|
|
|
runOnUiThread {
|
|
|
- if (TextUtils.equals("D", playClass)) {
|
|
|
+ if (callQuitGame) {
|
|
|
+ reportGameCrashInfo("游戏结束退出失败,通过返回键退出游戏")
|
|
|
+ ActivityManagers.instance.finishActivity(GameIntroductionActivity::class.java)
|
|
|
finish()
|
|
|
} else {
|
|
|
- Log.e("wpp", "游戏暂停")
|
|
|
- binding.webView.evaluateJavascript(
|
|
|
- "javascript:CallPauseGame()"
|
|
|
- ) {
|
|
|
- Log.e("wpp", "游戏暂停成功跳转介绍")
|
|
|
- ARouter.getInstance().build(RouterUrlCommon.gameIntroduction)
|
|
|
- .withString("gameCode", gameCode).withString("id", id)
|
|
|
- .withString("playClass", playClass)
|
|
|
- .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
- .navigation(mContext)
|
|
|
+ if (TextUtils.equals("D", playClass)) {
|
|
|
+ finish()
|
|
|
+ } else {
|
|
|
+ Log.e("wpp", "游戏暂停")
|
|
|
+ binding.webView.evaluateJavascript(
|
|
|
+ "javascript:CallPauseGame()"
|
|
|
+ ) {
|
|
|
+ Log.e("wpp", "游戏暂停成功跳转介绍")
|
|
|
+ ARouter.getInstance()
|
|
|
+ .build(RouterUrlCommon.gameIntroduction)
|
|
|
+ .withString("gameCode", gameCode).withString("id", id)
|
|
|
+ .withString("playClass", playClass)
|
|
|
+ .withBoolean("isPlayGameJump", true)
|
|
|
+ .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
+ .navigation(mContext)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -319,8 +331,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
- if (newStartGame) {
|
|
|
- newStartGame = false
|
|
|
+ if (isNewPlayGameJump.not()) {
|
|
|
if (gameSoundDao != null) {
|
|
|
val gameSoundbeans = gameSoundDao?.getAllGameSoundBean()
|
|
|
if (gameSoundbeans.isNullOrEmpty().not()) {
|
|
|
@@ -450,9 +461,9 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
//游戏进度
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.SAVEDATA) {
|
|
|
- binding.tvScore.postDelayed({
|
|
|
+ runOnUiThread {
|
|
|
if (TextUtils.isEmpty(it).not()) {
|
|
|
- Log.e("wpp", "游戏保存-----------" + it)
|
|
|
+ Log.e("wpp", "游戏保存-----------$it")
|
|
|
val gameDataBean = GsonUtil.GsonToBean(it, GameDataBean::class.java)
|
|
|
if (gameDataBean != null) {
|
|
|
val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
|
|
|
@@ -475,9 +486,13 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
} else {
|
|
|
parsingData(gameDataBean, isPass)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ reportGameCrashInfo("h5返回信息解析失败")
|
|
|
}
|
|
|
+ } else {
|
|
|
+ reportGameCrashInfo("h5返回游戏信息为空")
|
|
|
}
|
|
|
- }, 100)
|
|
|
+ }
|
|
|
}
|
|
|
//游戏加载完成
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.LOADINGOVER) {
|
|
|
@@ -707,4 +722,18 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
val cn = am.getRunningTasks(1)[0].topActivity
|
|
|
return cn!!.className == activity.javaClass.name
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上报游戏异常
|
|
|
+ */
|
|
|
+ private fun reportGameCrashInfo(msg: String) {
|
|
|
+ if (BuildConfig.DEBUG) {
|
|
|
+ Log.e("wpp", "游戏页面日志上报----------------->$msg")
|
|
|
+ CrashReport.postCatchedException(
|
|
|
+ Throwable(
|
|
|
+ msg + "\n用户信息:" + User.getName() + User.getUserId() + "\n游戏名称: " + gameName + "游戏code: " + gameCode
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|