package U;

import A1.y;
import M4.k;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.SparseIntArray;
import android.view.Choreographer;
import android.view.View;
import android.view.ViewGroup;
import androidx.lifecycle.EnumC0510o;
import com.martsnew.tv.R;
import h0.Y;
import java.lang.ref.ReferenceQueue;
import u5.M0;

/* JADX INFO: loaded from: classes.dex */
public abstract class g extends W3.b {
    public static final boolean H = true;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public static final ReferenceQueue f6645I = new ReferenceQueue();

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public static final d f6646J = new d(0);

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public boolean f6647A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final Choreographer f6648B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public final e f6649C;
    public final Handler D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public M0 f6650E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public Y f6651F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public f f6652G;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final k f6653w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public boolean f6654x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final h[] f6655y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final View f6656z;

    public g(Object obj, View view, int i) {
        if (obj != 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");
        }
        this.f6653w = new k(9, this);
        this.f6654x = false;
        this.f6655y = new h[i];
        this.f6656z = view;
        if (Looper.myLooper() == null) {
            throw new IllegalStateException("DataBinding must be created in view's UI Thread");
        }
        if (H) {
            this.f6648B = Choreographer.getInstance();
            this.f6649C = new e(0, this);
        } else {
            this.f6649C = null;
            this.D = new Handler(Looper.myLooper());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:115:0x01e0  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x0098  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void H(View view, Object[] objArr, y yVar, SparseIntArray sparseIntArray, boolean z8) {
        int iCharAt;
        boolean z9;
        int i;
        int i5;
        int i8;
        int i9;
        int i10;
        String str;
        int id;
        int i11;
        int i12;
        int length;
        if ((view != null ? (g) view.getTag(R.id.dataBinding) : null) != null) {
            return;
        }
        Object tag = view.getTag();
        String str2 = tag instanceof String ? (String) tag : null;
        int i13 = 0;
        int i14 = 1;
        if (!z8 || str2 == null || !str2.startsWith("layout")) {
            if (str2 != null && str2.startsWith("binding_")) {
                int length2 = str2.length();
                iCharAt = 0;
                for (int i15 = 8; i15 < length2; i15++) {
                    iCharAt = (iCharAt * 10) + (str2.charAt(i15) - '0');
                }
                if (objArr[iCharAt] == null) {
                    objArr[iCharAt] = view;
                }
                if (yVar == null) {
                    iCharAt = -1;
                }
                z9 = true;
            }
            z9 = false;
            iCharAt = -1;
            break;
        }
        int iLastIndexOf = str2.lastIndexOf(95);
        if (iLastIndexOf > 0 && (length = str2.length()) != (i12 = iLastIndexOf + 1)) {
            for (int i16 = i12; i16 < length; i16++) {
                if (Character.isDigit(str2.charAt(i16))) {
                }
            }
            int length3 = str2.length();
            iCharAt = 0;
            while (i12 < length3) {
                iCharAt = (iCharAt * 10) + (str2.charAt(i12) - '0');
                i12++;
            }
            if (objArr[iCharAt] == null) {
                objArr[iCharAt] = view;
            }
            if (yVar == null) {
            }
            z9 = true;
        }
        z9 = false;
        iCharAt = -1;
        break;
        if (!z9 && (id = view.getId()) > 0 && sparseIntArray != null && (i11 = sparseIntArray.get(id, -1)) >= 0 && objArr[i11] == null) {
            objArr[i11] = view;
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int childCount = viewGroup.getChildCount();
            int i17 = 0;
            int i18 = 0;
            while (i17 < childCount) {
                View childAt = viewGroup.getChildAt(i17);
                if (iCharAt < 0 || !(childAt.getTag() instanceof String)) {
                    i = childCount;
                    i5 = i14;
                    i8 = 0;
                } else {
                    String str3 = (String) childAt.getTag();
                    if (str3.endsWith("_0") && str3.startsWith("layout") && str3.indexOf(47) > 0) {
                        i5 = i14;
                        CharSequence charSequenceSubSequence = str3.subSequence(str3.indexOf(47) + i14, str3.length() - 2);
                        String[] strArr = ((String[][]) yVar.f363r)[iCharAt];
                        int length4 = strArr.length;
                        int i19 = i18;
                        while (true) {
                            if (i19 >= length4) {
                                i19 = -1;
                                break;
                            } else if (TextUtils.equals(charSequenceSubSequence, strArr[i19])) {
                                break;
                            } else {
                                i19++;
                            }
                        }
                        if (i19 >= 0) {
                            i18 = i19 + 1;
                            int i20 = ((int[][]) yVar.f364s)[iCharAt][i19];
                            int i21 = ((int[][]) yVar.f365t)[iCharAt][i19];
                            String str4 = (String) viewGroup.getChildAt(i17).getTag();
                            String strSubstring = str4.substring(i13, str4.length() - 1);
                            int length5 = strSubstring.length();
                            int childCount2 = viewGroup.getChildCount();
                            i = childCount;
                            int i22 = i17;
                            int i23 = i17 + 1;
                            while (i23 < childCount2) {
                                View childAt2 = viewGroup.getChildAt(i23);
                                int i24 = i23;
                                String str5 = childAt2.getTag() instanceof String ? (String) childAt2.getTag() : null;
                                if (str5 != null && str5.startsWith(strSubstring)) {
                                    i10 = childCount2;
                                    str = str4;
                                    if (str5.length() == str.length() && str5.charAt(str5.length() - 1) == '0') {
                                        break;
                                    }
                                    int length6 = str5.length();
                                    if (length6 != length5) {
                                        int i25 = length5;
                                        while (true) {
                                            if (i25 >= length6) {
                                                i22 = i24;
                                                break;
                                            } else if (!Character.isDigit(str5.charAt(i25))) {
                                                break;
                                            } else {
                                                i25++;
                                            }
                                        }
                                    }
                                } else {
                                    i10 = childCount2;
                                    str = str4;
                                }
                                i23 = i24 + 1;
                                childCount2 = i10;
                                str4 = str;
                            }
                            if (i22 == i17) {
                                objArr[i20] = c.f6640a.b(childAt, i21);
                            } else {
                                int i26 = i22 - i17;
                                int i27 = i26 + 1;
                                View[] viewArr = new View[i27];
                                for (int i28 = 0; i28 < i27; i28++) {
                                    viewArr[i28] = viewGroup.getChildAt(i17 + i28);
                                }
                                objArr[i20] = c.f6640a.c(viewArr, i21);
                                i17 += i26;
                            }
                            i8 = i5;
                        } else {
                            i = childCount;
                        }
                    }
                    i8 = 0;
                }
                if (i8 == 0) {
                    i9 = 0;
                    H(childAt, objArr, yVar, sparseIntArray, false);
                } else {
                    i9 = 0;
                }
                i17++;
                childCount = i;
                i13 = i9;
                i14 = i5;
            }
        }
    }

    public static Object[] I(View view, int i, y yVar, SparseIntArray sparseIntArray) {
        Object[] objArr = new Object[i];
        H(view, objArr, yVar, sparseIntArray, true);
        return objArr;
    }

    public abstract void C();

    public final void D() {
        if (this.f6647A) {
            J();
        } else if (F()) {
            this.f6647A = true;
            C();
            this.f6647A = false;
        }
    }

    public final void E() {
        M0 m02 = this.f6650E;
        if (m02 == null) {
            D();
        } else {
            m02.E();
        }
    }

    public abstract boolean F();

    public abstract void G();

    public final void J() {
        M0 m02 = this.f6650E;
        if (m02 != null) {
            m02.J();
            return;
        }
        Y y8 = this.f6651F;
        if (y8 != null) {
            y8.c();
            if (y8.f13140u.f8849t.compareTo(EnumC0510o.f8837t) < 0) {
                return;
            }
        }
        synchronized (this) {
            try {
                if (this.f6654x) {
                    return;
                }
                this.f6654x = true;
                if (H) {
                    this.f6648B.postFrameCallback(this.f6649C);
                } else {
                    this.D.post(this.f6653w);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public void K(Y y8) {
        Y y9 = this.f6651F;
        if (y9 == y8) {
            return;
        }
        if (y9 != null) {
            y9.c();
            y9.f13140u.y(this.f6652G);
        }
        this.f6651F = y8;
        if (y8 != null) {
            if (this.f6652G == null) {
                this.f6652G = new f(this);
            }
            y8.c();
            y8.f13140u.f(this.f6652G);
        }
        for (h hVar : this.f6655y) {
        }
    }

    public final void L(View view) {
        view.setTag(R.id.dataBinding, this);
    }
}
