45 lines
1.6 KiB
Java
45 lines
1.6 KiB
Java
package androidx.core.view;
|
|
|
|
import android.os.Build;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import java.lang.reflect.Field;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class LayoutInflaterCompat {
|
|
private static Field a;
|
|
private static boolean b;
|
|
|
|
private static void a(LayoutInflater layoutInflater, LayoutInflater.Factory2 factory2) {
|
|
if (!b) {
|
|
try {
|
|
a = LayoutInflater.class.getDeclaredField("mFactory2");
|
|
a.setAccessible(true);
|
|
} catch (NoSuchFieldException e) {
|
|
Log.e("LayoutInflaterCompatHC", "forceSetFactory2 Could not find field 'mFactory2' on class " + LayoutInflater.class.getName() + "; inflation may have unexpected results.", e);
|
|
}
|
|
b = true;
|
|
}
|
|
Field field = a;
|
|
if (field != null) {
|
|
try {
|
|
field.set(layoutInflater, factory2);
|
|
} catch (IllegalAccessException e2) {
|
|
Log.e("LayoutInflaterCompatHC", "forceSetFactory2 could not set the Factory2 on LayoutInflater " + layoutInflater + "; inflation may have unexpected results.", e2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void b(LayoutInflater layoutInflater, LayoutInflater.Factory2 factory2) {
|
|
layoutInflater.setFactory2(factory2);
|
|
if (Build.VERSION.SDK_INT < 21) {
|
|
LayoutInflater.Factory factory = layoutInflater.getFactory();
|
|
if (factory instanceof LayoutInflater.Factory2) {
|
|
a(layoutInflater, (LayoutInflater.Factory2) factory);
|
|
} else {
|
|
a(layoutInflater, factory2);
|
|
}
|
|
}
|
|
}
|
|
}
|