package androidx.appcompat.widget; 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 java.lang.ref.WeakReference; import o.SYO; /* loaded from: classes.dex */ public final class ViewStubCompat extends View { private Sts a; private WeakReference b; private int c; private int d; private LayoutInflater e; /* loaded from: classes.dex */ public interface Sts { void b(ViewStubCompat viewStubCompat, View view); } @Override // android.view.View protected final void dispatchDraw(Canvas canvas) { } @Override // android.view.View public final void draw(Canvas canvas) { } public ViewStubCompat(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public ViewStubCompat(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.d = 0; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, SYO.ZqN.ViewStubCompat, i, 0); this.c = obtainStyledAttributes.getResourceId(SYO.ZqN.ViewStubCompat_android_inflatedId, -1); this.d = obtainStyledAttributes.getResourceId(SYO.ZqN.ViewStubCompat_android_layout, 0); setId(obtainStyledAttributes.getResourceId(SYO.ZqN.ViewStubCompat_android_id, -1)); obtainStyledAttributes.recycle(); setVisibility(8); setWillNotDraw(true); } @Override // android.view.View protected final void onMeasure(int i, int i2) { setMeasuredDimension(0, 0); } @Override // android.view.View public final void setVisibility(int i) { WeakReference weakReference = this.b; if (weakReference != null) { 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) { e(); } } public final View e() { ViewParent parent = getParent(); if (!(parent instanceof ViewGroup)) { throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent"); } if (this.d != 0) { ViewGroup viewGroup = (ViewGroup) parent; LayoutInflater layoutInflater = this.e; if (layoutInflater == null) { layoutInflater = LayoutInflater.from(getContext()); } View inflate = layoutInflater.inflate(this.d, viewGroup, false); int i = this.c; if (i != -1) { inflate.setId(i); } int indexOfChild = viewGroup.indexOfChild(this); viewGroup.removeViewInLayout(this); ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams != null) { viewGroup.addView(inflate, indexOfChild, layoutParams); } else { viewGroup.addView(inflate, indexOfChild); } this.b = new WeakReference<>(inflate); Sts sts = this.a; if (sts != null) { sts.b(this, inflate); } return inflate; } throw new IllegalArgumentException("ViewStub must have a valid layoutResource"); } public final void setOnInflateListener(Sts sts) { this.a = sts; } public final void setLayoutResource(int i) { this.d = i; } public final void setLayoutInflater(LayoutInflater layoutInflater) { this.e = layoutInflater; } public final void setInflatedId(int i) { this.c = i; } }