|
|
@@ -1,11 +1,14 @@
|
|
|
package com.yingyangfly.game.dialog
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.os.Bundle
|
|
|
+import android.text.TextUtils
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import androidx.appcompat.widget.AppCompatButton
|
|
|
import androidx.appcompat.widget.AppCompatTextView
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
import androidx.fragment.app.DialogFragment
|
|
|
import com.gyf.immersionbar.BarHide
|
|
|
import com.gyf.immersionbar.ktx.immersionBar
|
|
|
@@ -17,11 +20,16 @@ import com.yingyangfly.game.R
|
|
|
*/
|
|
|
class GameResultDialog : DialogFragment() {
|
|
|
|
|
|
+ private var gameLayout: ConstraintLayout? = null
|
|
|
private var tvGameLevel: AppCompatTextView? = null
|
|
|
private var tvTotalGameScore: AppCompatTextView? = null
|
|
|
private var tvGameScore: AppCompatTextView? = null
|
|
|
private var btnHome: AppCompatButton? = null
|
|
|
private var btnContinueThisLevel: AppCompatButton? = null
|
|
|
+ private var curLevel: String = ""
|
|
|
+ private var curLevelScore: String = ""
|
|
|
+ private var isPass: String = ""
|
|
|
+ private var totalScore: String = ""
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
@@ -29,8 +37,11 @@ class GameResultDialog : DialogFragment() {
|
|
|
dialog?.setCanceledOnTouchOutside(true)
|
|
|
}
|
|
|
|
|
|
- fun setData() {
|
|
|
-
|
|
|
+ fun setData(curLevel: String, totalScore: String, curLevelScore: String, isPass: String) {
|
|
|
+ this.curLevel = curLevel
|
|
|
+ this.totalScore = totalScore
|
|
|
+ this.curLevelScore = curLevelScore
|
|
|
+ this.isPass = isPass
|
|
|
}
|
|
|
|
|
|
override fun onStart() {
|
|
|
@@ -55,14 +66,28 @@ class GameResultDialog : DialogFragment() {
|
|
|
activity, R.layout.dialog_game_result, container, 1194, 834
|
|
|
)
|
|
|
findId(rootView)
|
|
|
+ initData()
|
|
|
return rootView
|
|
|
}
|
|
|
|
|
|
private fun findId(rootView: View) {
|
|
|
+ gameLayout = rootView.findViewById(R.id.gameLayout)
|
|
|
tvGameLevel = rootView.findViewById(R.id.tvGameLevel)
|
|
|
tvTotalGameScore = rootView.findViewById(R.id.tvTotalGameScore)
|
|
|
tvGameScore = rootView.findViewById(R.id.tvGameScore)
|
|
|
btnHome = rootView.findViewById(R.id.btnHome)
|
|
|
btnContinueThisLevel = rootView.findViewById(R.id.btnContinueThisLevel)
|
|
|
}
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ private fun initData() {
|
|
|
+ if (TextUtils.equals("1", isPass)) {
|
|
|
+ gameLayout?.setBackgroundResource(R.mipmap.icon_game_fail)
|
|
|
+ } else {
|
|
|
+ gameLayout?.setBackgroundResource(R.mipmap.icon_game_success)
|
|
|
+ }
|
|
|
+ tvGameLevel?.text = "当前关卡:$curLevel"
|
|
|
+ tvTotalGameScore?.text = "总得分:" + totalScore + "分"
|
|
|
+ tvGameScore?.text = "本关得分:" + curLevelScore + "分"
|
|
|
+ }
|
|
|
}
|