From deff5c4a7560f45ef3e56c96770d16b79e9ff50f Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 11 Feb 2019 11:06:53 +0000 Subject: [PATCH] Fixed occasional invalid spinner --- .../eu/faircode/email/ContentLoadingProgressBar.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ContentLoadingProgressBar.java b/app/src/main/java/eu/faircode/email/ContentLoadingProgressBar.java index fdefcf928d..bd6cfc0ae2 100644 --- a/app/src/main/java/eu/faircode/email/ContentLoadingProgressBar.java +++ b/app/src/main/java/eu/faircode/email/ContentLoadingProgressBar.java @@ -27,6 +27,10 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; public class ContentLoadingProgressBar extends ProgressBar { + private int visibility; + + private static final int VISIBILITY_DELAY = 500; // milliseconds + public ContentLoadingProgressBar(@NonNull Context context) { this(context, null); } @@ -37,6 +41,7 @@ public class ContentLoadingProgressBar extends ProgressBar { @Override public void setVisibility(int visibility) { + this.visibility = visibility; if (false && BuildConfig.DEBUG) { super.setVisibility(visibility); return; @@ -44,7 +49,7 @@ public class ContentLoadingProgressBar extends ProgressBar { removeCallbacks(delayedShow); if (visibility == VISIBLE) { super.setVisibility(INVISIBLE); - postDelayed(delayedShow, 500); + postDelayed(delayedShow, VISIBILITY_DELAY); } else super.setVisibility(visibility); } @@ -52,7 +57,8 @@ public class ContentLoadingProgressBar extends ProgressBar { private final Runnable delayedShow = new Runnable() { @Override public void run() { - ContentLoadingProgressBar.super.setVisibility(VISIBLE); + if (visibility == VISIBLE) + ContentLoadingProgressBar.super.setVisibility(VISIBLE); } }; }