|
@@ -1,6 +1,8 @@
|
|
|
package com.yingyangfly.baselib.dialog
|
|
|
|
|
|
import android.os.Bundle
|
|
|
+import android.os.CountDownTimer
|
|
|
+import android.util.Log
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
@@ -11,7 +13,6 @@ import com.bumptech.glide.Glide
|
|
|
import com.gyf.immersionbar.BarHide
|
|
|
import com.gyf.immersionbar.ktx.immersionBar
|
|
|
import com.yingyangfly.baselib.R
|
|
|
-import com.yingyangfly.baselib.utils.RxTimer
|
|
|
import com.yingyangfly.baselib.utils.ViewTool
|
|
|
|
|
|
/**
|
|
@@ -21,8 +22,6 @@ class GameLoadingDialog : DialogFragment() {
|
|
|
|
|
|
private var loadingImage: AppCompatImageView? = null
|
|
|
private var progressBar: ProgressBar? = null
|
|
|
- private lateinit var rxTimer: RxTimer
|
|
|
- private var time: Long = 3
|
|
|
var onDialogClickListener: ((bean: String) -> Unit)? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -71,21 +70,17 @@ class GameLoadingDialog : DialogFragment() {
|
|
|
}
|
|
|
|
|
|
private fun initData() {
|
|
|
- rxTimer = RxTimer()
|
|
|
- val m: Long = 1000
|
|
|
- rxTimer.interval(m) {
|
|
|
- progressBar!!.progress = it.toInt() + 1
|
|
|
- if (time == it) {
|
|
|
- rxTimer.cancel()
|
|
|
- setData()
|
|
|
+ val countDownTimer = object : CountDownTimer(4000, 1000) {
|
|
|
+ override fun onTick(millisUntilFinished: Long) {
|
|
|
+ val progress = 4 - millisUntilFinished / 1000
|
|
|
+ progressBar!!.progress = progress.toInt()
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- private fun setData() {
|
|
|
- loadingImage!!.postDelayed({
|
|
|
- onDialogClickListener?.invoke("")
|
|
|
- dismiss()
|
|
|
- }, 200)
|
|
|
+ override fun onFinish() {
|
|
|
+ onDialogClickListener?.invoke("")
|
|
|
+ dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ countDownTimer.start()
|
|
|
}
|
|
|
}
|