From 800c1d4795cd9f851ef495ef1a40bb27783d6cf0 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 4 Jun 2020 08:58:19 +0200 Subject: [PATCH] Simplification --- .../faircode/email/SwipeRefreshLayoutEx.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/SwipeRefreshLayoutEx.java b/app/src/main/java/eu/faircode/email/SwipeRefreshLayoutEx.java index 1126472a18..c5aaf5d63d 100644 --- a/app/src/main/java/eu/faircode/email/SwipeRefreshLayoutEx.java +++ b/app/src/main/java/eu/faircode/email/SwipeRefreshLayoutEx.java @@ -27,7 +27,6 @@ import androidx.annotation.Nullable; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { - private boolean muted = false; private boolean refreshing = false; private static final int DELAY_MUTE = 45 * 1000; // milliseconds @@ -46,7 +45,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { if (this.refreshing == refreshing) return; - Log.i("Refreshing=" + this.refreshing + "/" + refreshing + " muted=" + muted + " event=set"); + Log.i("Refreshing=" + this.refreshing + "/" + refreshing + " event=set"); this.refreshing = refreshing; @@ -54,14 +53,10 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { removeCallbacks(delayedMute); if (refreshing) { - if (!muted) { - super.setRefreshing(true); - postDelayed(delayedMute, DELAY_MUTE); - } - } else { - muted = false; + super.setRefreshing(refreshing); + postDelayed(delayedMute, DELAY_MUTE); + } else postDelayed(delayedDisable, DELAY_DISABLE); - } } @Override @@ -78,7 +73,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { public void resetRefreshing() { // Restart spinner after screen off, etc if (super.isRefreshing()) { - Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=reset"); + Log.i("Refreshing=" + refreshing + " event=reset"); super.setRefreshing(false); super.setRefreshing(true); } @@ -87,7 +82,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { private final Runnable delayedDisable = new Runnable() { @Override public void run() { - Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=disable"); + Log.i("Refreshing=" + refreshing + " event=disable"); if (!refreshing) SwipeRefreshLayoutEx.super.setRefreshing(refreshing); } @@ -96,11 +91,9 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { private final Runnable delayedMute = new Runnable() { @Override public void run() { - Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=mute"); - if (refreshing) { - muted = true; + Log.i("Refreshing=" + refreshing + " event=mute"); + if (refreshing) SwipeRefreshLayoutEx.super.setRefreshing(false); - } } }; }