From 4635a7bae0cbd79eecdca767d46ece7e7b8d6603 Mon Sep 17 00:00:00 2001 From: Lethe <37437842+0xlethe@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:57:15 +0900 Subject: [PATCH] chore: create Utils with MainExecutor, MainHandler --- android/src/main/AndroidManifest.xml | 2 +- .../java/com/captureprotection/Utils.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 android/src/main/java/com/captureprotection/Utils.java diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 7f805e6..66d622f 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -7,5 +7,5 @@ - + diff --git a/android/src/main/java/com/captureprotection/Utils.java b/android/src/main/java/com/captureprotection/Utils.java new file mode 100644 index 0000000..cd07f2b --- /dev/null +++ b/android/src/main/java/com/captureprotection/Utils.java @@ -0,0 +1,28 @@ +package com.captureprotection; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import androidx.annotation.NonNull; +import java.util.concurrent.Executor; + +public class Utils { + public static final class MainExecutor implements Executor { + static final Executor INSTANCE = new MainExecutor(); + private final Handler handler = new Handler(Looper.getMainLooper()); + + @Override + public void execute(Runnable r) { + handler.post(r); + } + } + + public static final class MainHandler { + static final Handler INSTANCE = new Handler(Looper.getMainLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + return false; + } + }); + } +}