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 com.google.android.material.bottomsheet.BottomSheetBehavior;
import org.schabi.newpipe.R;
import java.util.Arrays;
import java.util.List;
public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout> {
@ -25,7 +24,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout>
Rect globalRect = new Rect();
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.itemsListPanel, R.id.view_pager, R.id.tab_layout, R.id.bottomControls,
R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton);
@ -57,7 +56,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior<FrameLayout>
if (getState() == BottomSheetBehavior.STATE_EXPANDED
&& event.getAction() == MotionEvent.ACTION_DOWN) {
// 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);
if (view != null) {
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 java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import androidx.annotation.NonNull;
@ -56,9 +56,7 @@ public class FailedMediaSource extends BaseMediaSource implements ManagedMediaSo
this.playQueueItem = playQueueItem;
this.error = error;
this.retryTimestamp = retryTimestamp;
this.mediaItem = ExceptionTag
.of(playQueueItem, Collections.singletonList(error))
.withExtras(this)
this.mediaItem = ExceptionTag.of(playQueueItem, List.of(error)).withExtras(this)
.asMediaItem();
}

View file

@ -16,7 +16,6 @@ import org.schabi.newpipe.player.playqueue.events.SelectEvent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@ -264,7 +263,7 @@ public abstract class PlayQueue implements Serializable {
* @param items {@link PlayQueueItem}s to append
*/
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 java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public final class SinglePlayQueue extends PlayQueue {
public SinglePlayQueue(final StreamInfoItem item) {
super(0, Collections.singletonList(new PlayQueueItem(item)));
super(0, List.of(new PlayQueueItem(item)));
}
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) {
super(0, Collections.singletonList(new PlayQueueItem(info)));
super(0, List.of(new PlayQueueItem(info)));
getItem().setRecoveryPosition(startPosition);
}