Browse Source

Smoothed ProgressBar animation

master
Anthony Restaino 10 years ago
parent
commit
62430ce72e
  1. 28
      src/acr/browser/lightning/BrowserActivity.java

28
src/acr/browser/lightning/BrowserActivity.java

@ -1689,17 +1689,27 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void updateProgress(int n) { public void updateProgress(int n) {
if (!mProgress.isShown()) {
mProgress.setVisibility(View.VISIBLE); if (n > mProgress.getProgress()) {
ObjectAnimator animator = ObjectAnimator.ofInt(mProgress, "progress", n);
animator.setDuration(200);
animator.setInterpolator(new DecelerateInterpolator());
animator.start();
} else {
mProgress.setProgress(n);
} }
ObjectAnimator animator = ObjectAnimator.ofInt(mProgress, "progress", n); if (n >= 100) {
animator.setDuration(200); Handler handler = new Handler();
animator.setInterpolator(new DecelerateInterpolator()); handler.postDelayed(new Runnable() {
animator.start(); @Override
if (n == 100) { public void run() {
mProgress.setVisibility(View.INVISIBLE); mProgress.setVisibility(View.INVISIBLE);
setIsFinishedLoading(); setIsFinishedLoading();
}
}, 200);
} else { } else {
mProgress.setVisibility(View.VISIBLE);
setIsLoading(); setIsLoading();
} }
} }

Loading…
Cancel
Save