content: 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 androidx.appcompat.R;
  import java.lang.ref.WeakReference;
  
  public final class ViewStubCompat extends View {
      private OnInflateListener mInflateListener;
      private int mInflatedId;
      private WeakReference<View> mInflatedViewRef;
      private LayoutInflater mInflater;
      private int mLayoutResource;
  
      public interface OnInflateListener {
          void onInflate(ViewStubCompat viewStubCompat, View view);
      }
  
      public ViewStubCompat(Context context, AttributeSet attrs) {
          this(context, attrs, 0);
      }
  
      public ViewStubCompat(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          this.mLayoutResource = 0;
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, R.styleable.ViewStubCompat, defStyle, 0);
          this.mInflatedId = obtainStyledAttributes.getResourceId(R.styleable.ViewStubCompat_android_inflatedId, -1);
          this.mLayoutResource = obtainStyledAttributes.getResourceId(R.styleable.ViewStubCompat_android_layout, 0);
          setId(obtainStyledAttributes.getResourceId(R.styleable.ViewStubCompat_android_id, -1));
          obtainStyledAttributes.recycle();
          setVisibility(8);
          setWillNotDraw(true);
      }
  
      /* access modifiers changed from: protected */
      public void dispatchDraw(Canvas canvas) {
      }
  
      public void draw(Canvas canvas) {
      }
  
      public int getInflatedId() {
          return this.mInflatedId;
      }
  
      public LayoutInflater getLayoutInflater() {
          return this.mInflater;
      }
  
      public int getLayoutResource() {
          return this.mLayoutResource;
      }
  
      public View inflate() {
          ViewParent parent = getParent();
          if (!(parent instanceof ViewGroup)) {
              throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
          } else if (this.mLayoutResource != 0) {
              ViewGroup viewGroup = (ViewGroup) parent;
              View inflate = (this.mInflater != null ? this.mInflater : LayoutInflater.from(getContext())).inflate(this.mLayoutResource, viewGroup, false);
              int i = this.mInflatedId;
              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.mInflatedViewRef = new WeakReference<>(inflate);
              OnInflateListener onInflateListener = this.mInflateListener;
              if (onInflateListener != null) {
                  onInflateListener.onInflate(this, inflate);
              }
              return inflate;
          } else {
              throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
          }
      }
  
      /* access modifiers changed from: protected */
      public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          setMeasuredDimension(0, 0);
      }
  
      public void setInflatedId(int inflatedId) {
          this.mInflatedId = inflatedId;
      }
  
      public void setLayoutInflater(LayoutInflater inflater) {
          this.mInflater = inflater;
      }
  
      public void setLayoutResource(int layoutResource) {
          this.mLayoutResource = layoutResource;
      }
  
      public void setOnInflateListener(OnInflateListener inflateListener) {
          this.mInflateListener = inflateListener;
      }
  
      public void setVisibility(int visibility) {
          WeakReference<View> weakReference = this.mInflatedViewRef;
          if (weakReference != null) {
              View view = (View) weakReference.get();
              if (view != null) {
                  view.setVisibility(visibility);
                  return;
              }
              throw new IllegalStateException("setVisibility called on un-referenced view");
          }
          super.setVisibility(visibility);
          if (visibility == 0 || visibility == 4) {
              inflate();
          }
      }
  }
  