Review: Fix initSortedTrack to keep all groups in the TrackGroupArray

This commit is contained in:
Yoni Obadia 2020-08-27 12:19:56 +02:00
parent 551b6d65ae
commit c9b4b98103

View File

@ -384,16 +384,17 @@ public class TrackSelectionView extends LinearLayout {
private TrackGroupArray initSortedTrackGroups(TrackGroupArray trackGroups) { private TrackGroupArray initSortedTrackGroups(TrackGroupArray trackGroups) {
TrackGroupArray trackGroupArray = trackGroups; TrackGroupArray trackGroupArray = trackGroups;
if(comparator != null) { if(comparator != null) {
TrackGroupArray trackGroupsArray = mappedTrackInfo.getTrackGroups(rendererIndex); TrackGroup[] tg = new TrackGroup[trackGroupArray.length];
for (int groupIndex = 0; groupIndex < trackGroupsArray.length; groupIndex++) { for (int groupIndex = 0; groupIndex < trackGroupArray.length; groupIndex++) {
TrackGroup group = trackGroupsArray.get(groupIndex); TrackGroup group = trackGroupArray.get(groupIndex);
Format[] listFormats = new Format[group.length]; Format[] listFormats = new Format[group.length];
for (int formatIndex = 0; formatIndex < group.length; formatIndex++) { for (int formatIndex = 0; formatIndex < group.length; formatIndex++) {
listFormats[formatIndex] = group.getFormat(formatIndex); listFormats[formatIndex] = group.getFormat(formatIndex);
} }
Arrays.sort(listFormats, comparator); Arrays.sort(listFormats, comparator);
trackGroupArray = new TrackGroupArray(new TrackGroup(listFormats)); tg[groupIndex] = new TrackGroup(listFormats);
} }
trackGroupArray = new TrackGroupArray(tg);
} }
return trackGroupArray; return trackGroupArray;
} }