diff --git a/app/src/main/java/eu/faircode/email/FixedConstraintLayout.java b/app/src/main/java/eu/faircode/email/FixedConstraintLayout.java index 6ba80086da..2eb0faee27 100644 --- a/app/src/main/java/eu/faircode/email/FixedConstraintLayout.java +++ b/app/src/main/java/eu/faircode/email/FixedConstraintLayout.java @@ -123,7 +123,14 @@ public class FixedConstraintLayout extends ConstraintLayout { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -133,7 +140,7 @@ public class FixedConstraintLayout extends ConstraintLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -145,13 +152,13 @@ public class FixedConstraintLayout extends ConstraintLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedCoordinatorLayout.java b/app/src/main/java/eu/faircode/email/FixedCoordinatorLayout.java index d0a659530d..f03249c462 100644 --- a/app/src/main/java/eu/faircode/email/FixedCoordinatorLayout.java +++ b/app/src/main/java/eu/faircode/email/FixedCoordinatorLayout.java @@ -63,7 +63,14 @@ public class FixedCoordinatorLayout extends CoordinatorLayout { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -73,7 +80,7 @@ public class FixedCoordinatorLayout extends CoordinatorLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -85,13 +92,13 @@ public class FixedCoordinatorLayout extends CoordinatorLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedFrameLayout.java b/app/src/main/java/eu/faircode/email/FixedFrameLayout.java index b2d6ec0ebe..8204b9e1d9 100644 --- a/app/src/main/java/eu/faircode/email/FixedFrameLayout.java +++ b/app/src/main/java/eu/faircode/email/FixedFrameLayout.java @@ -76,7 +76,14 @@ public class FixedFrameLayout extends FrameLayout { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -86,7 +93,7 @@ public class FixedFrameLayout extends FrameLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -98,13 +105,13 @@ public class FixedFrameLayout extends FrameLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedLinearLayout.java b/app/src/main/java/eu/faircode/email/FixedLinearLayout.java index a9905aa37b..ce55dc1181 100644 --- a/app/src/main/java/eu/faircode/email/FixedLinearLayout.java +++ b/app/src/main/java/eu/faircode/email/FixedLinearLayout.java @@ -24,6 +24,7 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.LinearLayout; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Map; @@ -56,7 +57,14 @@ public class FixedLinearLayout extends LinearLayout { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -66,7 +74,7 @@ public class FixedLinearLayout extends LinearLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -78,13 +86,13 @@ public class FixedLinearLayout extends LinearLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedRecyclerView.java b/app/src/main/java/eu/faircode/email/FixedRecyclerView.java index fa3cfc5a0f..b1f403b5b3 100644 --- a/app/src/main/java/eu/faircode/email/FixedRecyclerView.java +++ b/app/src/main/java/eu/faircode/email/FixedRecyclerView.java @@ -211,7 +211,14 @@ public class FixedRecyclerView extends RecyclerView { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -221,7 +228,7 @@ public class FixedRecyclerView extends RecyclerView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -233,7 +240,7 @@ public class FixedRecyclerView extends RecyclerView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @@ -245,7 +252,7 @@ public class FixedRecyclerView extends RecyclerView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); super.postOnAnimation(wrapped); } @@ -257,13 +264,13 @@ public class FixedRecyclerView extends RecyclerView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); super.postOnAnimationDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedRelativeLayout.java b/app/src/main/java/eu/faircode/email/FixedRelativeLayout.java index 066d8c6828..d6a94cd90d 100644 --- a/app/src/main/java/eu/faircode/email/FixedRelativeLayout.java +++ b/app/src/main/java/eu/faircode/email/FixedRelativeLayout.java @@ -24,6 +24,8 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.RelativeLayout; +import androidx.annotation.NonNull; + import java.util.Map; import java.util.WeakHashMap; @@ -54,7 +56,14 @@ public class FixedRelativeLayout extends RelativeLayout { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -64,7 +73,7 @@ public class FixedRelativeLayout extends RelativeLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -76,13 +85,13 @@ public class FixedRelativeLayout extends RelativeLayout { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else diff --git a/app/src/main/java/eu/faircode/email/FixedScrollView.java b/app/src/main/java/eu/faircode/email/FixedScrollView.java index 4e55d67c2d..cae89125ea 100644 --- a/app/src/main/java/eu/faircode/email/FixedScrollView.java +++ b/app/src/main/java/eu/faircode/email/FixedScrollView.java @@ -5,6 +5,8 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.ScrollView; +import androidx.annotation.NonNull; + import java.util.Map; import java.util.WeakHashMap; @@ -133,7 +135,14 @@ public class FixedScrollView extends ScrollView { } } - private final Map mapRunnable = new WeakHashMap<>(); + private Map mapRunnable = null; + + @NonNull + private Map getMapRunnable() { + if (mapRunnable == null) + mapRunnable = new WeakHashMap<>(); + return mapRunnable; + } @Override public boolean post(Runnable action) { @@ -143,7 +152,7 @@ public class FixedScrollView extends ScrollView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.post(wrapped); } @@ -155,13 +164,13 @@ public class FixedScrollView extends ScrollView { action.run(); } }; - mapRunnable.put(action, wrapped); + getMapRunnable().put(action, wrapped); return super.postDelayed(wrapped, delayMillis); } @Override public boolean removeCallbacks(Runnable action) { - Runnable wrapped = mapRunnable.get(action); + Runnable wrapped = getMapRunnable().get(action); if (wrapped == null) return super.removeCallbacks(action); else