- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
package com.vungle.ads.internal.util;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import java.util.concurrent.Executor;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class ThreadUtil {
|
|
public static final ThreadUtil INSTANCE = new ThreadUtil();
|
|
private static final Handler UI_HANDLER = new Handler(Looper.getMainLooper());
|
|
private static Executor uiExecutor;
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getUiExecutor$vungle_ads_release$annotations() {
|
|
}
|
|
|
|
public final Executor getUiExecutor$vungle_ads_release() {
|
|
return uiExecutor;
|
|
}
|
|
|
|
public final void setUiExecutor$vungle_ads_release(Executor executor) {
|
|
uiExecutor = executor;
|
|
}
|
|
|
|
private ThreadUtil() {
|
|
}
|
|
|
|
public final boolean isMainThread() {
|
|
Looper mainLooper = Looper.getMainLooper();
|
|
if (mainLooper == null) {
|
|
return false;
|
|
}
|
|
return mainLooper.isCurrentThread();
|
|
}
|
|
|
|
public final void runOnUiThread(Runnable runnable) {
|
|
Intrinsics.checkNotNullParameter(runnable, "runnable");
|
|
if (isMainThread()) {
|
|
runnable.run();
|
|
return;
|
|
}
|
|
Executor executor = uiExecutor;
|
|
if (executor == null) {
|
|
UI_HANDLER.post(runnable);
|
|
} else if (executor != null) {
|
|
executor.execute(runnable);
|
|
}
|
|
}
|
|
}
|