mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Review: Simplify getSortedIndexFromInitialTrackGroup
This commit is contained in:
parent
ed58280d23
commit
551b6d65ae
1 changed files with 4 additions and 10 deletions
|
|
@ -304,7 +304,7 @@ public class TrackSelectionView extends LinearLayout {
|
||||||
SelectionOverride override = overrides.get(i);
|
SelectionOverride override = overrides.get(i);
|
||||||
for (int j = 0; j < trackViews[i].length; j++) {
|
for (int j = 0; j < trackViews[i].length; j++) {
|
||||||
if(override != null) {
|
if(override != null) {
|
||||||
int sortedIndex = getSortedIndexFromInitialTrackGroup(override.groupIndex, j);
|
int sortedIndex = getSortedIndexFromInitialTrackGroup(j);
|
||||||
trackViews[i][j].setChecked(override.containsTrack(sortedIndex));
|
trackViews[i][j].setChecked(override.containsTrack(sortedIndex));
|
||||||
} else {
|
} else {
|
||||||
trackViews[i][j].setChecked(false);
|
trackViews[i][j].setChecked(false);
|
||||||
|
|
@ -342,7 +342,7 @@ public class TrackSelectionView extends LinearLayout {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Pair<Integer, Integer> tag = (Pair<Integer, Integer>) Assertions.checkNotNull(view.getTag());
|
Pair<Integer, Integer> tag = (Pair<Integer, Integer>) Assertions.checkNotNull(view.getTag());
|
||||||
int groupIndex = tag.first;
|
int groupIndex = tag.first;
|
||||||
int trackIndex = getSortedIndexFromInitialTrackGroup(tag.first, tag.second);
|
int trackIndex = getSortedIndexFromInitialTrackGroup(tag.second);
|
||||||
SelectionOverride override = overrides.get(groupIndex);
|
SelectionOverride override = overrides.get(groupIndex);
|
||||||
Assertions.checkNotNull(mappedTrackInfo);
|
Assertions.checkNotNull(mappedTrackInfo);
|
||||||
if (override == null) {
|
if (override == null) {
|
||||||
|
|
@ -404,20 +404,14 @@ public class TrackSelectionView extends LinearLayout {
|
||||||
* asc sorted array (only quality for this example) : [256,480,720,1080]
|
* asc sorted array (only quality for this example) : [256,480,720,1080]
|
||||||
* initial array index for 480 is 0, but for sorted array index is 1.
|
* initial array index for 480 is 0, but for sorted array index is 1.
|
||||||
* Initial array index is @param trackIndex, and the @return result is sorted array index
|
* Initial array index is @param trackIndex, and the @return result is sorted array index
|
||||||
* @param groupIndex which TrackGroup you want to browse into
|
|
||||||
* @param trackIndex which index of the initial array
|
* @param trackIndex which index of the initial array
|
||||||
* @return index of the sorted array that correspond to the same element in the initial array
|
* @return index of the sorted array that correspond to the same element in the initial array
|
||||||
*/
|
*/
|
||||||
private int getSortedIndexFromInitialTrackGroup(int groupIndex, int trackIndex) {
|
private int getSortedIndexFromInitialTrackGroup(int trackIndex) {
|
||||||
int sortedTrackIndex = trackIndex;
|
int sortedTrackIndex = trackIndex;
|
||||||
if(sortedTrackGroups != trackGroups) {
|
if(sortedTrackGroups != trackGroups) {
|
||||||
Format selectedFormat = sortedTrackGroups.get(rendererIndex).getFormat(trackIndex);
|
Format selectedFormat = sortedTrackGroups.get(rendererIndex).getFormat(trackIndex);
|
||||||
for (int formatIndex = 0; formatIndex < trackGroups.get(groupIndex).length; formatIndex++) {
|
sortedTrackIndex = trackGroups.get(rendererIndex).indexOf(selectedFormat);
|
||||||
if(trackGroups.get(groupIndex).getFormat(formatIndex) == selectedFormat) {
|
|
||||||
sortedTrackIndex = formatIndex;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sortedTrackIndex;
|
return sortedTrackIndex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue