|
|
@@ -0,0 +1,84 @@
|
|
|
+package com.yingyangfly.game.dialog
|
|
|
+
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.LayoutInflater
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import android.widget.ProgressBar
|
|
|
+import androidx.appcompat.widget.AppCompatImageView
|
|
|
+import androidx.fragment.app.DialogFragment
|
|
|
+import com.bumptech.glide.Glide
|
|
|
+import com.gyf.immersionbar.BarHide
|
|
|
+import com.gyf.immersionbar.ktx.immersionBar
|
|
|
+import com.yingyangfly.baselib.utils.RxTimer
|
|
|
+import com.yingyangfly.baselib.utils.ViewTool
|
|
|
+import com.yingyangfly.game.R
|
|
|
+
|
|
|
+/**
|
|
|
+ * 游戏引导页弹框
|
|
|
+ */
|
|
|
+class GameLoadingDialog : DialogFragment() {
|
|
|
+
|
|
|
+ private var loadingImage: AppCompatImageView? = null
|
|
|
+ private var progressBar: ProgressBar? = null
|
|
|
+ private lateinit var rxTimer: RxTimer
|
|
|
+ private var time: Long = 3
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ isCancelable = false
|
|
|
+ dialog?.setCanceledOnTouchOutside(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStart() {
|
|
|
+ super.onStart()
|
|
|
+ dialog?.window?.setLayout(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
+ )
|
|
|
+ dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onCreateView(
|
|
|
+ inflater: LayoutInflater,
|
|
|
+ container: ViewGroup?,
|
|
|
+ savedInstanceState: Bundle?
|
|
|
+ ): View? {
|
|
|
+ immersionBar {
|
|
|
+ hideBar(BarHide.FLAG_HIDE_BAR)
|
|
|
+ navigationBarColor(R.color.transparent)
|
|
|
+ }
|
|
|
+ val rootView = ViewTool.inflateFragmentPixels(
|
|
|
+ activity, R.layout.dialog_game_loading, container, 1194, 834
|
|
|
+ )
|
|
|
+ findId(rootView)
|
|
|
+ initView()
|
|
|
+ initData()
|
|
|
+ return rootView
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun findId(rootView: View) {
|
|
|
+ loadingImage = rootView.findViewById(R.id.loadingImage)
|
|
|
+ progressBar = rootView.findViewById(R.id.progressBar)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initView() {
|
|
|
+ Glide.with(requireActivity())
|
|
|
+ .asGif()
|
|
|
+ .load(com.yingyangfly.baselib.R.drawable.fish)
|
|
|
+ .into(loadingImage!!)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initData() {
|
|
|
+ rxTimer = RxTimer()
|
|
|
+ rxTimer = RxTimer()
|
|
|
+ val m: Long = 1000
|
|
|
+ rxTimer.interval(m) {
|
|
|
+ progressBar!!.progress = it.toInt() + 1
|
|
|
+ if (time == it) {
|
|
|
+ rxTimer.cancel()
|
|
|
+ dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|