Rabbit-R1/android (non root)/java/sources/androidx/databinding/MergedDataBinderMapper.java
2024-05-21 17:08:36 -04:00

112 lines
4 KiB
Java

package androidx.databinding;
import android.util.Log;
import android.view.View;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
/* loaded from: classes.dex */
public class MergedDataBinderMapper extends DataBinderMapper {
private static final String TAG = "MergedDataBinderMapper";
private Set<Class<? extends DataBinderMapper>> mExistingMappers = new HashSet();
private List<DataBinderMapper> mMappers = new CopyOnWriteArrayList();
private List<String> mFeatureBindingMappers = new CopyOnWriteArrayList();
/* JADX WARN: Multi-variable type inference failed */
public void addMapper(DataBinderMapper dataBinderMapper) {
if (this.mExistingMappers.add(dataBinderMapper.getClass())) {
this.mMappers.add(dataBinderMapper);
Iterator<DataBinderMapper> it = dataBinderMapper.collectDependencies().iterator();
while (it.hasNext()) {
addMapper(it.next());
}
}
}
protected void addMapper(String str) {
this.mFeatureBindingMappers.add(str + ".DataBinderMapperImpl");
}
@Override // androidx.databinding.DataBinderMapper
public ViewDataBinding getDataBinder(DataBindingComponent dataBindingComponent, View view, int i) {
Iterator<DataBinderMapper> it = this.mMappers.iterator();
while (it.hasNext()) {
ViewDataBinding dataBinder = it.next().getDataBinder(dataBindingComponent, view, i);
if (dataBinder != null) {
return dataBinder;
}
}
if (loadFeatures()) {
return getDataBinder(dataBindingComponent, view, i);
}
return null;
}
@Override // androidx.databinding.DataBinderMapper
public ViewDataBinding getDataBinder(DataBindingComponent dataBindingComponent, View[] viewArr, int i) {
Iterator<DataBinderMapper> it = this.mMappers.iterator();
while (it.hasNext()) {
ViewDataBinding dataBinder = it.next().getDataBinder(dataBindingComponent, viewArr, i);
if (dataBinder != null) {
return dataBinder;
}
}
if (loadFeatures()) {
return getDataBinder(dataBindingComponent, viewArr, i);
}
return null;
}
@Override // androidx.databinding.DataBinderMapper
public int getLayoutId(String str) {
Iterator<DataBinderMapper> it = this.mMappers.iterator();
while (it.hasNext()) {
int layoutId = it.next().getLayoutId(str);
if (layoutId != 0) {
return layoutId;
}
}
if (loadFeatures()) {
return getLayoutId(str);
}
return 0;
}
@Override // androidx.databinding.DataBinderMapper
public String convertBrIdToString(int i) {
Iterator<DataBinderMapper> it = this.mMappers.iterator();
while (it.hasNext()) {
String convertBrIdToString = it.next().convertBrIdToString(i);
if (convertBrIdToString != null) {
return convertBrIdToString;
}
}
if (loadFeatures()) {
return convertBrIdToString(i);
}
return null;
}
private boolean loadFeatures() {
boolean z = false;
for (String str : this.mFeatureBindingMappers) {
try {
Class<?> cls = Class.forName(str);
if (DataBinderMapper.class.isAssignableFrom(cls)) {
addMapper((DataBinderMapper) cls.newInstance());
this.mFeatureBindingMappers.remove(str);
z = true;
}
} catch (ClassNotFoundException unused) {
} catch (IllegalAccessException e) {
Log.e(TAG, "unable to add feature mapper for " + str, e);
} catch (InstantiationException e2) {
Log.e(TAG, "unable to add feature mapper for " + str, e2);
}
}
return z;
}
}