|
|
@@ -2,6 +2,7 @@ package com.yingyangfly.game.dialog
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
|
+import android.content.DialogInterface
|
|
|
import android.os.Bundle
|
|
|
import android.text.TextUtils
|
|
|
import android.view.LayoutInflater
|
|
|
@@ -15,6 +16,7 @@ import com.bumptech.glide.Glide
|
|
|
import com.gyf.immersionbar.BarHide
|
|
|
import com.gyf.immersionbar.ktx.immersionBar
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.player.VoicePlayer
|
|
|
import com.yingyangfly.baselib.utils.ViewTool
|
|
|
import com.yingyangfly.game.R
|
|
|
import com.yingyangfly.game.widget.NumberAnimTextView
|
|
|
@@ -32,14 +34,17 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
private var totalScore: String = ""
|
|
|
private var curLevelScore: String = ""
|
|
|
private var playClass: String = ""
|
|
|
+ private var gameSuccess: String = ""
|
|
|
private var btnDetermine: AppCompatImageView? = null
|
|
|
private var content: Context? = null
|
|
|
var onDialogClickListener: ((bean: String) -> Unit)? = null
|
|
|
+ private var voicePlayer: VoicePlayer? = null
|
|
|
|
|
|
- fun setData(totalScore: String, curLevelScore: String, playClass: String) {
|
|
|
+ fun setData(totalScore: String, curLevelScore: String, playClass: String, gameSuccess: String) {
|
|
|
this.totalScore = totalScore
|
|
|
this.curLevelScore = curLevelScore
|
|
|
this.playClass = playClass
|
|
|
+ this.gameSuccess = gameSuccess
|
|
|
}
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
@@ -70,6 +75,7 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
activity, R.layout.dialog_completion_training, container, 1194, 834
|
|
|
)
|
|
|
content = activity
|
|
|
+ voicePlayer = VoicePlayer.getInstance(content)
|
|
|
findId(rootView)
|
|
|
initData()
|
|
|
initListener()
|
|
|
@@ -78,7 +84,7 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
|
|
|
private fun findId(rootView: View) {
|
|
|
totalScoreLayout = rootView.findViewById(R.id.totalScoreLayout)
|
|
|
- if(TextUtils.equals("D", playClass)){
|
|
|
+ if (TextUtils.equals("D", playClass)) {
|
|
|
totalScoreLayout?.visibility = View.INVISIBLE
|
|
|
} else {
|
|
|
totalScoreLayout?.visibility = View.VISIBLE
|
|
|
@@ -88,7 +94,7 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
tvGameLevelScore = rootView.findViewById(R.id.tvGameLevelScore)
|
|
|
btnDetermine = rootView.findViewById(R.id.btnDetermine)
|
|
|
tvLevelScore = rootView.findViewById(R.id.tvLevelScore)
|
|
|
- tvLevelScore?.text = if(TextUtils.equals("D", playClass)){
|
|
|
+ tvLevelScore?.text = if (TextUtils.equals("D", playClass)) {
|
|
|
"体验分数:"
|
|
|
} else {
|
|
|
"本关得分:"
|
|
|
@@ -107,6 +113,11 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
tvTotalScore?.setNumberString(totalScore)
|
|
|
tvGameLevelScore?.setEnableAnim(true)
|
|
|
tvGameLevelScore?.setNumberString(curLevelScore)
|
|
|
+ if (content != null && !TextUtils.isEmpty(gameSuccess)) {
|
|
|
+ voicePlayer?.play(gameSuccess) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun initListener() {
|
|
|
@@ -114,4 +125,11 @@ class CompletionTrainingDialog : DialogFragment() {
|
|
|
onDialogClickListener?.invoke("")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ override fun dismiss() {
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ voicePlayer?.stop()
|
|
|
+ }
|
|
|
+ super.dismiss()
|
|
|
+ }
|
|
|
}
|