package androidx.databinding;

import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.Choreographer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.b;
import androidx.databinding.h;
import androidx.databinding.i;
import androidx.databinding.j;
import androidx.lifecycle.a0;
import androidx.lifecycle.g0;
import androidx.lifecycle.h0;
import androidx.lifecycle.n;
import androidx.lifecycle.t;
import androidx.lifecycle.u;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

/* loaded from: classes.dex */
public abstract class n extends androidx.databinding.a {

    /* renamed from: r, reason: collision with root package name */
    private static final int f3982r = 8;

    /* renamed from: b, reason: collision with root package name */
    private final Runnable f3991b;

    /* renamed from: c, reason: collision with root package name */
    private boolean f3992c;

    /* renamed from: d, reason: collision with root package name */
    private boolean f3993d;

    /* renamed from: e, reason: collision with root package name */
    private o[] f3994e;

    /* renamed from: f, reason: collision with root package name */
    private final View f3995f;

    /* renamed from: g, reason: collision with root package name */
    private androidx.databinding.b f3996g;

    /* renamed from: h, reason: collision with root package name */
    private boolean f3997h;

    /* renamed from: i, reason: collision with root package name */
    private Choreographer f3998i;

    /* renamed from: j, reason: collision with root package name */
    private final Choreographer.FrameCallback f3999j;

    /* renamed from: k, reason: collision with root package name */
    private Handler f4000k;

    /* renamed from: l, reason: collision with root package name */
    private n f4001l;

    /* renamed from: m, reason: collision with root package name */
    private u f4002m;

    /* renamed from: n, reason: collision with root package name */
    private k f4003n;

    /* renamed from: o, reason: collision with root package name */
    private boolean f4004o;

    /* renamed from: p, reason: collision with root package name */
    protected boolean f4005p;

    /* renamed from: q, reason: collision with root package name */
    static int f3981q = Build.VERSION.SDK_INT;

    /* renamed from: s, reason: collision with root package name */
    private static final boolean f3983s = true;

    /* renamed from: t, reason: collision with root package name */
    private static final androidx.databinding.c f3984t = new a();

    /* renamed from: u, reason: collision with root package name */
    private static final androidx.databinding.c f3985u = new b();

    /* renamed from: v, reason: collision with root package name */
    private static final androidx.databinding.c f3986v = new c();

    /* renamed from: w, reason: collision with root package name */
    private static final androidx.databinding.c f3987w = new d();

    /* renamed from: x, reason: collision with root package name */
    private static final b.a f3988x = new e();

    /* renamed from: y, reason: collision with root package name */
    private static final ReferenceQueue f3989y = new ReferenceQueue();

    /* renamed from: z, reason: collision with root package name */
    private static final View.OnAttachStateChangeListener f3990z = new f();

    /* loaded from: classes.dex */
    class a implements androidx.databinding.c {
        a() {
        }

        @Override // androidx.databinding.c
        public o a(n nVar, int i10, ReferenceQueue referenceQueue) {
            return new C0105n(nVar, i10, referenceQueue).f();
        }
    }

    /* loaded from: classes.dex */
    class b implements androidx.databinding.c {
        b() {
        }

        @Override // androidx.databinding.c
        public o a(n nVar, int i10, ReferenceQueue referenceQueue) {
            return new l(nVar, i10, referenceQueue).e();
        }
    }

    /* loaded from: classes.dex */
    class c implements androidx.databinding.c {
        c() {
        }

        @Override // androidx.databinding.c
        public o a(n nVar, int i10, ReferenceQueue referenceQueue) {
            return new m(nVar, i10, referenceQueue).e();
        }
    }

    /* loaded from: classes.dex */
    class d implements androidx.databinding.c {
        d() {
        }

        @Override // androidx.databinding.c
        public o a(n nVar, int i10, ReferenceQueue referenceQueue) {
            return new j(nVar, i10, referenceQueue).g();
        }
    }

    /* loaded from: classes.dex */
    class e extends b.a {
        e() {
        }

        @Override // androidx.databinding.b.a
        public /* bridge */ /* synthetic */ void a(Object obj, Object obj2, int i10, Object obj3) {
            android.support.v4.media.session.b.a(obj);
            b(null, (n) obj2, i10, (Void) obj3);
        }

        public void b(androidx.databinding.l lVar, n nVar, int i10, Void r42) {
            if (i10 == 1) {
                throw null;
            }
            if (i10 == 2) {
                throw null;
            }
            if (i10 == 3) {
                throw null;
            }
        }
    }

    /* loaded from: classes.dex */
    class f implements View.OnAttachStateChangeListener {
        f() {
        }

