I am using a ProgressBar in my application which I update in onProgressUpdate of an AsyncTask
. So far so good.
What I want to do is to animate the prog
I just wanted to add an extra value for those who want to use Data Binding with a progress bar animation.
First create the following binding adapter:
@BindingAdapter("animatedProgress")
fun setCustomProgressBar(progressBar: ProgressBar, progress: Int) {
ObjectAnimator.ofInt(progressBar, "progress", progressBar.progress, progress).apply {
duration = 500
interpolator = DecelerateInterpolator()
}.start()
}
And then use it in the layout which contains the ViewModel that reports the status updates:
The ViewModel itself will report the status with the following LiveData
:
private val _progress = MutableLiveData(null)
val progress: LiveData
get() = _