package androidx.fragment.app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TabHost;
import java.util.ArrayList;
import ඓ.K.K.K.C1293;
import ῲ.Ԕ.K.AbstractC1531;
import ῲ.Ԕ.K.AbstractC1558;

@Deprecated
public class FragmentTabHost extends TabHost implements TabHost.OnTabChangeListener {

    /* renamed from: ʬ  reason: contains not printable characters */
    public Context f1317;

    /* renamed from: ඓ  reason: contains not printable characters */
    public int f1318;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final ArrayList<C0190> f1319 = new ArrayList<>();

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C0190 f1320;

    /* renamed from: 㴹  reason: contains not printable characters */
    public TabHost.OnTabChangeListener f1321;

    /* renamed from: 㸾  reason: contains not printable characters */
    public AbstractC1531 f1322;

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f1323;

    public static class SavedState extends View.BaseSavedState {
        public static final Parcelable.Creator<SavedState> CREATOR = new C0189();

        /* renamed from: ῲ  reason: contains not printable characters */
        public String f1324;

        /* renamed from: androidx.fragment.app.FragmentTabHost$SavedState$K  reason: contains not printable characters */
        public static class C0189 implements Parcelable.Creator<SavedState> {
            /* Return type fixed from 'java.lang.Object' to match base method */
            @Override // android.os.Parcelable.Creator
            public SavedState createFromParcel(Parcel parcel) {
                return new SavedState(parcel);
            }

            /* Return type fixed from 'java.lang.Object[]' to match base method */
            @Override // android.os.Parcelable.Creator
            public SavedState[] newArray(int i) {
                return new SavedState[i];
            }
        }

        public SavedState(Parcelable parcelable) {
            super(parcelable);
        }

        public String toString() {
            StringBuilder r0 = C1293.m3416("FragmentTabHost.SavedState{");
            r0.append(Integer.toHexString(System.identityHashCode(this)));
            r0.append(" curTab=");
            return C1293.m3414(r0, this.f1324, "}");
        }

        public void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeString(this.f1324);
        }

        public SavedState(Parcel parcel) {
            super(parcel);
            this.f1324 = parcel.readString();
        }
    }

    /* renamed from: androidx.fragment.app.FragmentTabHost$K  reason: contains not printable characters */
    public static final class C0190 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final Bundle f1325;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final Class<?> f1326;

        /* renamed from: K  reason: contains not printable characters */
        public final String f1327;

        /* renamed from: 㸾  reason: contains not printable characters */
        public Fragment f1328;
    }

    @Deprecated
    public FragmentTabHost(Context context) {
        super(context, null);
        m686(context, (AttributeSet) null);
    }

    @Deprecated
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        String currentTabTag = getCurrentTabTag();
        int size = this.f1319.size();
        AbstractC1558 r2 = null;
        for (int i = 0; i < size; i++) {
            C0190 k = this.f1319.get(i);
            k.f1328 = this.f1322.m3914(k.f1327);
            Fragment fragment = k.f1328;
            if (fragment != null && !fragment.isDetached()) {
                if (k.f1327.equals(currentTabTag)) {
                    this.f1320 = k;
                } else {
                    if (r2 == null) {
                        r2 = this.f1322.m3915();
                    }
                    r2.m4094(k.f1328);
                }
            }
        }
        this.f1323 = true;
        AbstractC1558 r0 = m685(currentTabTag, r2);
        if (r0 != null) {
            r0.m4095();
            this.f1322.m3913();
        }
    }

    @Deprecated
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.f1323 = false;
    }

    @Deprecated
    public void onRestoreInstanceState(@SuppressLint({"UnknownNullness"}) Parcelable parcelable) {
        if (!(parcelable instanceof SavedState)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        SavedState savedState = (SavedState) parcelable;
        super.onRestoreInstanceState(savedState.getSuperState());
        setCurrentTabByTag(savedState.f1324);
    }

    @Deprecated
    public Parcelable onSaveInstanceState() {
        SavedState savedState = new SavedState(super.onSaveInstanceState());
        savedState.f1324 = getCurrentTabTag();
        return savedState;
    }

    @Deprecated
    public void onTabChanged(String str) {
        AbstractC1558 r0;
        if (this.f1323 && (r0 = m685(str, (AbstractC1558) null)) != null) {
            r0.m4095();
        }
        TabHost.OnTabChangeListener onTabChangeListener = this.f1321;
        if (onTabChangeListener != null) {
            onTabChangeListener.onTabChanged(str);
        }
    }

    @Deprecated
    public void setOnTabChangedListener(TabHost.OnTabChangeListener onTabChangeListener) {
        this.f1321 = onTabChangeListener;
    }

    @Deprecated
    public void setup() {
        throw new IllegalStateException("Must call setup() that takes a Context and FragmentManager");
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m686(Context context, AttributeSet attributeSet) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{16842995}, 0, 0);
        this.f1318 = obtainStyledAttributes.getResourceId(0, 0);
        obtainStyledAttributes.recycle();
        super.setOnTabChangedListener(this);
    }

    @Deprecated
    public FragmentTabHost(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        m686(context, attributeSet);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final AbstractC1558 m685(String str, AbstractC1558 r6) {
        C0190 k;
        Fragment fragment;
        int size = this.f1319.size();
        int i = 0;
        while (true) {
            if (i >= size) {
                k = null;
                break;
            }
            k = this.f1319.get(i);
            if (k.f1327.equals(str)) {
                break;
            }
            i++;
        }
        if (this.f1320 != k) {
            if (r6 == null) {
                r6 = this.f1322.m3915();
            }
            C0190 k2 = this.f1320;
            if (!(k2 == null || (fragment = k2.f1328) == null)) {
                r6.m4094(fragment);
            }
            if (k != null) {
                Fragment fragment2 = k.f1328;
                if (fragment2 == null) {
                    k.f1328 = this.f1322.m3911().m3878(this.f1317.getClassLoader(), k.f1326.getName());
                    k.f1328.setArguments(k.f1325);
                    r6.m4097(this.f1318, k.f1328, k.f1327);
                } else {
                    r6.m4098(fragment2);
                }
            }
            this.f1320 = k;
        }
        return r6;
    }
}
