mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 10:27:17 +01:00
36 lines
1.8 KiB
Java
36 lines
1.8 KiB
Java
package com.facebook.react.views.common;
|
|
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import androidx.exifinterface.media.ExifInterface;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.JvmStatic;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bÀ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J/\u0010\u0004\u001a\u0004\u0018\u0001H\u0005\"\u0004\b\u0000\u0010\u00052\b\u0010\u0006\u001a\u0004\u0018\u00010\u00072\u000e\u0010\b\u001a\n\u0012\u0006\b\u0001\u0012\u0002H\u00050\tH\u0007¢\u0006\u0002\u0010\n¨\u0006\u000b"}, d2 = {"Lcom/facebook/react/views/common/ContextUtils;", "", "<init>", "()V", "findContextOfType", ExifInterface.GPS_DIRECTION_TRUE, "context", "Landroid/content/Context;", "clazz", "Ljava/lang/Class;", "(Landroid/content/Context;Ljava/lang/Class;)Ljava/lang/Object;", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
|
/* loaded from: classes7.dex */
|
|
public final class ContextUtils {
|
|
|
|
@NotNull
|
|
public static final ContextUtils INSTANCE = new ContextUtils();
|
|
|
|
private ContextUtils() {
|
|
}
|
|
|
|
@JvmStatic
|
|
@Nullable
|
|
public static final <T> T findContextOfType(@Nullable Context context, @NotNull Class<? extends T> clazz) {
|
|
Context baseContext;
|
|
clazz.getClass();
|
|
Object obj = context;
|
|
while (!clazz.isInstance(obj)) {
|
|
if (!(obj instanceof ContextWrapper) || obj == (baseContext = obj.getBaseContext())) {
|
|
return null;
|
|
}
|
|
obj = (T) baseContext;
|
|
}
|
|
return (T) obj;
|
|
}
|
|
}
|