Use List.of().

This commit is contained in:
Isira Seneviratne 2022-07-15 07:40:29 +05:30
parent c53143ef4f
commit ca26fcb0eb
17 changed files with 75 additions and 102 deletions

View File

@ -14,7 +14,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List; import java.util.List;
// See https://stackoverflow.com/questions/56849221#57997489 // See https://stackoverflow.com/questions/56849221#57997489
@ -27,7 +26,7 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
private boolean allowScroll = true; private boolean allowScroll = true;
private final Rect globalRect = new Rect(); private final Rect globalRect = new Rect();
private final List<Integer> skipInterceptionOfElements = Arrays.asList( private final List<Integer> skipInterceptionOfElements = List.of(
R.id.itemsListPanel, R.id.playbackSeekBar, R.id.itemsListPanel, R.id.playbackSeekBar,
R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton); R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton);
@ -67,7 +66,7 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent, public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent,
@NonNull final AppBarLayout child, @NonNull final AppBarLayout child,
@NonNull final MotionEvent ev) { @NonNull final MotionEvent ev) {
for (final Integer element : skipInterceptionOfElements) { for (final int element : skipInterceptionOfElements) {
final View view = child.findViewById(element); final View view = child.findViewById(element);
if (view != null) { if (view != null) {
final boolean visible = view.getGlobalVisibleRect(globalRect); final boolean visible = view.getGlobalVisibleRect(globalRect);

View File

@ -27,9 +27,8 @@ import org.schabi.newpipe.util.StateSaver;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.net.SocketException; import java.net.SocketException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import io.reactivex.rxjava3.exceptions.CompositeException; import io.reactivex.rxjava3.exceptions.CompositeException;
import io.reactivex.rxjava3.exceptions.MissingBackpressureException; import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
@ -140,7 +139,7 @@ public class App extends Application {
if (throwable instanceof UndeliverableException) { if (throwable instanceof UndeliverableException) {
// As UndeliverableException is a wrapper, // As UndeliverableException is a wrapper,
// get the cause of it to get the "real" exception // get the cause of it to get the "real" exception
actualThrowable = throwable.getCause(); actualThrowable = Objects.requireNonNull(throwable.getCause());
} else { } else {
actualThrowable = throwable; actualThrowable = throwable;
} }
@ -149,7 +148,7 @@ public class App extends Application {
if (actualThrowable instanceof CompositeException) { if (actualThrowable instanceof CompositeException) {
errors = ((CompositeException) actualThrowable).getExceptions(); errors = ((CompositeException) actualThrowable).getExceptions();
} else { } else {
errors = Collections.singletonList(actualThrowable); errors = List.of(actualThrowable);
} }
for (final Throwable error : errors) { for (final Throwable error : errors) {
@ -213,41 +212,37 @@ public class App extends Application {
private void initNotificationChannels() { private void initNotificationChannels() {
// Keep the importance below DEFAULT to avoid making noise on every notification update for // Keep the importance below DEFAULT to avoid making noise on every notification update for
// the main and update channels // the main and update channels
final List<NotificationChannelCompat> notificationChannelCompats = new ArrayList<>(); final List<NotificationChannelCompat> notificationChannelCompats = List.of(
notificationChannelCompats.add(new NotificationChannelCompat new NotificationChannelCompat.Builder(getString(R.string.notification_channel_id),
.Builder(getString(R.string.notification_channel_id),
NotificationManagerCompat.IMPORTANCE_LOW) NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.notification_channel_name)) .setName(getString(R.string.notification_channel_name))
.setDescription(getString(R.string.notification_channel_description)) .setDescription(getString(R.string.notification_channel_description))
.build()); .build(),
new NotificationChannelCompat
notificationChannelCompats.add(new NotificationChannelCompat
.Builder(getString(R.string.app_update_notification_channel_id), .Builder(getString(R.string.app_update_notification_channel_id),
NotificationManagerCompat.IMPORTANCE_LOW) NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.app_update_notification_channel_name)) .setName(getString(R.string.app_update_notification_channel_name))
.setDescription(getString(R.string.app_update_notification_channel_description)) .setDescription(
.build()); getString(R.string.app_update_notification_channel_description))
.build(),
notificationChannelCompats.add(new NotificationChannelCompat new NotificationChannelCompat.Builder(getString(R.string.hash_channel_id),
.Builder(getString(R.string.hash_channel_id),
NotificationManagerCompat.IMPORTANCE_HIGH) NotificationManagerCompat.IMPORTANCE_HIGH)
.setName(getString(R.string.hash_channel_name)) .setName(getString(R.string.hash_channel_name))
.setDescription(getString(R.string.hash_channel_description)) .setDescription(getString(R.string.hash_channel_description))
.build()); .build(),
new NotificationChannelCompat.Builder(getString(R.string.error_report_channel_id),
notificationChannelCompats.add(new NotificationChannelCompat
.Builder(getString(R.string.error_report_channel_id),
NotificationManagerCompat.IMPORTANCE_LOW) NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.error_report_channel_name)) .setName(getString(R.string.error_report_channel_name))
.setDescription(getString(R.string.error_report_channel_description)) .setDescription(getString(R.string.error_report_channel_description))
.build()); .build(),
new NotificationChannelCompat
notificationChannelCompats.add(new NotificationChannelCompat
.Builder(getString(R.string.streams_notification_channel_id), .Builder(getString(R.string.streams_notification_channel_id),
NotificationManagerCompat.IMPORTANCE_DEFAULT) NotificationManagerCompat.IMPORTANCE_DEFAULT)
.setName(getString(R.string.streams_notification_channel_name)) .setName(getString(R.string.streams_notification_channel_name))
.setDescription(getString(R.string.streams_notification_channel_description)) .setDescription(
.build()); getString(R.string.streams_notification_channel_description))
.build()
);
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.createNotificationChannelsCompat(notificationChannelCompats); notificationManager.createNotificationChannelsCompat(notificationChannelCompats);

View File

@ -16,7 +16,7 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.SparseItemUtil; import org.schabi.newpipe.util.SparseItemUtil;
import java.util.Collections; import java.util.List;
public final class QueueItemMenuUtil { public final class QueueItemMenuUtil {
private QueueItemMenuUtil() { private QueueItemMenuUtil() {
@ -53,7 +53,7 @@ public final class QueueItemMenuUtil {
case R.id.menu_item_append_playlist: case R.id.menu_item_append_playlist:
PlaylistDialog.createCorrespondingDialog( PlaylistDialog.createCorrespondingDialog(
context, context,
Collections.singletonList(new StreamEntity(item)), List.of(new StreamEntity(item)),
dialog -> dialog.show( dialog -> dialog.show(
fragmentManager, fragmentManager,
"QueueItemMenuUtil@append_playlist" "QueueItemMenuUtil@append_playlist"

View File

@ -81,7 +81,6 @@ import org.schabi.newpipe.views.FocusOverlayView;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import icepick.Icepick; import icepick.Icepick;
@ -649,7 +648,7 @@ public class RouterActivity extends AppCompatActivity {
.subscribe( .subscribe(
info -> PlaylistDialog.createCorrespondingDialog( info -> PlaylistDialog.createCorrespondingDialog(
getThemeWrapperContext(), getThemeWrapperContext(),
Collections.singletonList(new StreamEntity(info)), List.of(new StreamEntity(info)),
playlistDialog -> { playlistDialog -> {
playlistDialog.setOnDismissListener(dialog -> finish()); playlistDialog.setOnDismissListener(dialog -> finish());

View File

@ -114,7 +114,6 @@ import org.schabi.newpipe.util.external_communication.KoreUtils;
import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.util.external_communication.ShareUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -453,7 +452,7 @@ public final class VideoDetailFragment
disposables.add( disposables.add(
PlaylistDialog.createCorrespondingDialog( PlaylistDialog.createCorrespondingDialog(
getContext(), getContext(),
Collections.singletonList(new StreamEntity(currentInfo)), List.of(new StreamEntity(currentInfo)),
dialog -> dialog.show(getFM(), TAG) dialog -> dialog.show(getFM(), TAG)
) )
); );

View File

@ -20,7 +20,7 @@ import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.external_communication.KoreUtils; import org.schabi.newpipe.util.external_communication.KoreUtils;
import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.util.external_communication.ShareUtils;
import java.util.Collections; import java.util.List;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
@ -89,7 +89,7 @@ public enum StreamDialogDefaultEntry {
APPEND_PLAYLIST(R.string.add_to_playlist, (fragment, item) -> APPEND_PLAYLIST(R.string.add_to_playlist, (fragment, item) ->
PlaylistDialog.createCorrespondingDialog( PlaylistDialog.createCorrespondingDialog(
fragment.getContext(), fragment.getContext(),
Collections.singletonList(new StreamEntity(item)), List.of(new StreamEntity(item)),
dialog -> dialog.show( dialog -> dialog.show(
fragment.getParentFragmentManager(), fragment.getParentFragmentManager(),
"StreamDialogEntry@" "StreamDialogEntry@"

View File

@ -14,7 +14,6 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout> { public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout> {
@ -25,7 +24,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout>
Rect globalRect = new Rect(); Rect globalRect = new Rect();
private boolean skippingInterception = false; private boolean skippingInterception = false;
private final List<Integer> skipInterceptionOfElements = Arrays.asList( private final List<Integer> skipInterceptionOfElements = List.of(
R.id.detail_content_root_layout, R.id.relatedItemsLayout, R.id.detail_content_root_layout, R.id.relatedItemsLayout,
R.id.itemsListPanel, R.id.view_pager, R.id.tab_layout, R.id.bottomControls, R.id.itemsListPanel, R.id.view_pager, R.id.tab_layout, R.id.bottomControls,
R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton); R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton);
@ -57,7 +56,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout>
if (getState() == BottomSheetBehavior.STATE_EXPANDED if (getState() == BottomSheetBehavior.STATE_EXPANDED
&& event.getAction() == MotionEvent.ACTION_DOWN) { && event.getAction() == MotionEvent.ACTION_DOWN) {
// Without overriding scrolling will not work when user touches these elements // Without overriding scrolling will not work when user touches these elements
for (final Integer element : skipInterceptionOfElements) { for (final int element : skipInterceptionOfElements) {
final View view = child.findViewById(element); final View view = child.findViewById(element);
if (view != null) { if (view != null) {
final boolean visible = view.getGlobalVisibleRect(globalRect); final boolean visible = view.getGlobalVisibleRect(globalRect);

View File

@ -16,7 +16,7 @@ import org.schabi.newpipe.player.mediaitem.ExceptionTag;
import org.schabi.newpipe.player.playqueue.PlayQueueItem; import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -56,9 +56,7 @@ public class FailedMediaSource extends BaseMediaSource implements ManagedMediaSo
this.playQueueItem = playQueueItem; this.playQueueItem = playQueueItem;
this.error = error; this.error = error;
this.retryTimestamp = retryTimestamp; this.retryTimestamp = retryTimestamp;
this.mediaItem = ExceptionTag this.mediaItem = ExceptionTag.of(playQueueItem, List.of(error)).withExtras(this)
.of(playQueueItem, Collections.singletonList(error))
.withExtras(this)
.asMediaItem(); .asMediaItem();
} }

View File

@ -16,7 +16,6 @@ import org.schabi.newpipe.player.playqueue.events.SelectEvent;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -264,7 +263,7 @@ public abstract class PlayQueue implements Serializable {
* @param items {@link PlayQueueItem}s to append * @param items {@link PlayQueueItem}s to append
*/ */
public synchronized void append(@NonNull final PlayQueueItem... items) { public synchronized void append(@NonNull final PlayQueueItem... items) {
append(Arrays.asList(items)); append(List.of(items));
} }
/** /**

View File

@ -4,20 +4,19 @@ import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public final class SinglePlayQueue extends PlayQueue { public final class SinglePlayQueue extends PlayQueue {
public SinglePlayQueue(final StreamInfoItem item) { public SinglePlayQueue(final StreamInfoItem item) {
super(0, Collections.singletonList(new PlayQueueItem(item))); super(0, List.of(new PlayQueueItem(item)));
} }
public SinglePlayQueue(final StreamInfo info) { public SinglePlayQueue(final StreamInfo info) {
super(0, Collections.singletonList(new PlayQueueItem(info))); super(0, List.of(new PlayQueueItem(info)));
} }
public SinglePlayQueue(final StreamInfo info, final long startPosition) { public SinglePlayQueue(final StreamInfo info, final long startPosition) {
super(0, Collections.singletonList(new PlayQueueItem(info))); super(0, List.of(new PlayQueueItem(info)));
getItem().setRecoveryPosition(startPosition); getItem().setRecoveryPosition(startPosition);
} }

View File

@ -3,8 +3,6 @@ package org.schabi.newpipe.settings.preferencesearch;
import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -12,9 +10,9 @@ import java.util.stream.Stream;
public class PreferenceSearchConfiguration { public class PreferenceSearchConfiguration {
private PreferenceSearchFunction searcher = new PreferenceFuzzySearchFunction(); private PreferenceSearchFunction searcher = new PreferenceFuzzySearchFunction();
private final List<String> parserIgnoreElements = Collections.singletonList( private final List<String> parserIgnoreElements = List.of(PreferenceCategory.class
PreferenceCategory.class.getSimpleName()); .getSimpleName());
private final List<String> parserContainerElements = Arrays.asList( private final List<String> parserContainerElements = List.of(
PreferenceCategory.class.getSimpleName(), PreferenceCategory.class.getSimpleName(),
PreferenceScreen.class.getSimpleName()); PreferenceScreen.class.getSimpleName());

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.settings.preferencesearch;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.XmlRes; import androidx.annotation.XmlRes;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -92,11 +91,7 @@ public class PreferenceSearchItem {
} }
public List<String> getAllRelevantSearchFields() { public List<String> getAllRelevantSearchFields() {
return Arrays.asList( return List.of(getTitle(), getSummary(), getEntries(), getBreadcrumbs());
getTitle(),
getSummary(),
getEntries(),
getBreadcrumbs());
} }
@NonNull @NonNull

View File

@ -10,8 +10,6 @@ import com.grack.nanojson.JsonStringWriter;
import com.grack.nanojson.JsonWriter; import com.grack.nanojson.JsonWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -20,11 +18,9 @@ import java.util.List;
public final class TabsJsonHelper { public final class TabsJsonHelper {
private static final String JSON_TABS_ARRAY_KEY = "tabs"; private static final String JSON_TABS_ARRAY_KEY = "tabs";
private static final List<Tab> FALLBACK_INITIAL_TABS_LIST = Collections.unmodifiableList( private static final List<Tab> FALLBACK_INITIAL_TABS_LIST = List.of(
Arrays.asList( Tab.Type.DEFAULT_KIOSK.getTab(), Tab.Type.SUBSCRIPTIONS.getTab(),
Tab.Type.DEFAULT_KIOSK.getTab(), Tab.Type.BOOKMARKS.getTab());
Tab.Type.SUBSCRIPTIONS.getTab(),
Tab.Type.BOOKMARKS.getTab()));
private TabsJsonHelper() { } private TabsJsonHelper() { }

View File

@ -31,14 +31,14 @@ import java.util.stream.Collectors;
public final class ListHelper { public final class ListHelper {
// Video format in order of quality. 0=lowest quality, n=highest quality // Video format in order of quality. 0=lowest quality, n=highest quality
private static final List<MediaFormat> VIDEO_FORMAT_QUALITY_RANKING = private static final List<MediaFormat> VIDEO_FORMAT_QUALITY_RANKING =
Arrays.asList(MediaFormat.v3GPP, MediaFormat.WEBM, MediaFormat.MPEG_4); List.of(MediaFormat.v3GPP, MediaFormat.WEBM, MediaFormat.MPEG_4);
// Audio format in order of quality. 0=lowest quality, n=highest quality // Audio format in order of quality. 0=lowest quality, n=highest quality
private static final List<MediaFormat> AUDIO_FORMAT_QUALITY_RANKING = private static final List<MediaFormat> AUDIO_FORMAT_QUALITY_RANKING =
Arrays.asList(MediaFormat.MP3, MediaFormat.WEBMA, MediaFormat.M4A); List.of(MediaFormat.MP3, MediaFormat.WEBMA, MediaFormat.M4A);
// Audio format in order of efficiency. 0=most efficient, n=least efficient // Audio format in order of efficiency. 0=most efficient, n=least efficient
private static final List<MediaFormat> AUDIO_FORMAT_EFFICIENCY_RANKING = private static final List<MediaFormat> AUDIO_FORMAT_EFFICIENCY_RANKING =
Arrays.asList(MediaFormat.WEBMA, MediaFormat.M4A, MediaFormat.MP3); List.of(MediaFormat.WEBMA, MediaFormat.M4A, MediaFormat.MP3);
// Use a Set for better performance // Use a Set for better performance
private static final Set<String> HIGH_RESOLUTION_LIST = Set.of("1440p", "2160p"); private static final Set<String> HIGH_RESOLUTION_LIST = Set.of("1440p", "2160p");

View File

@ -17,7 +17,6 @@ import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance; import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public final class PeertubeHelper { public final class PeertubeHelper {
@ -29,7 +28,7 @@ public final class PeertubeHelper {
final String savedInstanceListKey = context.getString(R.string.peertube_instance_list_key); final String savedInstanceListKey = context.getString(R.string.peertube_instance_list_key);
final String savedJson = sharedPreferences.getString(savedInstanceListKey, null); final String savedJson = sharedPreferences.getString(savedInstanceListKey, null);
if (null == savedJson) { if (null == savedJson) {
return Collections.singletonList(getCurrentInstance()); return List.of(getCurrentInstance());
} }
try { try {
@ -45,9 +44,8 @@ public final class PeertubeHelper {
} }
return result; return result;
} catch (final JsonParserException e) { } catch (final JsonParserException e) {
return Collections.singletonList(getCurrentInstance()); return List.of(getCurrentInstance());
} }
} }
public static PeertubeInstance selectInstance(final PeertubeInstance instance, public static PeertubeInstance selectInstance(final PeertubeInstance instance,

View File

@ -153,7 +153,7 @@ public class PlayQueueTest {
@Test @Test
public void itemsAreNotCloned() { public void itemsAreNotCloned() {
final PlayQueueItem item = makeItemWithUrl("A url"); final PlayQueueItem item = makeItemWithUrl("A url");
final PlayQueue playQueue = makePlayQueue(0, Collections.singletonList(item)); final PlayQueue playQueue = makePlayQueue(0, List.of(item));
// make sure that items are not cloned when added to the queue // make sure that items are not cloned when added to the queue
assertSame(playQueue.getItem(), item); assertSame(playQueue.getItem(), item);

View File

@ -6,7 +6,6 @@ import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.extractor.stream.VideoStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -18,7 +17,7 @@ import androidx.annotation.Nullable;
public class ListHelperTest { public class ListHelperTest {
private static final String BEST_RESOLUTION_KEY = "best_resolution"; private static final String BEST_RESOLUTION_KEY = "best_resolution";
private static final List<AudioStream> AUDIO_STREAMS_TEST_LIST = Arrays.asList( private static final List<AudioStream> AUDIO_STREAMS_TEST_LIST = List.of(
generateAudioStream("m4a-128-1", MediaFormat.M4A, 128), generateAudioStream("m4a-128-1", MediaFormat.M4A, 128),
generateAudioStream("webma-192", MediaFormat.WEBMA, 192), generateAudioStream("webma-192", MediaFormat.WEBMA, 192),
generateAudioStream("mp3-64", MediaFormat.MP3, 64), generateAudioStream("mp3-64", MediaFormat.MP3, 64),
@ -30,7 +29,7 @@ public class ListHelperTest {
generateAudioStream("mp3-192", MediaFormat.MP3, 192), generateAudioStream("mp3-192", MediaFormat.MP3, 192),
generateAudioStream("webma-320", MediaFormat.WEBMA, 320)); generateAudioStream("webma-320", MediaFormat.WEBMA, 320));
private static final List<VideoStream> VIDEO_STREAMS_TEST_LIST = Arrays.asList( private static final List<VideoStream> VIDEO_STREAMS_TEST_LIST = List.of(
generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false), generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false),
generateVideoStream("v3gpp-240", MediaFormat.v3GPP, "240p", false), generateVideoStream("v3gpp-240", MediaFormat.v3GPP, "240p", false),
generateVideoStream("webm-480", MediaFormat.WEBM, "480p", false), generateVideoStream("webm-480", MediaFormat.WEBM, "480p", false),
@ -38,7 +37,7 @@ public class ListHelperTest {
generateVideoStream("mpeg_4-360", MediaFormat.MPEG_4, "360p", false), generateVideoStream("mpeg_4-360", MediaFormat.MPEG_4, "360p", false),
generateVideoStream("webm-360", MediaFormat.WEBM, "360p", false)); generateVideoStream("webm-360", MediaFormat.WEBM, "360p", false));
private static final List<VideoStream> VIDEO_ONLY_STREAMS_TEST_LIST = Arrays.asList( private static final List<VideoStream> VIDEO_ONLY_STREAMS_TEST_LIST = List.of(
generateVideoStream("mpeg_4-720-1", MediaFormat.MPEG_4, "720p", true), generateVideoStream("mpeg_4-720-1", MediaFormat.MPEG_4, "720p", true),
generateVideoStream("mpeg_4-720-2", MediaFormat.MPEG_4, "720p", true), generateVideoStream("mpeg_4-720-2", MediaFormat.MPEG_4, "720p", true),
generateVideoStream("mpeg_4-2160", MediaFormat.MPEG_4, "2160p", true), generateVideoStream("mpeg_4-2160", MediaFormat.MPEG_4, "2160p", true),
@ -54,7 +53,7 @@ public class ListHelperTest {
List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true,
VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, true, false); VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, true, false);
List<String> expected = Arrays.asList("144p", "240p", "360p", "480p", "720p", "720p60", List<String> expected = List.of("144p", "240p", "360p", "480p", "720p", "720p60",
"1080p", "1080p60", "1440p60", "2160p", "2160p60"); "1080p", "1080p60", "1440p60", "2160p", "2160p60");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
@ -69,7 +68,7 @@ public class ListHelperTest {
result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true,
VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, false, false); VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, false, false);
expected = Arrays.asList("2160p60", "2160p", "1440p60", "1080p60", "1080p", "720p60", expected = List.of("2160p60", "2160p", "1440p60", "1080p60", "1080p", "720p60",
"720p", "480p", "360p", "240p", "144p"); "720p", "480p", "360p", "240p", "144p");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
@ -83,7 +82,7 @@ public class ListHelperTest {
null, VIDEO_ONLY_STREAMS_TEST_LIST, true, true); null, VIDEO_ONLY_STREAMS_TEST_LIST, true, true);
List<String> expected = List<String> expected =
Arrays.asList("720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60"); List.of("720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
@ -97,7 +96,7 @@ public class ListHelperTest {
result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true,
VIDEO_STREAMS_TEST_LIST, null, false, true); VIDEO_STREAMS_TEST_LIST, null, false, true);
expected = Arrays.asList("720p", "480p", "360p", "240p", "144p"); expected = List.of("720p", "480p", "360p", "240p", "144p");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
assertEquals(expected.get(i), result.get(i).getResolution()); assertEquals(expected.get(i), result.get(i).getResolution());
@ -110,10 +109,10 @@ public class ListHelperTest {
result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true,
VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, true, true); VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, true, true);
expected = Arrays.asList("144p", "240p", "360p", "480p", "720p", "720p60", expected = List.of("144p", "240p", "360p", "480p", "720p", "720p60",
"1080p", "1080p60", "1440p60", "2160p", "2160p60"); "1080p", "1080p60", "1440p60", "2160p", "2160p60");
final List<String> expectedVideoOnly = final List<String> expectedVideoOnly =
Arrays.asList("720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60"); List.of("720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
@ -131,7 +130,7 @@ public class ListHelperTest {
final List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, final List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4,
false, VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, false, false); false, VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, false, false);
final List<String> expected = Arrays.asList( final List<String> expected = List.of(
"1080p60", "1080p", "720p60", "720p", "480p", "360p", "240p", "144p"); "1080p60", "1080p", "720p60", "720p", "480p", "360p", "240p", "144p");
assertEquals(expected.size(), result.size()); assertEquals(expected.size(), result.size());
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
@ -141,7 +140,7 @@ public class ListHelperTest {
@Test @Test
public void getDefaultResolutionTest() { public void getDefaultResolutionTest() {
final List<VideoStream> testList = Arrays.asList( final List<VideoStream> testList = List.of(
generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false), generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false),
generateVideoStream("v3gpp-240", MediaFormat.v3GPP, "240p", false), generateVideoStream("v3gpp-240", MediaFormat.v3GPP, "240p", false),
generateVideoStream("webm-480", MediaFormat.WEBM, "480p", false), generateVideoStream("webm-480", MediaFormat.WEBM, "480p", false),
@ -223,7 +222,7 @@ public class ListHelperTest {
// Doesn't contain the preferred format // // Doesn't contain the preferred format //
//////////////////////////////////////// ////////////////////////////////////////
List<AudioStream> testList = Arrays.asList( List<AudioStream> testList = List.of(
generateAudioStream("m4a-128", MediaFormat.M4A, 128), generateAudioStream("m4a-128", MediaFormat.M4A, 128),
generateAudioStream("webma-192", MediaFormat.WEBMA, 192)); generateAudioStream("webma-192", MediaFormat.WEBMA, 192));
// List doesn't contains this format // List doesn't contains this format
@ -237,7 +236,7 @@ public class ListHelperTest {
// Multiple not-preferred-formats and equal bitrates // // Multiple not-preferred-formats and equal bitrates //
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
testList = new ArrayList<>(Arrays.asList( testList = new ArrayList<>(List.of(
generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192), generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192),
generateAudioStream("m4a-192-1", MediaFormat.M4A, 192), generateAudioStream("m4a-192-1", MediaFormat.M4A, 192),
generateAudioStream("webma-192-2", MediaFormat.WEBMA, 192), generateAudioStream("webma-192-2", MediaFormat.WEBMA, 192),
@ -290,7 +289,7 @@ public class ListHelperTest {
// Doesn't contain the preferred format // // Doesn't contain the preferred format //
//////////////////////////////////////// ////////////////////////////////////////
List<AudioStream> testList = new ArrayList<>(Arrays.asList( List<AudioStream> testList = new ArrayList<>(List.of(
generateAudioStream("m4a-128", MediaFormat.M4A, 128), generateAudioStream("m4a-128", MediaFormat.M4A, 128),
generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192))); generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192)));
// List doesn't contains this format // List doesn't contains this format
@ -310,7 +309,7 @@ public class ListHelperTest {
// Multiple not-preferred-formats and equal bitrates // // Multiple not-preferred-formats and equal bitrates //
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
testList = new ArrayList<>(Arrays.asList( testList = new ArrayList<>(List.of(
generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192), generateAudioStream("webma-192-1", MediaFormat.WEBMA, 192),
generateAudioStream("m4a-192-1", MediaFormat.M4A, 192), generateAudioStream("m4a-192-1", MediaFormat.M4A, 192),
generateAudioStream("webma-256", MediaFormat.WEBMA, 256), generateAudioStream("webma-256", MediaFormat.WEBMA, 256),
@ -337,7 +336,7 @@ public class ListHelperTest {
@Test @Test
public void getVideoDefaultStreamIndexCombinations() { public void getVideoDefaultStreamIndexCombinations() {
final List<VideoStream> testList = Arrays.asList( final List<VideoStream> testList = List.of(
generateVideoStream("mpeg_4-1080", MediaFormat.MPEG_4, "1080p", false), generateVideoStream("mpeg_4-1080", MediaFormat.MPEG_4, "1080p", false),
generateVideoStream("mpeg_4-720_60", MediaFormat.MPEG_4, "720p60", false), generateVideoStream("mpeg_4-720_60", MediaFormat.MPEG_4, "720p60", false),
generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false), generateVideoStream("mpeg_4-720", MediaFormat.MPEG_4, "720p", false),