package androidx.preference;

import a3.i0;
import a3.j0;
import a3.l0;
import a3.p0;
import a3.q0;
import a3.r0;
import a3.s0;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public class SeekBarPreference extends Preference {

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public int f3617o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public int f3618p0;

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    public int f3619q0;

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public int f3620r0;

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public boolean f3621s0;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public SeekBar f3622t0;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public TextView f3623u0;

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public final boolean f3624v0;

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public final boolean f3625w0;

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    public final boolean f3626x0;

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public final q0 f3627y0;
    public final r0 z0;

    public SeekBarPreference(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        this.f3627y0 = new q0(this);
        this.z0 = new r0(this);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, p0.SeekBarPreference, i10, i11);
        this.f3618p0 = typedArrayObtainStyledAttributes.getInt(p0.SeekBarPreference_min, 0);
        int i12 = typedArrayObtainStyledAttributes.getInt(p0.SeekBarPreference_android_max, 100);
        int i13 = this.f3618p0;
        i12 = i12 < i13 ? i13 : i12;
        if (i12 != this.f3619q0) {
            this.f3619q0 = i12;
            j();
        }
        int i14 = typedArrayObtainStyledAttributes.getInt(p0.SeekBarPreference_seekBarIncrement, 0);
        if (i14 != this.f3620r0) {
            this.f3620r0 = Math.min(this.f3619q0 - this.f3618p0, Math.abs(i14));
            j();
        }
        this.f3624v0 = typedArrayObtainStyledAttributes.getBoolean(p0.SeekBarPreference_adjustable, true);
        this.f3625w0 = typedArrayObtainStyledAttributes.getBoolean(p0.SeekBarPreference_showSeekBarValue, false);
        this.f3626x0 = typedArrayObtainStyledAttributes.getBoolean(p0.SeekBarPreference_updatesContinuously, false);
        typedArrayObtainStyledAttributes.recycle();
    }

    public final void B(int i10, boolean z10) {
        int i11 = this.f3618p0;
        if (i10 < i11) {
            i10 = i11;
        }
        int i12 = this.f3619q0;
        if (i10 > i12) {
            i10 = i12;
        }
        if (i10 != this.f3617o0) {
            this.f3617o0 = i10;
            TextView textView = this.f3623u0;
            if (textView != null) {
                textView.setText(String.valueOf(i10));
            }
            s(i10);
            if (z10) {
                j();
            }
        }
    }

    @Override // androidx.preference.Preference
    public final void n(i0 i0Var) {
        super.n(i0Var);
        i0Var.itemView.setOnKeyListener(this.z0);
        this.f3622t0 = (SeekBar) i0Var.a(l0.seekbar);
        TextView textView = (TextView) i0Var.a(l0.seekbar_value);
        this.f3623u0 = textView;
        if (this.f3625w0) {
            textView.setVisibility(0);
        } else {
            textView.setVisibility(8);
            this.f3623u0 = null;
        }
        SeekBar seekBar = this.f3622t0;
        if (seekBar == null) {
            return;
        }
        seekBar.setOnSeekBarChangeListener(this.f3627y0);
        this.f3622t0.setMax(this.f3619q0 - this.f3618p0);
        int i10 = this.f3620r0;
        if (i10 != 0) {
            this.f3622t0.setKeyProgressIncrement(i10);
        } else {
            this.f3620r0 = this.f3622t0.getKeyProgressIncrement();
        }
        this.f3622t0.setProgress(this.f3617o0 - this.f3618p0);
        int i11 = this.f3617o0;
        TextView textView2 = this.f3623u0;
        if (textView2 != null) {
            textView2.setText(String.valueOf(i11));
        }
        this.f3622t0.setEnabled(i());
    }

    @Override // androidx.preference.Preference
    @Nullable
    public Object onGetDefaultValue(@NonNull TypedArray typedArray, int i10) {
        return Integer.valueOf(typedArray.getInt(i10, 0));
    }

    @Override // androidx.preference.Preference
    public void onRestoreInstanceState(@Nullable Parcelable parcelable) {
        if (parcelable == null || !parcelable.getClass().equals(s0.class)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        s0 s0Var = (s0) parcelable;
        super.onRestoreInstanceState(s0Var.getSuperState());
        this.f3617o0 = s0Var.f275a;
        this.f3618p0 = s0Var.f276b;
        this.f3619q0 = s0Var.f277c;
        j();
    }

    @Override // androidx.preference.Preference
    @Nullable
    public Parcelable onSaveInstanceState() {
        Parcelable parcelableOnSaveInstanceState = super.onSaveInstanceState();
        if (this.S) {
            return parcelableOnSaveInstanceState;
        }
        s0 s0Var = new s0(parcelableOnSaveInstanceState);
        s0Var.f275a = this.f3617o0;
        s0Var.f276b = this.f3618p0;
        s0Var.f277c = this.f3619q0;
        return s0Var;
    }

    @Override // androidx.preference.Preference
    public final void onSetInitialValue(Object obj) {
        if (obj == null) {
            obj = 0;
        }
        B(e(((Integer) obj).intValue()), true);
    }

    public SeekBarPreference(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        this(context, attributeSet, i10, 0);
    }

    public SeekBarPreference(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, j0.seekBarPreferenceStyle);
    }
}
