SmoothProgressBar
SmoothProgressBar copied to clipboard
Doesn't stop if the delay between progressiveStart() and progressiveStop() is very short
I don't have time to dig it, but in mUpdater
there's a condition which is never satisfied and stop()
isn't called:
if (isFinishing()) {
mFinishingOffset += (OFFSET_PER_FRAME * mProgressiveStopSpeed);
mCurrentOffset += (OFFSET_PER_FRAME * mProgressiveStopSpeed);
if (mFinishingOffset >= 1f) {
stop();
}
...
Found something. Before to reach stop()
in the next few frames ProgressBar.drawTrack()
calls SmoothProgressDrawable.start()
which does:
if (mProgressiveStartActivated) {
resetProgressiveStart(0);
}
...
This actually restarts the progress before it has chance to reach stop()
. I guess you should check for mIsFinishing
in the if
above.
I workaround it by running progressiveStop()
in Handler.postDelayed()
with delay above 500 ms, that is 30 frames. That's the time needed for OFFSET_PER_FRAME * mProgressiveStopSpeed
to reach 1.0.
Hey, thanks for the detailed issue, I'll have a look
To me it was fixed by doing this:
progress.setSmoothProgressDrawableCallbacks(object : SmoothProgressDrawable.Callbacks {
override fun onStop() {
progress.visibility = GONE
}
override fun onStart() {
progress.visibility = VISIBLE
}
})
If you are able to hide it, this might be useful