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 { @@ -1689,17 +1689,27 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override
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);
animator.setDuration(200);
animator.setInterpolator(new DecelerateInterpolator());
animator.start();
if (n == 100) {
mProgress.setVisibility(View.INVISIBLE);
setIsFinishedLoading();
if (n >= 100) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mProgress.setVisibility(View.INVISIBLE);
setIsFinishedLoading();
}
}, 200);
} else {
mProgress.setVisibility(View.VISIBLE);
setIsLoading();
}
}

Loading…
Cancel
Save