- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
243 lines
9.0 KiB
Java
243 lines
9.0 KiB
Java
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.SparseArray;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.CheckedTextView;
|
|
import android.widget.LinearLayout;
|
|
import androidx.annotation.AttrRes;
|
|
import androidx.annotation.Nullable;
|
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
|
import com.google.android.exoplayer2.util.Assertions;
|
|
import java.util.Arrays;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class TrackSelectionView extends LinearLayout {
|
|
public boolean allowAdaptiveSelections;
|
|
public boolean allowMultipleOverrides;
|
|
public final ComponentListener componentListener;
|
|
public final CheckedTextView defaultView;
|
|
public final CheckedTextView disableView;
|
|
public final LayoutInflater inflater;
|
|
public boolean isDisabled;
|
|
public final SparseArray overrides;
|
|
public final int selectableItemBackgroundResourceId;
|
|
public TrackGroupArray trackGroups;
|
|
public TrackNameProvider trackNameProvider;
|
|
public CheckedTextView[][] trackViews;
|
|
|
|
public static final class TrackInfo {
|
|
public final int groupIndex;
|
|
public final int trackIndex;
|
|
}
|
|
|
|
public TrackSelectionView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public TrackSelectionView(Context context, @Nullable AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public TrackSelectionView(Context context, @Nullable AttributeSet attributeSet, @AttrRes int i) {
|
|
super(context, attributeSet, i);
|
|
setOrientation(1);
|
|
this.overrides = new SparseArray();
|
|
setSaveFromParentEnabled(false);
|
|
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.selectableItemBackground});
|
|
int resourceId = obtainStyledAttributes.getResourceId(0, 0);
|
|
this.selectableItemBackgroundResourceId = resourceId;
|
|
obtainStyledAttributes.recycle();
|
|
LayoutInflater from = LayoutInflater.from(context);
|
|
this.inflater = from;
|
|
ComponentListener componentListener = new ComponentListener();
|
|
this.componentListener = componentListener;
|
|
this.trackNameProvider = new DefaultTrackNameProvider(getResources());
|
|
this.trackGroups = TrackGroupArray.EMPTY;
|
|
CheckedTextView checkedTextView = (CheckedTextView) from.inflate(R.layout.simple_list_item_single_choice, (ViewGroup) this, false);
|
|
this.disableView = checkedTextView;
|
|
checkedTextView.setBackgroundResource(resourceId);
|
|
checkedTextView.setText(R$string.exo_track_selection_none);
|
|
checkedTextView.setEnabled(false);
|
|
checkedTextView.setFocusable(true);
|
|
checkedTextView.setOnClickListener(componentListener);
|
|
checkedTextView.setVisibility(8);
|
|
addView(checkedTextView);
|
|
addView(from.inflate(R$layout.exo_list_divider, (ViewGroup) this, false));
|
|
CheckedTextView checkedTextView2 = (CheckedTextView) from.inflate(R.layout.simple_list_item_single_choice, (ViewGroup) this, false);
|
|
this.defaultView = checkedTextView2;
|
|
checkedTextView2.setBackgroundResource(resourceId);
|
|
checkedTextView2.setText(R$string.exo_track_selection_auto);
|
|
checkedTextView2.setEnabled(false);
|
|
checkedTextView2.setFocusable(true);
|
|
checkedTextView2.setOnClickListener(componentListener);
|
|
addView(checkedTextView2);
|
|
}
|
|
|
|
public void setAllowAdaptiveSelections(boolean z) {
|
|
if (this.allowAdaptiveSelections != z) {
|
|
this.allowAdaptiveSelections = z;
|
|
updateViews();
|
|
}
|
|
}
|
|
|
|
public void setAllowMultipleOverrides(boolean z) {
|
|
if (this.allowMultipleOverrides != z) {
|
|
this.allowMultipleOverrides = z;
|
|
if (!z && this.overrides.size() > 1) {
|
|
for (int size = this.overrides.size() - 1; size > 0; size--) {
|
|
this.overrides.remove(size);
|
|
}
|
|
}
|
|
updateViews();
|
|
}
|
|
}
|
|
|
|
public void setShowDisableOption(boolean z) {
|
|
this.disableView.setVisibility(z ? 0 : 8);
|
|
}
|
|
|
|
public void setTrackNameProvider(TrackNameProvider trackNameProvider) {
|
|
this.trackNameProvider = (TrackNameProvider) Assertions.checkNotNull(trackNameProvider);
|
|
updateViews();
|
|
}
|
|
|
|
public final void updateViews() {
|
|
int childCount = getChildCount();
|
|
while (true) {
|
|
childCount--;
|
|
if (childCount >= 3) {
|
|
removeViewAt(childCount);
|
|
} else {
|
|
this.disableView.setEnabled(false);
|
|
this.defaultView.setEnabled(false);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void updateViewStates() {
|
|
this.disableView.setChecked(this.isDisabled);
|
|
this.defaultView.setChecked(!this.isDisabled && this.overrides.size() == 0);
|
|
for (int i = 0; i < this.trackViews.length; i++) {
|
|
DefaultTrackSelector.SelectionOverride selectionOverride = (DefaultTrackSelector.SelectionOverride) this.overrides.get(i);
|
|
int i2 = 0;
|
|
while (true) {
|
|
CheckedTextView[] checkedTextViewArr = this.trackViews[i];
|
|
if (i2 < checkedTextViewArr.length) {
|
|
if (selectionOverride != null) {
|
|
this.trackViews[i][i2].setChecked(selectionOverride.containsTrack(((TrackInfo) Assertions.checkNotNull(checkedTextViewArr[i2].getTag())).trackIndex));
|
|
} else {
|
|
checkedTextViewArr[i2].setChecked(false);
|
|
}
|
|
i2++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void onClick(View view) {
|
|
if (view == this.disableView) {
|
|
onDisableViewClicked();
|
|
} else if (view == this.defaultView) {
|
|
onDefaultViewClicked();
|
|
} else {
|
|
onTrackViewClicked(view);
|
|
}
|
|
updateViewStates();
|
|
}
|
|
|
|
public final void onDisableViewClicked() {
|
|
this.isDisabled = true;
|
|
this.overrides.clear();
|
|
}
|
|
|
|
public final void onDefaultViewClicked() {
|
|
this.isDisabled = false;
|
|
this.overrides.clear();
|
|
}
|
|
|
|
public final void onTrackViewClicked(View view) {
|
|
this.isDisabled = false;
|
|
TrackInfo trackInfo = (TrackInfo) Assertions.checkNotNull(view.getTag());
|
|
int i = trackInfo.groupIndex;
|
|
int i2 = trackInfo.trackIndex;
|
|
DefaultTrackSelector.SelectionOverride selectionOverride = (DefaultTrackSelector.SelectionOverride) this.overrides.get(i);
|
|
Assertions.checkNotNull(null);
|
|
if (selectionOverride == null) {
|
|
if (!this.allowMultipleOverrides && this.overrides.size() > 0) {
|
|
this.overrides.clear();
|
|
}
|
|
this.overrides.put(i, new DefaultTrackSelector.SelectionOverride(i, i2));
|
|
return;
|
|
}
|
|
int i3 = selectionOverride.length;
|
|
int[] iArr = selectionOverride.tracks;
|
|
boolean isChecked = ((CheckedTextView) view).isChecked();
|
|
boolean shouldEnableAdaptiveSelection = shouldEnableAdaptiveSelection(i);
|
|
boolean z = shouldEnableAdaptiveSelection || shouldEnableMultiGroupSelection();
|
|
if (isChecked && z) {
|
|
if (i3 == 1) {
|
|
this.overrides.remove(i);
|
|
return;
|
|
} else {
|
|
this.overrides.put(i, new DefaultTrackSelector.SelectionOverride(i, getTracksRemoving(iArr, i2)));
|
|
return;
|
|
}
|
|
}
|
|
if (isChecked) {
|
|
return;
|
|
}
|
|
if (shouldEnableAdaptiveSelection) {
|
|
this.overrides.put(i, new DefaultTrackSelector.SelectionOverride(i, getTracksAdding(iArr, i2)));
|
|
} else {
|
|
this.overrides.put(i, new DefaultTrackSelector.SelectionOverride(i, i2));
|
|
}
|
|
}
|
|
|
|
public final boolean shouldEnableAdaptiveSelection(int i) {
|
|
if (!this.allowAdaptiveSelections || this.trackGroups.get(i).length <= 1) {
|
|
return false;
|
|
}
|
|
throw null;
|
|
}
|
|
|
|
public final boolean shouldEnableMultiGroupSelection() {
|
|
return this.allowMultipleOverrides && this.trackGroups.length > 1;
|
|
}
|
|
|
|
public static int[] getTracksAdding(int[] iArr, int i) {
|
|
int[] copyOf = Arrays.copyOf(iArr, iArr.length + 1);
|
|
copyOf[copyOf.length - 1] = i;
|
|
return copyOf;
|
|
}
|
|
|
|
public static int[] getTracksRemoving(int[] iArr, int i) {
|
|
int[] iArr2 = new int[iArr.length - 1];
|
|
int i2 = 0;
|
|
for (int i3 : iArr) {
|
|
if (i3 != i) {
|
|
iArr2[i2] = i3;
|
|
i2++;
|
|
}
|
|
}
|
|
return iArr2;
|
|
}
|
|
|
|
public class ComponentListener implements View.OnClickListener {
|
|
public ComponentListener() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
TrackSelectionView.this.onClick(view);
|
|
}
|
|
}
|
|
}
|