Ver Fonte

1.优化代码

王鹏鹏 há 2 anos atrás
pai
commit
00690fb7fe

+ 35 - 37
game/src/main/java/com/yingyangfly/game/play/PlayGameActivity.kt

@@ -578,48 +578,46 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
      */
     private fun parsingData(gameDataBean: GameDataBean, isPass: String) {
         runOnUiThread {
-            runOnUiThread {
-                if (TextUtils.equals("A", playClass)) {
+            if (TextUtils.equals("A", playClass)) {
+                val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
+                gameTotalScore = score.toString()
+                showCompletionTrainingDialog(gameDataBean)
+            } else {
+                if (TextUtils.equals("2", isPass)) {
+                    LiveEventBusUtil.send(RxBusCodes.QUITGAME, "")
+                    finish()
+                } else if (TextUtils.equals("3", isPass)) {
                     val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
                     gameTotalScore = score.toString()
-                    showCompletionTrainingDialog(gameDataBean)
+                    //游戏通关
+                    ARouter.getInstance().build(RouterUrlCommon.gameSettlement)
+                        .withString("gameCode", gameCode)
+                        .withString("playClass", playClass)
+                        .withString("gameType", gameType)
+                        .withTransition(R.anim.leftin, R.anim.leftout)
+                        .navigation(mContext)
                 } else {
-                    if (TextUtils.equals("2", isPass)) {
-                        LiveEventBusUtil.send(RxBusCodes.QUITGAME, "")
+                    val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
+                    gameTotalScore = score.toString()
+                    //游戏成功/失败
+                    gameResultDialog = GameResultDialog()
+                    gameResultDialog?.setData(
+                        gameDataBean.curLevel,
+                        gameTotalScore,
+                        gameDataBean.curLevelScore,
+                        isPass,
+                        gameSuccess,
+                        gameFailed,
+                        gameTimeOut
+                    )
+                    gameResultDialog?.onBackHomeDialogClickListener = {
                         finish()
-                    } else if (TextUtils.equals("3", isPass)) {
-                        val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
-                        gameTotalScore = score.toString()
-                        //游戏通关
-                        ARouter.getInstance().build(RouterUrlCommon.gameSettlement)
-                            .withString("gameCode", gameCode)
-                            .withString("playClass", playClass)
-                            .withString("gameType", gameType)
-                            .withTransition(R.anim.leftin, R.anim.leftout)
-                            .navigation(mContext)
-                    } else {
-                        val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
-                        gameTotalScore = score.toString()
-                        //游戏成功/失败
-                        gameResultDialog = GameResultDialog()
-                        gameResultDialog?.setData(
-                            gameDataBean.curLevel,
-                            gameTotalScore,
-                            gameDataBean.curLevelScore,
-                            isPass,
-                            gameSuccess,
-                            gameFailed,
-                            gameTimeOut
-                        )
-                        gameResultDialog?.onBackHomeDialogClickListener = {
-                            finish()
-                            LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
-                        }
-                        gameResultDialog?.onGameDialogClickListener = {
-                            loadJs(it)
-                        }
-                        gameResultDialog?.show(supportFragmentManager, "gameResultDialog")
+                        LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
+                    }
+                    gameResultDialog?.onGameDialogClickListener = {
+                        loadJs(it)
                     }
+                    gameResultDialog?.show(supportFragmentManager, "gameResultDialog")
                 }
             }
         }