mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
TrackSelectionView: Use same "isAdaptive" logic in updateViews and onClick.
We currently do not show check boxes if the renderer does not support adaptive switches between tracks in one group. However, we assume check boxes in the onClick method. Use same logic for both methods to be consistent. PiperOrigin-RevId: 236118372
This commit is contained in:
parent
2ae07936ba
commit
0bb123aa4c
@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
|
||||
/** A view for making track selections. */
|
||||
public class TrackSelectionView extends LinearLayout {
|
||||
@ -257,11 +258,7 @@ public class TrackSelectionView extends LinearLayout {
|
||||
allowMultipleOverrides && trackGroups.length > 1;
|
||||
for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
|
||||
TrackGroup group = trackGroups.get(groupIndex);
|
||||
boolean enableMultipleChoiceForAdaptiveSelections =
|
||||
allowAdaptiveSelections
|
||||
&& trackGroups.get(groupIndex).length > 1
|
||||
&& mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, false)
|
||||
!= RendererCapabilities.ADAPTIVE_NOT_SUPPORTED;
|
||||
boolean enableMultipleChoiceForAdaptiveSelections = shouldEnableAdaptiveSelection(groupIndex);
|
||||
trackViews[groupIndex] = new CheckedTextView[group.length];
|
||||
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
|
||||
if (trackIndex == 0) {
|
||||
@ -334,11 +331,13 @@ public class TrackSelectionView extends LinearLayout {
|
||||
int groupIndex = tag.first;
|
||||
int trackIndex = tag.second;
|
||||
SelectionOverride override = overrides.get(groupIndex);
|
||||
Assertions.checkNotNull(mappedTrackInfo);
|
||||
boolean adaptiveSelectionsEnabled = shouldEnableAdaptiveSelection(groupIndex);
|
||||
if (!allowMultipleOverrides && override == null && overrides.size() > 0) {
|
||||
// A new override is being started and we don't allow multiple overrides.
|
||||
overrides.clear();
|
||||
}
|
||||
if (override == null || !allowAdaptiveSelections) {
|
||||
if (override == null || !adaptiveSelectionsEnabled) {
|
||||
// Update override for current group.
|
||||
if (((CheckedTextView) view).isChecked()) {
|
||||
overrides.remove(groupIndex);
|
||||
@ -371,6 +370,14 @@ public class TrackSelectionView extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresNonNull("mappedTrackInfo")
|
||||
private boolean shouldEnableAdaptiveSelection(int groupIndex) {
|
||||
return allowAdaptiveSelections
|
||||
&& trackGroups.get(groupIndex).length > 1
|
||||
&& mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, false)
|
||||
!= RendererCapabilities.ADAPTIVE_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
private static int[] getTracksAdding(int[] tracks, int addedTrack) {
|
||||
tracks = Arrays.copyOf(tracks, tracks.length + 1);
|
||||
tracks[tracks.length - 1] = addedTrack;
|
||||
|
Loading…
x
Reference in New Issue
Block a user