|
|
@@ -146,10 +146,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
- Glide.with(mContext)
|
|
|
- .asGif()
|
|
|
- .load(R.drawable.fish)
|
|
|
- .into(binding.loadingImage)
|
|
|
+ Glide.with(mContext).asGif().load(R.drawable.fish).into(binding.loadingImage)
|
|
|
initLiveData()
|
|
|
setScreenData()
|
|
|
}
|
|
|
@@ -169,6 +166,11 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
|
|
|
override fun onNewIntent(intent: Intent?) {
|
|
|
super.onNewIntent(intent)
|
|
|
+ if (intent != null) {
|
|
|
+ id = intent.getStringExtra("id") ?: ""
|
|
|
+ gameCode = intent.getStringExtra("gameCode") ?: ""
|
|
|
+ playClass = intent.getStringExtra("playClass") ?: ""
|
|
|
+ }
|
|
|
newStartGame = false
|
|
|
runOnUiThread {
|
|
|
binding.webView.evaluateJavascript(
|
|
|
@@ -190,9 +192,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
requestBean.duration = gameDataBean.curLevelTime
|
|
|
requestBean.gameLevel = gameDataBean.curLevel
|
|
|
requestBean.gameScore = gameDataBean.curLevelScore
|
|
|
- viewModel.saveGameRecord(requestBean, fail = {
|
|
|
- }, success = {
|
|
|
- })
|
|
|
+ viewModel.saveGameRecord(requestBean, fail = {}, success = {})
|
|
|
}
|
|
|
|
|
|
@SuppressLint("JavascriptInterface", "SetJavaScriptEnabled")
|
|
|
@@ -236,8 +236,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
binding.webView.buildLayer()
|
|
|
binding.webView.webViewClient = object : WebViewClient() {
|
|
|
override fun shouldOverrideUrlLoading(
|
|
|
- view: WebView?,
|
|
|
- request: WebResourceRequest?
|
|
|
+ view: WebView?, request: WebResourceRequest?
|
|
|
): Boolean {
|
|
|
if (request != null) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
@@ -283,8 +282,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
) {
|
|
|
Log.e("wpp", "游戏暂停成功跳转介绍")
|
|
|
ARouter.getInstance().build(RouterUrlCommon.gameIntroduction)
|
|
|
- .withString("gameCode", gameCode)
|
|
|
- .withString("id", id)
|
|
|
+ .withString("gameCode", gameCode).withString("id", id)
|
|
|
.withString("playClass", playClass)
|
|
|
.withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
.navigation(mContext)
|
|
|
@@ -345,8 +343,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
val countdownDialog = CountdownDialog()
|
|
|
countdownDialog.setContentBackground(
|
|
|
- gameInbetweenImage,
|
|
|
- gameName
|
|
|
+ gameInbetweenImage, gameName
|
|
|
)
|
|
|
countdownDialog.onDialogClickListener = {
|
|
|
if (loadingOver) {
|
|
|
@@ -455,8 +452,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
Log.e("wpp", "游戏保存-----------" + it)
|
|
|
val gameDataBean = GsonUtil.GsonToBean(it, GameDataBean::class.java)
|
|
|
if (gameDataBean != null) {
|
|
|
- val score: Int =
|
|
|
- gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
|
|
|
+ val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
|
|
|
gameTotalScore = score.toString()
|
|
|
val isPass = gameDataBean.isPass
|
|
|
when (gameDataBean.isPass) {
|
|
|
@@ -571,8 +567,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
* 获取声音url
|
|
|
*/
|
|
|
private fun getVoiceUrl(taskDesn: String) {
|
|
|
- viewModel.getVoiceUrl(taskDesn, fail = {
|
|
|
- }, success = {
|
|
|
+ viewModel.getVoiceUrl(taskDesn, fail = {}, success = {
|
|
|
if (TextUtils.isEmpty(it).not()) {
|
|
|
if (db != null) {
|
|
|
val voicePlayerDao = db?.getVoicePlayerDao()
|
|
|
@@ -619,11 +614,9 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
} else if (TextUtils.equals("3", isPass)) {
|
|
|
//游戏通关
|
|
|
ARouter.getInstance().build(RouterUrlCommon.gameSettlement)
|
|
|
- .withString("gameCode", gameCode)
|
|
|
- .withString("playClass", playClass)
|
|
|
+ .withString("gameCode", gameCode).withString("playClass", playClass)
|
|
|
.withString("gameType", gameType)
|
|
|
- .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
- .navigation(mContext)
|
|
|
+ .withTransition(R.anim.leftin, R.anim.leftout).navigation(mContext)
|
|
|
} else {
|
|
|
//游戏成功/失败
|
|
|
gameResultDialog = GameResultDialog()
|
|
|
@@ -655,10 +648,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
private fun showCompletionTrainingDialog(gameDataBean: GameDataBean) {
|
|
|
val completionTrainingDialog = CompletionTrainingDialog()
|
|
|
completionTrainingDialog.setData(
|
|
|
- gameTotalScore,
|
|
|
- gameDataBean.curLevelScore,
|
|
|
- playClass,
|
|
|
- gameSuccess
|
|
|
+ gameTotalScore, gameDataBean.curLevelScore, playClass, gameSuccess
|
|
|
)
|
|
|
completionTrainingDialog.onDialogClickListener = {
|
|
|
runOnUiThread {
|
|
|
@@ -666,8 +656,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
}
|
|
|
completionTrainingDialog.show(
|
|
|
- supportFragmentManager,
|
|
|
- "completionTrainingDialog"
|
|
|
+ supportFragmentManager, "completionTrainingDialog"
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -681,16 +670,14 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
if (TextUtils.equals("0", fullFlag).not()) {
|
|
|
val params = ConstraintLayout.LayoutParams(
|
|
|
- mWebViewWidth,
|
|
|
- mWebViewHeight
|
|
|
+ mWebViewWidth, mWebViewHeight
|
|
|
)
|
|
|
binding.gameLayout.radius = 49F
|
|
|
binding.gameLayout.layoutParams = params
|
|
|
mConstrainSet_one?.applyTo(binding.gameParentLayout)
|
|
|
} else {
|
|
|
val params = FrameLayout.LayoutParams(
|
|
|
- FrameLayout.LayoutParams.MATCH_PARENT,
|
|
|
- FrameLayout.LayoutParams.MATCH_PARENT
|
|
|
+ FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT
|
|
|
)
|
|
|
binding.gameLayout.radius = 0F
|
|
|
binding.gameLayout.layoutParams = params
|