81 lines
2.8 KiB
Java
81 lines
2.8 KiB
Java
|
package butterknife;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.app.Dialog;
|
||
|
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 Map<Class<?>, Constructor<? extends Unbinder>> e = new LinkedHashMap();
|
||
|
|
||
|
private ButterKnife() {
|
||
|
throw new AssertionError("No instances.");
|
||
|
}
|
||
|
|
||
|
public static Unbinder Dg_(Activity activity) {
|
||
|
return c(activity, activity.getWindow().getDecorView());
|
||
|
}
|
||
|
|
||
|
public static Unbinder c(View view) {
|
||
|
return c(view, view);
|
||
|
}
|
||
|
|
||
|
public static Unbinder Dh_(Dialog dialog) {
|
||
|
return c(dialog, dialog.getWindow().getDecorView());
|
||
|
}
|
||
|
|
||
|
public static Unbinder c(Object obj, View view) {
|
||
|
Constructor<? extends Unbinder> c = c(obj.getClass());
|
||
|
if (c == null) {
|
||
|
return Unbinder.a;
|
||
|
}
|
||
|
try {
|
||
|
return c.newInstance(obj, view);
|
||
|
} catch (IllegalAccessException e2) {
|
||
|
throw new RuntimeException("Unable to invoke ".concat(String.valueOf(c)), e2);
|
||
|
} catch (InstantiationException e3) {
|
||
|
throw new RuntimeException("Unable to invoke ".concat(String.valueOf(c)), e3);
|
||
|
} catch (InvocationTargetException e4) {
|
||
|
Throwable cause = e4.getCause();
|
||
|
if (cause instanceof RuntimeException) {
|
||
|
throw ((RuntimeException) cause);
|
||
|
}
|
||
|
if (cause instanceof Error) {
|
||
|
throw ((Error) cause);
|
||
|
}
|
||
|
throw new RuntimeException("Unable to create binding instance.", cause);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static Constructor<? extends Unbinder> c(Class<?> cls) {
|
||
|
Constructor<? extends Unbinder> c;
|
||
|
Map<Class<?>, Constructor<? extends Unbinder>> map = e;
|
||
|
Constructor<? extends Unbinder> constructor = map.get(cls);
|
||
|
if (constructor != null || map.containsKey(cls)) {
|
||
|
return constructor;
|
||
|
}
|
||
|
String name = cls.getName();
|
||
|
if (name.startsWith("android.") || name.startsWith("java.") || name.startsWith("androidx.")) {
|
||
|
return null;
|
||
|
}
|
||
|
try {
|
||
|
ClassLoader classLoader = cls.getClassLoader();
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(name);
|
||
|
sb.append("_ViewBinding");
|
||
|
c = classLoader.loadClass(sb.toString()).getConstructor(cls, View.class);
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
c = c(cls.getSuperclass());
|
||
|
} catch (NoSuchMethodException e2) {
|
||
|
throw new RuntimeException("Unable to find binding constructor for ".concat(String.valueOf(name)), e2);
|
||
|
}
|
||
|
e.put(cls, c);
|
||
|
return c;
|
||
|
}
|
||
|
}
|