mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-28 01:52:26 -06:00
125 lines
4.9 KiB
Java
125 lines
4.9 KiB
Java
package androidx.databinding;
|
|
|
|
import android.R;
|
|
import android.app.Activity;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DataBindingUtil {
|
|
private static DataBinderMapper sMapper = new DataBinderMapperImpl();
|
|
private static DataBindingComponent sDefaultComponent = null;
|
|
|
|
public static DataBindingComponent getDefaultComponent() {
|
|
return sDefaultComponent;
|
|
}
|
|
|
|
public static void setDefaultComponent(DataBindingComponent dataBindingComponent) {
|
|
sDefaultComponent = dataBindingComponent;
|
|
}
|
|
|
|
private DataBindingUtil() {
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T inflate(LayoutInflater layoutInflater, int i, ViewGroup viewGroup, boolean z) {
|
|
return (T) inflate(layoutInflater, i, viewGroup, z, sDefaultComponent);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T inflate(LayoutInflater layoutInflater, int i, ViewGroup viewGroup, boolean z, DataBindingComponent dataBindingComponent) {
|
|
boolean z2 = viewGroup != null && z;
|
|
int childCount = z2 ? viewGroup.getChildCount() : 0;
|
|
View inflate = layoutInflater.inflate(i, viewGroup, z);
|
|
if (z2) {
|
|
return (T) bindToAddedViews(dataBindingComponent, viewGroup, childCount, i);
|
|
}
|
|
return (T) bind(dataBindingComponent, inflate, i);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T bind(View view) {
|
|
return (T) bind(view, sDefaultComponent);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T bind(View view, DataBindingComponent dataBindingComponent) {
|
|
T t = (T) getBinding(view);
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
Object tag = view.getTag();
|
|
if (!(tag instanceof String)) {
|
|
throw new IllegalArgumentException("View is not a binding layout");
|
|
}
|
|
int layoutId = sMapper.getLayoutId((String) tag);
|
|
if (layoutId == 0) {
|
|
throw new IllegalArgumentException("View is not a binding layout. Tag: " + tag);
|
|
}
|
|
return (T) sMapper.getDataBinder(dataBindingComponent, view, layoutId);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static <T extends ViewDataBinding> T bind(DataBindingComponent dataBindingComponent, View[] viewArr, int i) {
|
|
return (T) sMapper.getDataBinder(dataBindingComponent, viewArr, i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static <T extends ViewDataBinding> T bind(DataBindingComponent dataBindingComponent, View view, int i) {
|
|
return (T) sMapper.getDataBinder(dataBindingComponent, view, i);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T findBinding(View view) {
|
|
while (view != null) {
|
|
T t = (T) ViewDataBinding.getBinding(view);
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
Object tag = view.getTag();
|
|
if (tag instanceof String) {
|
|
String str = (String) tag;
|
|
if (str.startsWith("layout") && str.endsWith("_0")) {
|
|
char charAt = str.charAt(6);
|
|
int indexOf = str.indexOf(47, 7);
|
|
if (charAt == '/') {
|
|
if (indexOf == -1) {
|
|
return null;
|
|
}
|
|
} else if (charAt == '-' && indexOf != -1 && str.indexOf(47, indexOf + 1) == -1) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
Object parent = view.getParent();
|
|
view = parent instanceof View ? (View) parent : null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T getBinding(View view) {
|
|
return (T) ViewDataBinding.getBinding(view);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T setContentView(Activity activity, int i) {
|
|
return (T) setContentView(activity, i, sDefaultComponent);
|
|
}
|
|
|
|
public static <T extends ViewDataBinding> T setContentView(Activity activity, int i, DataBindingComponent dataBindingComponent) {
|
|
activity.setContentView(i);
|
|
return (T) bindToAddedViews(dataBindingComponent, (ViewGroup) activity.getWindow().getDecorView().findViewById(R.id.content), 0, i);
|
|
}
|
|
|
|
public static String convertBrIdToString(int i) {
|
|
return sMapper.convertBrIdToString(i);
|
|
}
|
|
|
|
private static <T extends ViewDataBinding> T bindToAddedViews(DataBindingComponent dataBindingComponent, ViewGroup viewGroup, int i, int i2) {
|
|
int childCount = viewGroup.getChildCount();
|
|
int i3 = childCount - i;
|
|
if (i3 == 1) {
|
|
return (T) bind(dataBindingComponent, viewGroup.getChildAt(childCount - 1), i2);
|
|
}
|
|
View[] viewArr = new View[i3];
|
|
for (int i4 = 0; i4 < i3; i4++) {
|
|
viewArr[i4] = viewGroup.getChildAt(i4 + i);
|
|
}
|
|
return (T) bind(dataBindingComponent, viewArr, i2);
|
|
}
|
|
}
|