Simplification

pull/180/head
M66B 5 years ago
parent c55c35a021
commit 800c1d4795

@ -27,7 +27,6 @@ import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class SwipeRefreshLayoutEx extends SwipeRefreshLayout { public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
private boolean muted = false;
private boolean refreshing = false; private boolean refreshing = false;
private static final int DELAY_MUTE = 45 * 1000; // milliseconds private static final int DELAY_MUTE = 45 * 1000; // milliseconds
@ -46,7 +45,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
if (this.refreshing == refreshing) if (this.refreshing == refreshing)
return; return;
Log.i("Refreshing=" + this.refreshing + "/" + refreshing + " muted=" + muted + " event=set"); Log.i("Refreshing=" + this.refreshing + "/" + refreshing + " event=set");
this.refreshing = refreshing; this.refreshing = refreshing;
@ -54,15 +53,11 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
removeCallbacks(delayedMute); removeCallbacks(delayedMute);
if (refreshing) { if (refreshing) {
if (!muted) { super.setRefreshing(refreshing);
super.setRefreshing(true);
postDelayed(delayedMute, DELAY_MUTE); postDelayed(delayedMute, DELAY_MUTE);
} } else
} else {
muted = false;
postDelayed(delayedDisable, DELAY_DISABLE); postDelayed(delayedDisable, DELAY_DISABLE);
} }
}
@Override @Override
public boolean isRefreshing() { public boolean isRefreshing() {
@ -78,7 +73,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
public void resetRefreshing() { public void resetRefreshing() {
// Restart spinner after screen off, etc // Restart spinner after screen off, etc
if (super.isRefreshing()) { if (super.isRefreshing()) {
Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=reset"); Log.i("Refreshing=" + refreshing + " event=reset");
super.setRefreshing(false); super.setRefreshing(false);
super.setRefreshing(true); super.setRefreshing(true);
} }
@ -87,7 +82,7 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
private final Runnable delayedDisable = new Runnable() { private final Runnable delayedDisable = new Runnable() {
@Override @Override
public void run() { public void run() {
Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=disable"); Log.i("Refreshing=" + refreshing + " event=disable");
if (!refreshing) if (!refreshing)
SwipeRefreshLayoutEx.super.setRefreshing(refreshing); SwipeRefreshLayoutEx.super.setRefreshing(refreshing);
} }
@ -96,11 +91,9 @@ public class SwipeRefreshLayoutEx extends SwipeRefreshLayout {
private final Runnable delayedMute = new Runnable() { private final Runnable delayedMute = new Runnable() {
@Override @Override
public void run() { public void run() {
Log.i("Refreshing=" + refreshing + " muted=" + muted + " event=mute"); Log.i("Refreshing=" + refreshing + " event=mute");
if (refreshing) { if (refreshing)
muted = true;
SwipeRefreshLayoutEx.super.setRefreshing(false); SwipeRefreshLayoutEx.super.setRefreshing(false);
} }
}
}; };
} }

Loading…
Cancel
Save