Refactoring

pull/214/head
M66B 7 months ago
parent 7002cf44cf
commit 56a63dc66e

@ -123,7 +123,14 @@ public class FixedConstraintLayout extends ConstraintLayout {
}
}
private final Map<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -63,7 +63,14 @@ public class FixedCoordinatorLayout extends CoordinatorLayout {
}
}
private final Map<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -76,7 +76,14 @@ public class FixedFrameLayout extends FrameLayout {
}
}
private final Map<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -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<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -211,7 +211,14 @@ public class FixedRecyclerView extends RecyclerView {
}
}
private final Map<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -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<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

@ -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<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
private Map<Runnable, Runnable> mapRunnable = null;
@NonNull
private Map<Runnable, Runnable> 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

Loading…
Cancel
Save