SmoothProgressBar icon indicating copy to clipboard operation
SmoothProgressBar copied to clipboard

Doesn't stop if the delay between progressiveStart() and progressiveStop() is very short

Open sevar83 opened this issue 9 years ago • 3 comments

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();
        }
   ...

sevar83 avatar Nov 17 '15 22:11 sevar83

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.

sevar83 avatar Nov 17 '15 22:11 sevar83

Hey, thanks for the detailed issue, I'll have a look

castorflex avatar Nov 18 '15 09:11 castorflex

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

alxrm avatar Jan 05 '19 20:01 alxrm