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 d {

    /* renamed from: a, reason: collision with root package name */
    private Set f3968a = new HashSet();

    /* renamed from: b, reason: collision with root package name */
    private List f3969b = new CopyOnWriteArrayList();

    /* renamed from: c, reason: collision with root package name */
    private List f3970c = new CopyOnWriteArrayList();

    private boolean f() {
        boolean z10 = false;
        for (String str : this.f3970c) {
            try {
                Class<?> cls = Class.forName(str);
                if (d.class.isAssignableFrom(cls)) {
                    e((d) cls.newInstance());
                    this.f3970c.remove(str);
                    z10 = true;
                }
            } catch (ClassNotFoundException unused) {
            } catch (IllegalAccessException e10) {
                Log.e("MergedDataBinderMapper", "unable to add feature mapper for " + str, e10);
            } catch (InstantiationException e11) {
                Log.e("MergedDataBinderMapper", "unable to add feature mapper for " + str, e11);
            }
        }
        return z10;
    }

    @Override // androidx.databinding.d
    public n b(e eVar, View view, int i10) {
        Iterator it = this.f3969b.iterator();
        while (it.hasNext()) {
            n b10 = ((d) it.next()).b(eVar, view, i10);
            if (b10 != null) {
                return b10;
            }
        }
        if (f()) {
            return b(eVar, view, i10);
        }
        return null;
    }

    @Override // androidx.databinding.d
    public n c(e eVar, View[] viewArr, int i10) {
        Iterator it = this.f3969b.iterator();
        while (it.hasNext()) {
            n c10 = ((d) it.next()).c(eVar, viewArr, i10);
            if (c10 != null) {
                return c10;
            }
        }
        if (f()) {
            return c(eVar, viewArr, i10);
        }
        return null;
    }

    @Override // androidx.databinding.d
    public int d(String str) {
        Iterator it = this.f3969b.iterator();
        while (it.hasNext()) {
            int d10 = ((d) it.next()).d(str);
            if (d10 != 0) {
                return d10;
            }
        }
        if (f()) {
            return d(str);
        }
        return 0;
    }

    public void e(d dVar) {
        if (this.f3968a.add(dVar.getClass())) {
            this.f3969b.add(dVar);
            Iterator it = dVar.a().iterator();
            while (it.hasNext()) {
                e((d) it.next());
            }
        }
    }
}
