mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 16:10:31 +00:00
fix: sonarcloud lint
This commit is contained in:
parent
61a14765f3
commit
dbd6e4d11f
@ -657,23 +657,21 @@ public final class PlayQueueActivity extends AppCompatActivity
|
||||
* @param itemId index of the selected item
|
||||
*/
|
||||
private void onAudioTrackClick(final int itemId) {
|
||||
@Nullable final MediaItemTag currentMetadata = player.getCurrentMetadata();
|
||||
if (currentMetadata == null || currentMetadata.getMaybeAudioTrack().isEmpty()) {
|
||||
if (player.getCurrentMetadata() == null) {
|
||||
return;
|
||||
}
|
||||
player.getCurrentMetadata().getMaybeAudioTrack().ifPresent(audioTrack -> {
|
||||
final List<AudioStream> availableStreams = audioTrack.getAudioStreams();
|
||||
final int selectedStreamIndex = audioTrack.getSelectedAudioStreamIndex();
|
||||
if (selectedStreamIndex == itemId || availableStreams.size() <= itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MediaItemTag.AudioTrack audioTrack =
|
||||
currentMetadata.getMaybeAudioTrack().get();
|
||||
final List<AudioStream> availableStreams = audioTrack.getAudioStreams();
|
||||
final int selectedStreamIndex = audioTrack.getSelectedAudioStreamIndex();
|
||||
if (selectedStreamIndex == itemId || availableStreams.size() <= itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.saveStreamProgressState();
|
||||
final String newAudioTrack = availableStreams.get(itemId).getAudioTrackId();
|
||||
player.setRecovery();
|
||||
player.setAudioTrack(newAudioTrack);
|
||||
player.reloadPlayQueueManager();
|
||||
player.saveStreamProgressState();
|
||||
final String newAudioTrack = availableStreams.get(itemId).getAudioTrackId();
|
||||
player.setRecovery();
|
||||
player.setAudioTrack(newAudioTrack);
|
||||
player.reloadPlayQueueManager();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -239,13 +239,12 @@ public final class ListHelper {
|
||||
}
|
||||
|
||||
// Filter unknown audio tracks if there are multiple tracks
|
||||
java.util.stream.Stream<AudioStream> cs = collectedStreams.values().stream();
|
||||
if (collectedStreams.size() > 1) {
|
||||
cs = cs.filter(s -> s.getAudioTrackId() != null);
|
||||
collectedStreams.remove("");
|
||||
}
|
||||
|
||||
// Sort collected streams by name
|
||||
return cs.sorted(Comparator.comparing(audioStream ->
|
||||
return collectedStreams.values().stream().sorted(Comparator.comparing(audioStream ->
|
||||
Localization.audioTrackName(context, audioStream))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -390,6 +390,12 @@ public class ListHelperTest {
|
||||
stream = AUDIO_TRACKS_TEST_LIST.get(ListHelper.getAudioIndexByHighestRank(
|
||||
null, AUDIO_TRACKS_TEST_LIST, cmp));
|
||||
assertEquals("en.ds", stream.getId());
|
||||
|
||||
// Japanese language, fall back to original
|
||||
cmp = ListHelper.getAudioStreamComparator(Locale.JAPANESE, true, false, false);
|
||||
stream = AUDIO_TRACKS_TEST_LIST.get(ListHelper.getAudioIndexByHighestRank(
|
||||
null, AUDIO_TRACKS_TEST_LIST, cmp));
|
||||
assertEquals("en.or", stream.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user