Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java

Issue 2319213004: [Download Home] Deal with the infinite spinny (Closed)
Patch Set: Nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java
index 17a339123feba1e5ae2204844a22a9d6c4ce0fab..2da140e6d0e0447a94a4a2901dfba9b43ea493b9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/LoadingView.java
@@ -26,12 +26,20 @@ public class LoadingView extends ProgressBar {
private final Runnable mDelayedShow = new Runnable() {
@Override
public void run() {
+ if (!mShouldShow) return;
mStartTime = SystemClock.elapsedRealtime();
setVisibility(View.VISIBLE);
setAlpha(1.0f);
}
};
+ /**
+ * Tracks whether the View should be displayed when {@link #mDelayedShow} is run. Android
+ * doesn't always cancel a Runnable when requested, meaning that the View could be hidden before
+ * it even has a chance to be shown.
+ */
+ private boolean mShouldShow;
+
// Material loading design spec requires us to show progress spinner at least 500ms, so we need
// this delayed runnable to implement that.
private final Runnable mDelayedHide = new Runnable() {
@@ -67,6 +75,7 @@ public class LoadingView extends ProgressBar {
public void showLoadingUI() {
removeCallbacks(mDelayedShow);
removeCallbacks(mDelayedHide);
+ mShouldShow = true;
setVisibility(GONE);
postDelayed(mDelayedShow, LOADING_ANIMATION_DELAY_MS);
@@ -79,6 +88,7 @@ public class LoadingView extends ProgressBar {
public void hideLoadingUI() {
removeCallbacks(mDelayedShow);
removeCallbacks(mDelayedHide);
+ mShouldShow = false;
if (getVisibility() == VISIBLE) {
postDelayed(mDelayedHide, Math.max(0,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698