86 lines
3.2 KiB
Java
86 lines
3.2 KiB
Java
package butterknife;
|
|
|
|
import android.app.Activity;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class ButterKnife {
|
|
private static boolean a = false;
|
|
static final Map<Class<?>, Constructor<? extends Unbinder>> b = new LinkedHashMap();
|
|
|
|
private ButterKnife() {
|
|
throw new AssertionError("No instances.");
|
|
}
|
|
|
|
public static Unbinder a(Activity activity) {
|
|
return a(activity, activity.getWindow().getDecorView());
|
|
}
|
|
|
|
public static Unbinder a(Object obj, View view) {
|
|
Class<?> cls = obj.getClass();
|
|
if (a) {
|
|
Log.d("ButterKnife", "Looking up binding for " + cls.getName());
|
|
}
|
|
Constructor<? extends Unbinder> a2 = a(cls);
|
|
if (a2 == null) {
|
|
return Unbinder.a;
|
|
}
|
|
try {
|
|
return a2.newInstance(obj, view);
|
|
} catch (IllegalAccessException e) {
|
|
throw new RuntimeException("Unable to invoke " + a2, e);
|
|
} catch (InstantiationException e2) {
|
|
throw new RuntimeException("Unable to invoke " + a2, e2);
|
|
} catch (InvocationTargetException e3) {
|
|
Throwable cause = e3.getCause();
|
|
if (!(cause instanceof RuntimeException)) {
|
|
if (cause instanceof Error) {
|
|
throw ((Error) cause);
|
|
}
|
|
throw new RuntimeException("Unable to create binding instance.", cause);
|
|
}
|
|
throw ((RuntimeException) cause);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private static Constructor<? extends Unbinder> a(Class<?> cls) {
|
|
Constructor<? extends Unbinder> a2;
|
|
Constructor<? extends Unbinder> constructor = b.get(cls);
|
|
if (constructor == null && !b.containsKey(cls)) {
|
|
String name = cls.getName();
|
|
if (!name.startsWith("android.") && !name.startsWith("java.") && !name.startsWith("androidx.")) {
|
|
try {
|
|
a2 = cls.getClassLoader().loadClass(name + "_ViewBinding").getConstructor(cls, View.class);
|
|
if (a) {
|
|
Log.d("ButterKnife", "HIT: Loaded binding class and constructor.");
|
|
}
|
|
} catch (ClassNotFoundException unused) {
|
|
if (a) {
|
|
Log.d("ButterKnife", "Not found. Trying superclass " + cls.getSuperclass().getName());
|
|
}
|
|
a2 = a(cls.getSuperclass());
|
|
} catch (NoSuchMethodException e) {
|
|
throw new RuntimeException("Unable to find binding constructor for " + name, e);
|
|
}
|
|
b.put(cls, a2);
|
|
return a2;
|
|
}
|
|
if (!a) {
|
|
return null;
|
|
}
|
|
Log.d("ButterKnife", "MISS: Reached framework class. Abandoning search.");
|
|
return null;
|
|
}
|
|
if (a) {
|
|
Log.d("ButterKnife", "HIT: Cached in binding map.");
|
|
}
|
|
return constructor;
|
|
}
|
|
}
|