        @Override // android.view.View.OnAttachStateChangeListener
        public void onViewAttachedToWindow(View view) {
            n.t(view).f3991b.run();
            view.removeOnAttachStateChangeListener(this);
        }

        @Override // android.view.View.OnAttachStateChangeListener
        public void onViewDetachedFromWindow(View view) {
        }
    }

    /* loaded from: classes.dex */
    class g implements Runnable {
        g() {
        }

        @Override // java.lang.Runnable
        public void run() {
            synchronized (this) {
                n.this.f3992c = false;
            }
            n.H();
            if (n.this.f3995f.isAttachedToWindow()) {
                n.this.q();
            } else {
                n.this.f3995f.removeOnAttachStateChangeListener(n.f3990z);
                n.this.f3995f.addOnAttachStateChangeListener(n.f3990z);
            }
        }
    }

    /* loaded from: classes.dex */
    class h implements Choreographer.FrameCallback {
        h() {
        }

        @Override // android.view.Choreographer.FrameCallback
        public void doFrame(long j10) {
            n.this.f3991b.run();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    /* loaded from: classes.dex */
    public static class i {

        /* renamed from: a, reason: collision with root package name */
        public final String[][] f4008a;

        /* renamed from: b, reason: collision with root package name */
        public final int[][] f4009b;

        /* renamed from: c, reason: collision with root package name */
        public final int[][] f4010c;

        public i(int i10) {
            this.f4008a = new String[i10];
            this.f4009b = new int[i10];
            this.f4010c = new int[i10];
        }

        public void a(int i10, String[] strArr, int[] iArr, int[] iArr2) {
            this.f4008a[i10] = strArr;
            this.f4009b[i10] = iArr;
            this.f4010c[i10] = iArr2;
        }
    }

    /* loaded from: classes.dex */
    private static class j implements g0, androidx.databinding.k {

        /* renamed from: a, reason: collision with root package name */
        final o f4011a;

        /* renamed from: b, reason: collision with root package name */
        WeakReference f4012b = null;

        public j(n nVar, int i10, ReferenceQueue referenceQueue) {
            this.f4011a = new o(nVar, i10, this, referenceQueue);
        }

        private u f() {
            WeakReference weakReference = this.f4012b;
            if (weakReference == null) {
                return null;
            }
            return (u) weakReference.get();
        }

        @Override // androidx.databinding.k
        public void a(u uVar) {
            u f10 = f();
            a0 a0Var = (a0) this.f4011a.b();
            if (a0Var != null) {
                if (f10 != null) {
                    a0Var.o(this);
                }
                if (uVar != null) {
                    a0Var.j(uVar, this);
                }
            }
            if (uVar != null) {
                this.f4012b = new WeakReference(uVar);
            }
        }

        @Override // androidx.lifecycle.g0
        public void d(Object obj) {
            n a10 = this.f4011a.a();
            if (a10 != null) {
                o oVar = this.f4011a;
                a10.y(oVar.f4018b, oVar.b(), 0);
            }
        }

        @Override // androidx.databinding.k
        /* renamed from: e, reason: merged with bridge method [inline-methods] */
        public void c(a0 a0Var) {
            u f10 = f();
            if (f10 != null) {
                a0Var.j(f10, this);
            }
        }

        public o g() {
            return this.f4011a;
        }

        @Override // androidx.databinding.k
        /* renamed from: h, reason: merged with bridge method [inline-methods] */
        public void b(a0 a0Var) {
            a0Var.o(this);
        }
    }

    /* loaded from: classes.dex */
    static class k implements t {

        /* renamed from: p, reason: collision with root package name */
        final WeakReference f4013p;

        /* synthetic */ k(n nVar, a aVar) {
            this(nVar);
        }

        @h0(n.a.ON_START)
        public void onStart() {
            n nVar = (n) this.f4013p.get();
            if (nVar != null) {
                nVar.q();
            }
        }

        private k(n nVar) {
            this.f4013p = new WeakReference(nVar);
        }
    }

    /* loaded from: classes.dex */
    private static class l extends i.a implements androidx.databinding.k {

        /* renamed from: a, reason: collision with root package name */
        final o f4014a;

        public l(n nVar, int i10, ReferenceQueue referenceQueue) {
            this.f4014a = new o(nVar, i10, this, referenceQueue);
        }

        @Override // androidx.databinding.k
        public void a(u uVar) {
        }

        @Override // androidx.databinding.k
        public /* bridge */ /* synthetic */ void b(Object obj) {
            android.support.v4.media.session.b.a(obj);
            f(null);
        }

        @Override // androidx.databinding.k
        public /* bridge */ /* synthetic */ void c(Object obj) {
            android.support.v4.media.session.b.a(obj);
            d(null);
        }

        public void d(androidx.databinding.i iVar) {
            iVar.u0(this);
        }

        public o e() {
            return this.f4014a;
        }

        public void f(androidx.databinding.i iVar) {
            iVar.p(this);
        }
    }

    /* loaded from: classes.dex */
    private static class m extends j.a implements androidx.databinding.k {

        /* renamed from: a, reason: collision with root package name */
        final o f4015a;

        public m(n nVar, int i10, ReferenceQueue referenceQueue) {
            this.f4015a = new o(nVar, i10, this, referenceQueue);
        }

        @Override // androidx.databinding.k
        public void a(u uVar) {
        }

        @Override // androidx.databinding.k
        public /* bridge */ /* synthetic */ void b(Object obj) {
            android.support.v4.media.session.b.a(obj);
            f(null);
        }

        @Override // androidx.databinding.k
        public /* bridge */ /* synthetic */ void c(Object obj) {
            android.support.v4.media.session.b.a(obj);
            d(null);
        }

        public void d(androidx.databinding.j jVar) {
            jVar.i(this);
        }

        public o e() {
            return this.f4015a;
        }

        public void f(androidx.databinding.j jVar) {
            jVar.x(this);
        }
    }

    /* renamed from: androidx.databinding.n$n, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    private static class C0105n extends h.a implements androidx.databinding.k {

        /* renamed from: a, reason: collision with root package name */
        final o f4016a;

        public C0105n(n nVar, int i10, ReferenceQueue referenceQueue) {
            this.f4016a = new o(nVar, i10, this, referenceQueue);
        }

        @Override // androidx.databinding.k
        public void a(u uVar) {
        }

        @Override // androidx.databinding.h.a
        public void d(androidx.databinding.h hVar, int i10) {
            n a10 = this.f4016a.a();
            if (a10 != null && ((androidx.databinding.h) this.f4016a.b()) == hVar) {
                a10.y(this.f4016a.f4018b, hVar, i10);
            }
        }

        @Override // androidx.databinding.k
        /* renamed from: e, reason: merged with bridge method [inline-methods] */
        public void c(androidx.databinding.h hVar) {
            hVar.c(this);
        }

        public o f() {
            return this.f4016a;
        }

        @Override // androidx.databinding.k
        /* renamed from: g, reason: merged with bridge method [inline-methods] */
        public void b(androidx.databinding.h hVar) {
            hVar.e(this);
        }
    }

