Skip to content

Hasiy/spinkitprogressbarDialog

Repository files navigation

spinkitprogressbarDialog

Android 加载 ProgressBarDialog 基于spinkit动画(参照SpinKit

基于DialogFragment 不会发生 WindowLeaked 错误

效果

Gradle 设置

dependencies {
      implementation 'top.hasiy:spinkitprogressbar:1.3.0'
}

使用

  • BaseActivity
abstract class BaseActivity : AppCompatActivity(), SpinkitProgressBarDialogManager {
override var loadingIsShow: Boolean = false
override lateinit var spinkitProgressBarDialog: SpinkitProgressBarDialog
    
    //初始化Dialog
    override fun onStart() {
        SpinkitProgressBarDialogConfig.instance
        .messageShow(true)
        // 是否显示加载文字
        .spinKitColor(Color.parseColor("#a1c4fd"))
        //设置spinKit显示颜色         
        .spinKitStatus("WanderingCubes")
        // 设置加载动画 
        .apply()
        //应用
        //SpinkitProgressBarDialogConfig.reset()  恢复默认设置
         super.onStart()
 	}

    private fun showProgressBar() {
      showSpinkitProgressBarDialog(supportFragmentManager)
    }

    fun showBaseProgressBar() {
    	//显示无文字 Dialog
    	SpinkitProgressBarDialogConfig.instance
        .messageShow(false)
        .spinKitColor(Color.parseColor("#a1c4fd"))
        .spinKitStatus("WanderingCubes")
        .apply()
        spinkitProgressBarDialog =
        SpinkitProgressBarDialog.instance("")
        showProgressBar()
    }

    fun showBaseProgressBar(text: String) {
        //显示文字 Dialog
         SpinkitProgressBarDialogConfig.instance
        .messageShow(true)
        .spinKitColor(Color.parseColor("#a1c4fd"))
        .spinKitStatus("WanderingCubes")
        .apply()
        spinkitProgressBarDialog =	
        SpinkitProgressBarDialog.instance(text)
        showProgressBar()
    }

    //关闭 Dialog
    fun dismissBaseProgressBar() {
        if (!this.isDestroyed && !this.isFinishing) {
            dismissSpinkitProgressBarDialog()
        }
    }
    
}
  • 其他Activity 调用

    显示 : showBaseProgressBar() || showBaseProgressBar("加载中...") 关闭 : dismissBaseProgressBar()

调用Demo:

SpinKitStatus样式:

样式 预览
RotatingPlane RotatingPlane
DoubleBounce DoubleBounce
Wave Wave
WanderingCubes WanderingCubes
Pulse Pulse
ChasingDots ChasingDots
ThreeBounce ThreeBounce
Circle Circle
CubeGrid CubeGrid
FadingCircle FadingCircle
FoldingCube FoldingCube
RotatingCircle RotatingCircle
Heartbeat Heartbeat

Library used

About

基于Spinkit 的Progressbar Dialog 可选动画样式

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published