package x;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.constraintlayout.widget.ConstraintLayout;
import d5.AbstractC0844a;
import java.util.Arrays;
import java.util.HashMap;

/* JADX INFO: loaded from: classes.dex */
public abstract class b extends View {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int[] f18326q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f18327r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public Context f18328s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public v.i f18329t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public String f18330u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public HashMap f18331v;

    public b(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f18326q = new int[32];
        this.f18331v = new HashMap();
        this.f18328s = context;
        e(attributeSet);
    }

    /* JADX WARN: Removed duplicated region for block: B:30:0x005e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a(String str) {
        Context context;
        int identifier;
        HashMap map;
        if (str == null || str.length() == 0 || (context = this.f18328s) == null) {
            return;
        }
        String strTrim = str.trim();
        if (getParent() instanceof ConstraintLayout) {
        }
        ConstraintLayout constraintLayout = getParent() instanceof ConstraintLayout ? (ConstraintLayout) getParent() : null;
        if (!isInEditMode() || constraintLayout == null) {
            identifier = 0;
        } else {
            Object obj = (AbstractC0844a.w(strTrim) && (map = constraintLayout.f7902C) != null && map.containsKey(strTrim)) ? constraintLayout.f7902C.get(strTrim) : null;
            if (obj instanceof Integer) {
                identifier = ((Integer) obj).intValue();
            }
        }
        if (identifier == 0 && constraintLayout != null) {
            identifier = d(constraintLayout, strTrim);
        }
        if (identifier == 0) {
            try {
                identifier = m.class.getField(strTrim).getInt(null);
            } catch (Exception unused) {
            }
        }
        if (identifier == 0) {
            identifier = context.getResources().getIdentifier(strTrim, "id", context.getPackageName());
        }
        if (identifier != 0) {
            this.f18331v.put(Integer.valueOf(identifier), strTrim);
            b(identifier);
        } else {
            Log.w("ConstraintHelper", "Could not find id of \"" + strTrim + "\"");
        }
    }

    public final void b(int i) {
        if (i == getId()) {
            return;
        }
        int i5 = this.f18327r + 1;
        int[] iArr = this.f18326q;
        if (i5 > iArr.length) {
            this.f18326q = Arrays.copyOf(iArr, iArr.length * 2);
        }
        int[] iArr2 = this.f18326q;
        int i8 = this.f18327r;
        iArr2[i8] = i;
        this.f18327r = i8 + 1;
    }

    public final void c() {
        ViewParent parent = getParent();
        if (parent == null || !(parent instanceof ConstraintLayout)) {
            return;
        }
        ConstraintLayout constraintLayout = (ConstraintLayout) parent;
        int visibility = getVisibility();
        float elevation = getElevation();
        for (int i = 0; i < this.f18327r; i++) {
            View view = (View) constraintLayout.f7904q.get(this.f18326q[i]);
            if (view != null) {
                view.setVisibility(visibility);
                if (elevation > 0.0f) {
                    view.setTranslationZ(view.getTranslationZ() + elevation);
                }
            }
        }
    }

    public final int d(ConstraintLayout constraintLayout, String str) {
        Resources resources;
        String resourceEntryName;
        if (str != null && (resources = this.f18328s.getResources()) != null) {
            int childCount = constraintLayout.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = constraintLayout.getChildAt(i);
                if (childAt.getId() != -1) {
                    try {
                        resourceEntryName = resources.getResourceEntryName(childAt.getId());
                    } catch (Resources.NotFoundException unused) {
                        resourceEntryName = null;
                    }
                    if (str.equals(resourceEntryName)) {
                        return childAt.getId();
                    }
                }
            }
        }
        return 0;
    }

    public void e(AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, n.f18488b);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i = 0; i < indexCount; i++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i);
                if (index == 19) {
                    String string = typedArrayObtainStyledAttributes.getString(index);
                    this.f18330u = string;
                    setIds(string);
                }
            }
        }
    }

    public int[] getReferencedIds() {
        return Arrays.copyOf(this.f18326q, this.f18327r);
    }

    public final void h() {
        if (this.f18329t == null) {
            return;
        }
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        if (layoutParams instanceof d) {
            ((d) layoutParams).f18376k0 = this.f18329t;
        }
    }

    @Override // android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        String str = this.f18330u;
        if (str != null) {
            setIds(str);
        }
    }

    @Override // android.view.View
    public void onMeasure(int i, int i5) {
        setMeasuredDimension(0, 0);
    }

    public void setIds(String str) {
        this.f18330u = str;
        if (str == null) {
            return;
        }
        int i = 0;
        this.f18327r = 0;
        while (true) {
            int iIndexOf = str.indexOf(44, i);
            if (iIndexOf == -1) {
                a(str.substring(i));
                return;
            } else {
                a(str.substring(i, iIndexOf));
                i = iIndexOf + 1;
            }
        }
    }

    public void setReferencedIds(int[] iArr) {
        this.f18330u = null;
        this.f18327r = 0;
        for (int i : iArr) {
            b(i);
        }
    }

    public void g() {
    }

    @Override // android.view.View
    public final void onDraw(Canvas canvas) {
    }

    public void f(v.d dVar, boolean z8) {
    }
}
