Fixed views

This commit is contained in:
M66B
2024-01-21 13:16:01 +01:00
parent b3b2e983aa
commit f23add9d5a
106 changed files with 433 additions and 202 deletions

View File

@@ -24,6 +24,9 @@ import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;
import java.util.Map;
import java.util.WeakHashMap;
public class FixedRelativeLayout extends RelativeLayout {
public FixedRelativeLayout(Context context) {
super(context);
@@ -50,4 +53,39 @@ public class FixedRelativeLayout extends RelativeLayout {
return false;
}
}
private final Map<Runnable, Runnable> mapRunnable = new WeakHashMap<>();
@Override
public boolean post(Runnable action) {
Runnable wrapped = new RunnableEx("post") {
@Override
protected void delegate() {
action.run();
}
};
mapRunnable.put(action, wrapped);
return super.post(wrapped);
}
@Override
public boolean postDelayed(Runnable action, long delayMillis) {
Runnable wrapped = new RunnableEx("postDelayed") {
@Override
protected void delegate() {
action.run();
}
};
mapRunnable.put(action, wrapped);
return super.postDelayed(wrapped, delayMillis);
}
@Override
public boolean removeCallbacks(Runnable action) {
Runnable wrapped = mapRunnable.get(action);
if (wrapped == null)
return super.removeCallbacks(action);
else
return super.removeCallbacks(wrapped);
}
}