package androidx.preference;

import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.AbsSavedState;
import defpackage.AbstractC4608;
import defpackage.C0642;
import defpackage.C1616;
import defpackage.C2771;
import defpackage.C5010;
import defpackage.RunnableC2802;
import java.util.ArrayList;
import java.util.Collections;

/* loaded from: classes3.dex */
public abstract class PreferenceGroup extends Preference {

    /* renamed from: ʽᵢˊ, reason: contains not printable characters */
    public int f782;

    /* renamed from: ʿᵘˆ, reason: contains not printable characters */
    public int f783;

    /* renamed from: ᵠᵪˀᵻ, reason: contains not printable characters */
    public boolean f784;

    /* renamed from: ᵣᵟᵔ, reason: contains not printable characters */
    public final C2771 f785;

    /* renamed from: ᵥʩᵩˑ, reason: contains not printable characters */
    public final Handler f786;

    /* renamed from: ᵨٴ, reason: contains not printable characters */
    public boolean f787;

    /* renamed from: ᵰʖʢ, reason: contains not printable characters */
    public final RunnableC2802 f788;

    /* renamed from: ᵲᵟ, reason: contains not printable characters */
    public final ArrayList f789;

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

    public PreferenceGroup(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, 0);
        this.f785 = new C2771(0);
        this.f786 = new Handler(Looper.getMainLooper());
        this.f787 = true;
        this.f782 = 0;
        this.f784 = false;
        this.f783 = Integer.MAX_VALUE;
        this.f788 = new RunnableC2802(18, this);
        this.f789 = new ArrayList();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC4608.f17080, i, 0);
        this.f787 = typedArrayObtainStyledAttributes.getBoolean(2, typedArrayObtainStyledAttributes.getBoolean(2, true));
        if (typedArrayObtainStyledAttributes.hasValue(1)) {
            int i3 = typedArrayObtainStyledAttributes.getInt(1, typedArrayObtainStyledAttributes.getInt(1, Integer.MAX_VALUE));
            if (i3 != Integer.MAX_VALUE) {
                TextUtils.isEmpty(this.f775);
            }
            this.f783 = i3;
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public final Preference m463(int i) {
        return (Preference) this.f789.get(i);
    }

    @Override // androidx.preference.Preference
    /* renamed from: ˌᵜᵹᵩ */
    public final void mo443(boolean z) {
        super.mo443(z);
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            Preference preferenceM463 = m463(i);
            if (preferenceM463.f759 == z) {
                preferenceM463.f759 = !z;
                preferenceM463.mo443(preferenceM463.mo433());
                preferenceM463.mo428();
            }
        }
    }

    @Override // androidx.preference.Preference
    /* renamed from: ˏᵙ */
    public final void mo447(Bundle bundle) {
        super.mo447(bundle);
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            m463(i).mo447(bundle);
        }
    }

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public final void m464(Preference preference) {
        long jM10455;
        if (this.f789.contains(preference)) {
            return;
        }
        if (preference.f775 != null) {
            PreferenceGroup preferenceGroup = this;
            while (true) {
                PreferenceGroup preferenceGroup2 = preferenceGroup.f741;
                if (preferenceGroup2 == null) {
                    break;
                } else {
                    preferenceGroup = preferenceGroup2;
                }
            }
            preferenceGroup.m466(preference.f775);
        }
        if (preference.f761 == Integer.MAX_VALUE) {
            if (this.f787) {
                int i = this.f782;
                this.f782 = i + 1;
                preference.m450(i);
            }
            if (preference instanceof PreferenceGroup) {
                ((PreferenceGroup) preference).f787 = this.f787;
            }
        }
        int iBinarySearch = Collections.binarySearch(this.f789, preference);
        if (iBinarySearch < 0) {
            iBinarySearch = (iBinarySearch * (-1)) - 1;
        }
        boolean zMo433 = mo433();
        if (preference.f759 == zMo433) {
            preference.f759 = !zMo433;
            preference.mo443(preference.mo433());
            preference.mo428();
        }
        synchronized (this) {
            this.f789.add(iBinarySearch, preference);
        }
        C5010 c5010 = this.f765;
        String str = preference.f775;
        if (str == null || !this.f785.containsKey(str)) {
            jM10455 = c5010.m10455();
        } else {
            jM10455 = ((Long) this.f785.get(str)).longValue();
            this.f785.remove(str);
        }
        preference.f778 = jM10455;
        preference.f766 = true;
        try {
            preference.m455(c5010);
            preference.f766 = false;
            if (preference.f741 != null) {
                ᵹˉᵞ.ᵳٴᵶ("This preference already has a parent. You must remove the existing parent before assigning a new one.");
                return;
            }
            preference.f741 = this;
            if (this.f784) {
                preference.mo456();
            }
            C0642 c0642 = this.f752;
            if (c0642 != null) {
                Handler handler = c0642.f3157;
                RunnableC2802 runnableC2802 = c0642.f3156;
                handler.removeCallbacks(runnableC2802);
                handler.post(runnableC2802);
            }
        } catch (Throwable th) {
            preference.f766 = false;
            throw th;
        }
    }

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public final boolean m465(Preference preference) {
        boolean zRemove;
        synchronized (this) {
            try {
                preference.m460();
                if (preference.f741 == this) {
                    preference.f741 = null;
                }
                zRemove = this.f789.remove(preference);
                if (zRemove) {
                    String str = preference.f775;
                    if (str != null) {
                        this.f785.put(str, Long.valueOf(preference.mo446()));
                        this.f786.removeCallbacks(this.f788);
                        this.f786.post(this.f788);
                    }
                    if (this.f784) {
                        preference.mo449();
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return zRemove;
    }

    @Override // androidx.preference.Preference
    /* renamed from: ᵞʡ */
    public final void mo431(Parcelable parcelable) {
        if (!parcelable.getClass().equals(C1616.class)) {
            super.mo431(parcelable);
            return;
        }
        C1616 c1616 = (C1616) parcelable;
        this.f783 = c1616.f6410;
        super.mo431(c1616.getSuperState());
    }

    @Override // androidx.preference.Preference
    /* renamed from: ᵡʠ */
    public final void mo449() {
        m460();
        this.f784 = false;
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            m463(i).mo449();
        }
    }

    @Override // androidx.preference.Preference
    /* renamed from: ᵨᵳʝ */
    public final Parcelable mo432() {
        super.mo432();
        AbsSavedState absSavedState = AbsSavedState.EMPTY_STATE;
        return new C1616(this.f783);
    }

    @Override // androidx.preference.Preference
    /* renamed from: ᵯٴᵦ */
    public final void mo456() {
        super.mo456();
        this.f784 = true;
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            m463(i).mo456();
        }
    }

    @Override // androidx.preference.Preference
    /* renamed from: ᵴᵳ */
    public final void mo457(Bundle bundle) {
        super.mo457(bundle);
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            m463(i).mo457(bundle);
        }
    }

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public final Preference m466(CharSequence charSequence) {
        Preference preferenceM466;
        if (charSequence == null) {
            ᵹˉᵞ.ˌᵜᵹᵩ("Key cannot be null");
            return null;
        }
        if (TextUtils.equals(this.f775, charSequence)) {
            return this;
        }
        int size = this.f789.size();
        for (int i = 0; i < size; i++) {
            Preference preferenceM463 = m463(i);
            if (TextUtils.equals(preferenceM463.f775, charSequence)) {
                return preferenceM463;
            }
            if ((preferenceM463 instanceof PreferenceGroup) && (preferenceM466 = ((PreferenceGroup) preferenceM463).m466(charSequence)) != null) {
                return preferenceM466;
            }
        }
        return null;
    }

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final void m467() {
        synchronized (this) {
            try {
                ArrayList arrayList = this.f789;
                for (int size = arrayList.size() - 1; size >= 0; size--) {
                    m465((Preference) arrayList.get(0));
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        C0642 c0642 = this.f752;
        if (c0642 != null) {
            Handler handler = c0642.f3157;
            RunnableC2802 runnableC2802 = c0642.f3156;
            handler.removeCallbacks(runnableC2802);
            handler.post(runnableC2802);
        }
    }
}
