package androidx.appcompat.widget;

import X.AnonymousClass0HH;
import X.C008203c;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import com.bytedance.covode.number.Covode;
import java.lang.ref.WeakReference;

public final class ViewStubCompat extends View {
    public int LIZ;
    public int LIZIZ;
    public WeakReference<View> LIZJ;
    public LayoutInflater LIZLLL;
    public C008203c LJ;

    static {
        Covode.recordClassIndex(459);
    }

    public final void dispatchDraw(Canvas canvas) {
    }

    public final void draw(Canvas canvas) {
    }

    public final int getInflatedId() {
        return this.LIZIZ;
    }

    public final LayoutInflater getLayoutInflater() {
        return this.LIZLLL;
    }

    public final int getLayoutResource() {
        return this.LIZ;
    }

    public final View LIZ() {
        ViewParent parent = getParent();
        if (parent == null || !(parent instanceof ViewGroup)) {
            throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
        } else if (this.LIZ != 0) {
            ViewGroup viewGroup = (ViewGroup) parent;
            LayoutInflater layoutInflater = this.LIZLLL;
            if (layoutInflater == null) {
                layoutInflater = LayoutInflater.from(getContext());
            }
            View LIZ2 = AnonymousClass0HH.LIZ(layoutInflater, this.LIZ, viewGroup, false);
            int i = this.LIZIZ;
            if (i != -1) {
                LIZ2.setId(i);
            }
            int indexOfChild = viewGroup.indexOfChild(this);
            viewGroup.removeViewInLayout(this);
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            if (layoutParams != null) {
                viewGroup.addView(LIZ2, indexOfChild, layoutParams);
            } else {
                viewGroup.addView(LIZ2, indexOfChild);
            }
            this.LIZJ = new WeakReference<>(LIZ2);
            return LIZ2;
        } else {
            throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
        }
    }

    public final void setInflatedId(int i) {
        this.LIZIZ = i;
    }

    public final void setLayoutInflater(LayoutInflater layoutInflater) {
        this.LIZLLL = layoutInflater;
    }

    public final void setLayoutResource(int i) {
        this.LIZ = i;
    }

    public final void setOnInflateListener(C008203c r1) {
        this.LJ = r1;
    }

    public final void setVisibility(int i) {
        WeakReference<View> weakReference = this.LIZJ;
        if (weakReference != null) {
            View view = (View) weakReference.get();
            if (view != null) {
                view.setVisibility(i);
                return;
            }
            throw new IllegalStateException("setVisibility called on un-referenced view");
        }
        super.setVisibility(i);
        if (i == 0 || i == 4) {
            LIZ();
        }
    }

    public ViewStubCompat(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, (byte) 0);
    }

    public final void onMeasure(int i, int i2) {
        setMeasuredDimension(0, 0);
    }

    public ViewStubCompat(Context context, AttributeSet attributeSet, byte b) {
        super(context, attributeSet, 0);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{16842960, 16842994, 16842995}, 0, 0);
        this.LIZIZ = obtainStyledAttributes.getResourceId(2, -1);
        this.LIZ = obtainStyledAttributes.getResourceId(1, 0);
        setId(obtainStyledAttributes.getResourceId(0, -1));
        obtainStyledAttributes.recycle();
        setVisibility(8);
        setWillNotDraw(true);
    }
}