    protected n(androidx.databinding.e eVar, View view, int i10) {
        this.f3991b = new g();
        this.f3992c = false;
        this.f3993d = false;
        this.f3994e = new o[i10];
        this.f3995f = view;
        if (Looper.myLooper() != null) {
            if (f3983s) {
                this.f3998i = Choreographer.getInstance();
                this.f3999j = new h();
                return;
            } else {
                this.f3999j = null;
                this.f4000k = new Handler(Looper.myLooper());
                return;
            }
        }
        throw new IllegalStateException("DataBinding must be created in view's UI Thread");
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static n A(LayoutInflater layoutInflater, int i10, ViewGroup viewGroup, boolean z10, Object obj) {
        m(obj);
        return androidx.databinding.f.i(layoutInflater, i10, viewGroup, z10, null);
    }

    private static boolean C(String str, int i10) {
        int length = str.length();
        if (length == i10) {
            return false;
        }
        while (i10 < length) {
            if (!Character.isDigit(str.charAt(i10))) {
                return false;
            }
            i10++;
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:53:0x0101  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x010e A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private static void D(androidx.databinding.e eVar, View view, Object[] objArr, i iVar, SparseIntArray sparseIntArray, boolean z10) {
        int i10;
        boolean z11;
        int i11;
        int i12;
        int i13;
        int r10;
        int id2;
        int i14;
        int i15;
        if (t(view) != null) {
            return;
        }
        Object tag = view.getTag();
        String str = tag instanceof String ? (String) tag : null;
        int i16 = 1;
        if (z10 && str != null && str.startsWith("layout")) {
            int lastIndexOf = str.lastIndexOf(95);
            if (lastIndexOf > 0) {
                int i17 = lastIndexOf + 1;
                if (C(str, i17)) {
                    i15 = G(str, i17);
                    if (objArr[i15] == null) {
                        objArr[i15] = view;
                    }
                    if (iVar == null) {
                        i15 = -1;
                    }
                    z11 = true;
                    i10 = i15;
                }
            }
            i15 = -1;
            z11 = false;
            i10 = i15;
        } else if (str == null || !str.startsWith("binding_")) {
            i10 = -1;
            z11 = false;
        } else {
            int G = G(str, f3982r);
            if (objArr[G] == null) {
                objArr[G] = view;
            }
            if (iVar == null) {
                G = -1;
            }
            i10 = G;
            z11 = true;
        }
        if (!z11 && (id2 = view.getId()) > 0 && sparseIntArray != null && (i14 = sparseIntArray.get(id2, -1)) >= 0 && objArr[i14] == null) {
            objArr[i14] = view;
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int childCount = viewGroup.getChildCount();
            int i18 = 0;
            int i19 = 0;
            while (i18 < childCount) {
                View childAt = viewGroup.getChildAt(i18);
                if (i10 >= 0 && (childAt.getTag() instanceof String)) {
                    String str2 = (String) childAt.getTag();
                    if (str2.endsWith("_0") && str2.startsWith("layout") && str2.indexOf(47) > 0 && (r10 = r(str2, i19, iVar, i10)) >= 0) {
                        int i20 = r10 + 1;
                        int i21 = iVar.f4009b[i10][r10];
                        int i22 = iVar.f4010c[i10][r10];
                        int s10 = s(viewGroup, i18);
                        if (s10 == i18) {
                            objArr[i21] = androidx.databinding.f.c(eVar, childAt, i22);
                            i11 = i18;
                            i13 = i16;
                            i12 = i20;
                        } else {
                            int i23 = (s10 - i18) + i16;
                            View[] viewArr = new View[i23];
                            for (int i24 = 0; i24 < i23; i24++) {
                                viewArr[i24] = viewGroup.getChildAt(i18 + i24);
                            }
                            objArr[i21] = androidx.databinding.f.d(eVar, viewArr, i22);
                            i11 = i18 + (i23 - 1);
                            i12 = i20;
                            i13 = 1;
                        }
                        if (i13 != 0) {
                            D(eVar, childAt, objArr, iVar, sparseIntArray, false);
                        }
                        int i25 = i12;
                        i16 = 1;
                        i18 = i11 + 1;
                        i19 = i25;
                    }
                }
                i11 = i18;
                i12 = i19;
                i13 = 0;
                if (i13 != 0) {
                }
                int i252 = i12;
                i16 = 1;
                i18 = i11 + 1;
                i19 = i252;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static Object[] E(androidx.databinding.e eVar, View view, int i10, i iVar, SparseIntArray sparseIntArray) {
        Object[] objArr = new Object[i10];
        D(eVar, view, objArr, iVar, sparseIntArray, true);
        return objArr;
    }

    private static int G(String str, int i10) {
        int i11 = 0;
        while (i10 < str.length()) {
            i11 = (i11 * 10) + (str.charAt(i10) - '0');
            i10++;
        }
        return i11;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static void H() {
        while (true) {
            Reference poll = f3989y.poll();
            if (poll == null) {
                return;
            }
            if (poll instanceof o) {
                ((o) poll).e();
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static float K(Float f10) {
        return f10 == null ? BitmapDescriptorFactory.HUE_RED : f10.floatValue();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static int L(Integer num) {
        if (num == null) {
            return 0;
        }
        return num.intValue();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static boolean M(Boolean bool) {
        if (bool == null) {
            return false;
        }
        return bool.booleanValue();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static n l(Object obj, View view, int i10) {
        m(obj);
        return androidx.databinding.f.c(null, view, i10);
    }

    private static androidx.databinding.e m(Object obj) {
        if (obj == null) {
            return null;
        }
        throw new IllegalArgumentException("The provided bindingComponent parameter must be an instance of DataBindingComponent. See  https://issuetracker.google.com/issues/116541301 for details of why this parameter is not defined as DataBindingComponent");
    }

    private void o() {
        if (this.f3997h) {
            J();
            return;
        }
        if (z()) {
            this.f3997h = true;
            this.f3993d = false;
            androidx.databinding.b bVar = this.f3996g;
            if (bVar != null) {
                bVar.d(this, 1, null);
                if (this.f3993d) {
                    this.f3996g.d(this, 2, null);
                }
            }
            if (!this.f3993d) {
                n();
                androidx.databinding.b bVar2 = this.f3996g;
                if (bVar2 != null) {
                    bVar2.d(this, 3, null);
                }
            }
            this.f3997h = false;
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static void p(n nVar) {
        nVar.o();
    }

    private static int r(String str, int i10, i iVar, int i11) {
        CharSequence subSequence = str.subSequence(str.indexOf(47) + 1, str.length() - 2);
        String[] strArr = iVar.f4008a[i11];
        int length = strArr.length;
        while (i10 < length) {
            if (TextUtils.equals(subSequence, strArr[i10])) {
                return i10;
            }
            i10++;
        }
        return -1;
    }

    private static int s(ViewGroup viewGroup, int i10) {
        String str = (String) viewGroup.getChildAt(i10).getTag();
        String substring = str.substring(0, str.length() - 1);
        int length = substring.length();
        int childCount = viewGroup.getChildCount();
        for (int i11 = i10 + 1; i11 < childCount; i11++) {
            View childAt = viewGroup.getChildAt(i11);
            String str2 = childAt.getTag() instanceof String ? (String) childAt.getTag() : null;
            if (str2 != null && str2.startsWith(substring)) {
                if (str2.length() == str.length() && str2.charAt(str2.length() - 1) == '0') {
                    return i10;
                }
                if (C(str2, length)) {
                    i10 = i11;
                }
            }
        }
        return i10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static n t(View view) {
        if (view != null) {
            return (n) view.getTag(c4.a.f7448a);
        }
        return null;
    }

    public static int u() {
        return f3981q;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static int v(View view, int i10) {
        return view.getContext().getColor(i10);
    }

    public abstract void B();

    protected abstract boolean F(int i10, Object obj, int i11);

    protected void I(int i10, Object obj, androidx.databinding.c cVar) {
        if (obj == null) {
            return;
        }
        o oVar = this.f3994e[i10];
        if (oVar == null) {
            oVar = cVar.a(this, i10, f3989y);
            this.f3994e[i10] = oVar;
            u uVar = this.f4002m;
            if (uVar != null) {
                oVar.c(uVar);
            }
        }
        oVar.d(obj);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void J() {
        n nVar = this.f4001l;
        if (nVar != null) {
            nVar.J();
            return;
        }
        u uVar = this.f4002m;
        if (uVar == null || uVar.getLifecycle().b().isAtLeast(n.b.STARTED)) {
            synchronized (this) {
                if (this.f3992c) {
                    return;
                }
                this.f3992c = true;
                if (f3983s) {
                    this.f3998i.postFrameCallback(this.f3999j);
                } else {
                    this.f4000k.post(this.f3991b);
                }
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void N(n nVar) {
        if (nVar != null) {
            nVar.f4001l = this;
        }
    }

    public void O(u uVar) {
        if (uVar instanceof androidx.fragment.app.f) {
            Log.w("DataBinding", "Setting the fragment as the LifecycleOwner might cause memory leaks because views lives shorter than the Fragment. Consider using Fragment's view lifecycle");
        }
        u uVar2 = this.f4002m;
        if (uVar2 == uVar) {
            return;
        }
        if (uVar2 != null) {
            uVar2.getLifecycle().d(this.f4003n);
        }
        this.f4002m = uVar;
        if (uVar != null) {
            if (this.f4003n == null) {
                this.f4003n = new k(this, null);
            }
            uVar.getLifecycle().a(this.f4003n);
        }
        for (o oVar : this.f3994e) {
            if (oVar != null) {
                oVar.c(uVar);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void P(View view) {
        view.setTag(c4.a.f7448a, this);
    }

    public abstract boolean Q(int i10, Object obj);

    protected boolean R(int i10) {
        o oVar = this.f3994e[i10];
        if (oVar != null) {
            return oVar.e();
        }
        return false;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public boolean S(int i10, a0 a0Var) {
        this.f4004o = true;
        try {
            return T(i10, a0Var, f3987w);
        } finally {
            this.f4004o = false;
        }
    }

    protected boolean T(int i10, Object obj, androidx.databinding.c cVar) {
        if (obj == null) {
            return R(i10);
        }
        o oVar = this.f3994e[i10];
        if (oVar == null) {
            I(i10, obj, cVar);
            return true;
        }
        if (oVar.b() == obj) {
            return false;
        }
        R(i10);
        I(i10, obj, cVar);
        return true;
    }

    protected abstract void n();

    public void q() {
        n nVar = this.f4001l;
        if (nVar == null) {
            o();
        } else {
            nVar.q();
        }
    }

    public u w() {
        return this.f4002m;
    }

    public View x() {
        return this.f3995f;
    }

    protected void y(int i10, Object obj, int i11) {
        if (this.f4004o || this.f4005p || !F(i10, obj, i11)) {
            return;
        }
        J();
    }

    public abstract boolean z();

    /* JADX INFO: Access modifiers changed from: protected */
    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public n(Object obj, View view, int i10) {
        this((androidx.databinding.e) null, view, i10);
        m(obj);
    }
}
