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.AbstractC5234;
import defpackage.C1194;
import defpackage.C1627;
import defpackage.C4053;
import defpackage.C4494;
import defpackage.RunnableC1500;
import java.util.ArrayList;
import java.util.Collections;

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

    /* JADX INFO: renamed from: ˆʤᵳ, reason: contains not printable characters */
    public boolean f782;

    /* JADX INFO: renamed from: ˏʜᵪ, reason: contains not printable characters */
    public final Handler f783;

    /* JADX INFO: renamed from: ˏʽˊᵰ, reason: contains not printable characters */
    public int f784;

    /* JADX INFO: renamed from: ᵘᵝ, reason: contains not printable characters */
    public final ArrayList f785;

    /* JADX INFO: renamed from: ᵬᵦˋ, reason: contains not printable characters */
    public final C4053 f786;

    /* JADX INFO: renamed from: ᵮᵟᵡ, reason: contains not printable characters */
    public boolean f787;

    /* JADX INFO: renamed from: ᵯˇ, reason: contains not printable characters */
    public final RunnableC1500 f788;

    /* JADX INFO: renamed from: ᵹʾᵢᵯ, reason: contains not printable characters */
    public int 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.f786 = new C4053(0);
        this.f783 = new Handler(Looper.getMainLooper());
        this.f782 = true;
        this.f789 = 0;
        this.f787 = false;
        this.f784 = Integer.MAX_VALUE;
        this.f788 = new RunnableC1500(18, this);
        this.f785 = new ArrayList();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC5234.f19733, i, 0);
        this.f782 = 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.f752);
            }
            this.f784 = i3;
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo441(Bundle bundle) {
        super.mo441(bundle);
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            m466(i).mo441(bundle);
        }
    }

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final Preference m463(CharSequence charSequence) {
        Preference preferenceM463;
        if (charSequence == null) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Key cannot be null");
            return null;
        }
        if (TextUtils.equals(this.f752, charSequence)) {
            return this;
        }
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            Preference preferenceM466 = m466(i);
            if (TextUtils.equals(preferenceM466.f752, charSequence)) {
                return preferenceM466;
            }
            if ((preferenceM466 instanceof PreferenceGroup) && (preferenceM463 = ((PreferenceGroup) preferenceM466).m463(charSequence)) != null) {
                return preferenceM463;
            }
        }
        return null;
    }

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final void m464(Preference preference) {
        long jM4483;
        if (this.f785.contains(preference)) {
            return;
        }
        if (preference.f752 != null) {
            PreferenceGroup preferenceGroup = this;
            while (true) {
                PreferenceGroup preferenceGroup2 = preferenceGroup.f768;
                if (preferenceGroup2 == null) {
                    break;
                } else {
                    preferenceGroup = preferenceGroup2;
                }
            }
            preferenceGroup.m463(preference.f752);
        }
        if (preference.f759 == Integer.MAX_VALUE) {
            if (this.f782) {
                int i = this.f789;
                this.f789 = i + 1;
                preference.m459(i);
            }
            if (preference instanceof PreferenceGroup) {
                ((PreferenceGroup) preference).f782 = this.f782;
            }
        }
        int iBinarySearch = Collections.binarySearch(this.f785, preference);
        if (iBinarySearch < 0) {
            iBinarySearch = (iBinarySearch * (-1)) - 1;
        }
        boolean zMo429 = mo429();
        if (preference.f770 == zMo429) {
            preference.f770 = !zMo429;
            preference.mo453(preference.mo429());
            preference.mo428();
        }
        synchronized (this) {
            this.f785.add(iBinarySearch, preference);
        }
        C1627 c1627 = this.f769;
        String str = preference.f752;
        if (str == null || !this.f786.containsKey(str)) {
            jM4483 = c1627.m4483();
        } else {
            jM4483 = ((Long) this.f786.get(str)).longValue();
            this.f786.remove(str);
        }
        preference.f775 = jM4483;
        preference.f777 = true;
        try {
            preference.m445(c1627);
            preference.f777 = false;
            if (preference.f768 != null) {
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("This preference already has a parent. You must remove the existing parent before assigning a new one.");
                return;
            }
            preference.f768 = this;
            if (this.f787) {
                preference.mo449();
            }
            C4494 c4494 = this.f748;
            if (c4494 != null) {
                Handler handler = c4494.f17124;
                RunnableC1500 runnableC1500 = c4494.f17128;
                handler.removeCallbacks(runnableC1500);
                handler.post(runnableC1500);
            }
        } catch (Throwable th) {
            preference.f777 = false;
            throw th;
        }
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ˉᵲ */
    public final void mo431(Parcelable parcelable) {
        if (!parcelable.getClass().equals(C1194.class)) {
            super.mo431(parcelable);
            return;
        }
        C1194 c1194 = (C1194) parcelable;
        this.f784 = c1194.f5086;
        super.mo431(c1194.getSuperState());
    }

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final void m465() {
        synchronized (this) {
            try {
                ArrayList arrayList = this.f785;
                for (int size = arrayList.size() - 1; size >= 0; size--) {
                    m467((Preference) arrayList.get(0));
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        C4494 c4494 = this.f748;
        if (c4494 != null) {
            Handler handler = c4494.f17124;
            RunnableC1500 runnableC1500 = c4494.f17128;
            handler.removeCallbacks(runnableC1500);
            handler.post(runnableC1500);
        }
    }

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public final Preference m466(int i) {
        return (Preference) this.f785.get(i);
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ˏːˆ */
    public final Parcelable mo434() {
        super.mo434();
        AbsSavedState absSavedState = AbsSavedState.EMPTY_STATE;
        return new C1194(this.f784);
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final void mo446(Bundle bundle) {
        super.mo446(bundle);
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            m466(i).mo446(bundle);
        }
    }

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final boolean m467(Preference preference) {
        boolean zRemove;
        synchronized (this) {
            try {
                preference.m443();
                if (preference.f768 == this) {
                    preference.f768 = null;
                }
                zRemove = this.f785.remove(preference);
                if (zRemove) {
                    String str = preference.f752;
                    if (str != null) {
                        this.f786.put(str, Long.valueOf(preference.mo462()));
                        this.f783.removeCallbacks(this.f788);
                        this.f783.post(this.f788);
                    }
                    if (this.f787) {
                        preference.mo455();
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return zRemove;
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ᵝᵶ */
    public final void mo449() {
        super.mo449();
        this.f787 = true;
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            m466(i).mo449();
        }
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ᵮᵣᵗˈ */
    public final void mo453(boolean z) {
        super.mo453(z);
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            Preference preferenceM466 = m466(i);
            if (preferenceM466.f770 == z) {
                preferenceM466.f770 = !z;
                preferenceM466.mo453(preferenceM466.mo429());
                preferenceM466.mo428();
            }
        }
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ᵱʡˏ */
    public final void mo455() {
        m443();
        this.f787 = false;
        int size = this.f785.size();
        for (int i = 0; i < size; i++) {
            m466(i).mo455();
        }
    }
}
