package com.google.android.exoplayer2.ui;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
import p138.p176.p177.p190.p217.C3829;
import p138.p176.p177.p190.p235.C4022;
import p138.p176.p177.p190.p236.C4053;
import p138.p176.p177.p190.p236.C4066;
import p138.p176.p177.p190.p236.C4067;
import p138.p176.p177.p190.p236.InterfaceC4072;

/* JADX INFO: loaded from: classes.dex */
public class TrackSelectionView extends LinearLayout {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int f1947;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final LayoutInflater f1948;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final CheckedTextView f1949;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final CheckedTextView f1950;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final ViewOnClickListenerC0314 f1951;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final SparseArray<C4022.C4029> f1952;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public boolean f1953;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public boolean f1954;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public InterfaceC4072 f1955;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public CheckedTextView[][] f1956;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public C3829 f1957;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public boolean f1958;

    /* JADX INFO: renamed from: com.google.android.exoplayer2.ui.TrackSelectionView$ؠ, reason: contains not printable characters */
    public class ViewOnClickListenerC0314 implements View.OnClickListener {
        public /* synthetic */ ViewOnClickListenerC0314(C0313 c0313) {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            TrackSelectionView trackSelectionView = TrackSelectionView.this;
            if (view == trackSelectionView.f1949) {
                trackSelectionView.f1958 = true;
                trackSelectionView.f1952.clear();
            } else {
                if (view != trackSelectionView.f1950) {
                    trackSelectionView.f1958 = false;
                    Pair pair = (Pair) view.getTag();
                    int iIntValue = ((Integer) pair.first).intValue();
                    ((Integer) pair.second).intValue();
                    trackSelectionView.f1952.get(iIntValue);
                    throw null;
                }
                trackSelectionView.f1958 = false;
                trackSelectionView.f1952.clear();
            }
            trackSelectionView.m1280();
        }
    }

    public TrackSelectionView(Context context) {
        this(context, null);
    }

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

    public TrackSelectionView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        setOrientation(1);
        this.f1952 = new SparseArray<>();
        setSaveFromParentEnabled(false);
        TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.selectableItemBackground});
        this.f1947 = typedArrayObtainStyledAttributes.getResourceId(0, 0);
        typedArrayObtainStyledAttributes.recycle();
        this.f1948 = LayoutInflater.from(context);
        this.f1951 = new ViewOnClickListenerC0314(null);
        this.f1955 = new C4053(getResources());
        this.f1957 = C3829.f11784;
        CheckedTextView checkedTextView = (CheckedTextView) this.f1948.inflate(R.layout.simple_list_item_single_choice, (ViewGroup) this, false);
        this.f1949 = checkedTextView;
        checkedTextView.setBackgroundResource(this.f1947);
        this.f1949.setText(C4067.exo_track_selection_none);
        this.f1949.setEnabled(false);
        this.f1949.setFocusable(true);
        this.f1949.setOnClickListener(this.f1951);
        this.f1949.setVisibility(8);
        addView(this.f1949);
        addView(this.f1948.inflate(C4066.exo_list_divider, (ViewGroup) this, false));
        CheckedTextView checkedTextView2 = (CheckedTextView) this.f1948.inflate(R.layout.simple_list_item_single_choice, (ViewGroup) this, false);
        this.f1950 = checkedTextView2;
        checkedTextView2.setBackgroundResource(this.f1947);
        this.f1950.setText(C4067.exo_track_selection_auto);
        this.f1950.setEnabled(false);
        this.f1950.setFocusable(true);
        this.f1950.setOnClickListener(this.f1951);
        addView(this.f1950);
    }

    public boolean getIsDisabled() {
        return this.f1958;
    }

    public List<C4022.C4029> getOverrides() {
        ArrayList arrayList = new ArrayList(this.f1952.size());
        for (int i = 0; i < this.f1952.size(); i++) {
            arrayList.add(this.f1952.valueAt(i));
        }
        return arrayList;
    }

    public void setAllowAdaptiveSelections(boolean z) {
        if (this.f1953 != z) {
            this.f1953 = z;
            m1281();
        }
    }

    public void setAllowMultipleOverrides(boolean z) {
        if (this.f1954 != z) {
            this.f1954 = z;
            if (!z && this.f1952.size() > 1) {
                for (int size = this.f1952.size() - 1; size > 0; size--) {
                    this.f1952.remove(size);
                }
            }
            m1281();
        }
    }

    public void setShowDisableOption(boolean z) {
        this.f1949.setVisibility(z ? 0 : 8);
    }

    public void setTrackNameProvider(InterfaceC4072 interfaceC4072) {
        if (interfaceC4072 == null) {
            throw null;
        }
        this.f1955 = interfaceC4072;
        m1281();
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x004d  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m1280() {
        boolean z;
        boolean z2;
        this.f1949.setChecked(this.f1958);
        this.f1950.setChecked(!this.f1958 && this.f1952.size() == 0);
        for (int i = 0; i < this.f1956.length; i++) {
            C4022.C4029 c4029 = this.f1952.get(i);
            int i2 = 0;
            while (true) {
                CheckedTextView[][] checkedTextViewArr = this.f1956;
                if (i2 < checkedTextViewArr[i].length) {
                    CheckedTextView checkedTextView = checkedTextViewArr[i][i2];
                    if (c4029 != null) {
                        int[] iArr = c4029.f12804;
                        int length = iArr.length;
                        int i3 = 0;
                        while (true) {
                            if (i3 >= length) {
                                z2 = false;
                                break;
                            } else {
                                if (iArr[i3] == i2) {
                                    z2 = true;
                                    break;
                                }
                                i3++;
                            }
                        }
                        z = z2;
                    }
                    checkedTextView.setChecked(z);
                    i2++;
                }
            }
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m1281() {
        int childCount = getChildCount();
        while (true) {
            childCount--;
            if (childCount < 3) {
                this.f1949.setEnabled(false);
                this.f1950.setEnabled(false);
                return;
            }
            removeViewAt(childCount);
        }
    }
}
