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

@@ -26,6 +26,9 @@ import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import java.util.Map;
import java.util.WeakHashMap;
public class FixedLinearLayout extends LinearLayout {
public FixedLinearLayout(Context context) {
super(context);
@@ -52,4 +55,39 @@ public class FixedLinearLayout extends LinearLayout {
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);
}
}