Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'checkstyle'

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.2'

defaultConfig {
applicationId "org.schabi.newpipe"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.io.InterruptedIOException;
import java.net.SocketException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import io.reactivex.rxjava3.disposables.Disposable;
Expand Down Expand Up @@ -154,7 +153,7 @@ public void accept(@NonNull final Throwable throwable) {
if (actualThrowable instanceof CompositeException) {
errors = ((CompositeException) actualThrowable).getExceptions();
} else {
errors = Collections.singletonList(actualThrowable);
errors = List.of(actualThrowable);
}

for (final Throwable error : errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

Expand Down Expand Up @@ -594,7 +593,7 @@ private void showFailedDialog(@StringRes final int msg) {
private void showErrorActivity(final Exception e) {
ErrorActivity.reportError(
context,
Collections.singletonList(e),
List.of(e),
null,
null,
ErrorInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.InfoCache;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -253,8 +252,7 @@ public void onReCaptchaException(final ReCaptchaException exception) {
public void onUnrecoverableError(final Throwable exception, final UserAction userAction,
final String serviceName, final String request,
@StringRes final int errorId) {
onUnrecoverableError(Collections.singletonList(exception), userAction, serviceName,
request, errorId);
onUnrecoverableError(List.of(exception), userAction, serviceName, request, errorId);
}

public void onUnrecoverableError(final List<Throwable> exception, final UserAction userAction,
Expand All @@ -272,8 +270,7 @@ public void onUnrecoverableError(final List<Throwable> exception, final UserActi
public void showSnackBarError(final Throwable exception, final UserAction userAction,
final String serviceName, final String request,
@StringRes final int errorId) {
showSnackBarError(Collections.singletonList(exception), userAction, serviceName, request,
errorId);
showSnackBarError(List.of(exception), userAction, serviceName, request, errorId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.schabi.newpipe.util.OnClickGesture;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -59,7 +58,7 @@ public static Disposable onPlaylistFound(

public static PlaylistAppendDialog fromStreamInfo(final StreamInfo info) {
final PlaylistAppendDialog dialog = new PlaylistAppendDialog();
dialog.setInfo(Collections.singletonList(new StreamEntity(info)));
dialog.setInfo(List.of(new StreamEntity(info)));
return dialog;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private PlayQueue getPlayQueue() {

private PlayQueue getPlayQueue(final int index) {
if (itemListAdapter == null) {
return new SinglePlayQueue(Collections.emptyList(), 0);
return new SinglePlayQueue(List.of(), 0);
}

final List<LocalItem> infoItems = itemListAdapter.getItemsList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ private PlayQueue getPlayQueue() {

private PlayQueue getPlayQueue(final int index) {
if (itemListAdapter == null) {
return new SinglePlayQueue(Collections.emptyList(), 0);
return new SinglePlayQueue(List.of(), 0);
}

final List<LocalItem> infoItems = itemListAdapter.getItemsList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.schabi.newpipe.util.FilePickerActivityHelper;
import org.schabi.newpipe.util.ServiceHelper;

import java.util.Collections;
import java.util.List;

import icepick.State;
Expand Down Expand Up @@ -84,7 +83,7 @@ public void onCreate(final Bundle savedInstanceState) {

setupServiceVariables();
if (supportedSources.isEmpty() && currentServiceId != Constants.NO_SERVICE_ID) {
ErrorActivity.reportError(activity, Collections.emptyList(), null, null,
ErrorActivity.reportError(activity, List.of(), null, null,
ErrorInfo.make(UserAction.SOMETHING_ELSE,
NewPipe.getNameOfService(currentServiceId),
"Service don't support importing", R.string.general_error));
Expand Down Expand Up @@ -211,7 +210,7 @@ private void setupServiceVariables() {
}
}

supportedSources = Collections.emptyList();
supportedSources = List.of();
relatedUrl = null;
instructionsString = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.schabi.newpipe.report.UserAction;

import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -157,8 +157,8 @@ protected void stopAndReportError(@Nullable final Throwable error, final String

final ErrorInfo errorInfo = ErrorInfo
.make(UserAction.SUBSCRIPTION, "unknown", request, R.string.general_error);
ErrorActivity.reportError(this, error != null ? Collections.singletonList(error)
: Collections.emptyList(), null, null, errorInfo);
ErrorActivity.reportError(this, error != null ? List.of(error) : List.of(),
null, null, errorInfo);
}

protected void postErrorResult(final String title, final String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ThemeHelper;

import java.util.Collections;
import java.util.List;

import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
Expand Down Expand Up @@ -305,7 +304,7 @@ private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
final MenuItem append = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 2,
Menu.NONE, R.string.append_playlist);
append.setOnMenuItemClickListener(menuItem -> {
openPlaylistAppendDialog(Collections.singletonList(item));
openPlaylistAppendDialog(List.of(item));
return true;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.google.android.exoplayer2.util.Util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static android.support.v4.media.session.PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void onSkipToNext(final Player player, final ControlDispatcher controlDis

private void publishFloatingQueueWindow() {
if (callback.getQueueSize() == 0) {
mediaSession.setQueue(Collections.emptyList());
mediaSession.setQueue(List.of());
activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.schabi.newpipe.extractor.stream.StreamInfoItem;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import io.reactivex.rxjava3.core.SingleObserver;
Expand All @@ -28,7 +27,7 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
private transient Disposable fetchReactor;

AbstractInfoPlayQueue(final U item) {
this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0);
this(item.getServiceId(), item.getUrl(), null, List.of(), 0);
}

AbstractInfoPlayQueue(final int serviceId, final String url, final Page nextPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.schabi.newpipe.extractor.stream.VideoStream;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

public class MediaSourceTag implements Serializable {
Expand All @@ -27,7 +26,7 @@ public MediaSourceTag(@NonNull final StreamInfo metadata,
}

public MediaSourceTag(@NonNull final StreamInfo metadata) {
this(metadata, Collections.emptyList(), /*indexNotAvailable=*/-1);
this(metadata, List.of(), /*indexNotAvailable=*/-1);
}

@NonNull
Expand Down
16 changes: 2 additions & 14 deletions app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.Vector;

import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;

Expand Down Expand Up @@ -118,25 +117,14 @@ private static void startErrorActivity(final Class returnActivity, final Context
public static void reportError(final Context context, final Throwable e,
final Class returnActivity, final View rootView,
final ErrorInfo errorInfo) {
List<Throwable> el = null;
if (e != null) {
el = new Vector<>();
el.add(e);
}
reportError(context, el, returnActivity, rootView, errorInfo);
reportError(context, List.of(e), returnActivity, rootView, errorInfo);
}

// async call
public static void reportError(final Handler handler, final Context context,
final Throwable e, final Class returnActivity,
final View rootView, final ErrorInfo errorInfo) {

List<Throwable> el = null;
if (e != null) {
el = new Vector<>();
el.add(e);
}
reportError(handler, context, el, returnActivity, rootView, errorInfo);
reportError(handler, context, List.of(e), returnActivity, rootView, errorInfo);
}

// async call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import org.schabi.newpipe.report.ErrorInfo;
import org.schabi.newpipe.report.UserAction;

import java.util.Collections;
import java.util.List;

import io.reactivex.rxjava3.core.Maybe;
Expand Down Expand Up @@ -115,9 +114,7 @@ public static Single<List<String>> suggestionsFor(final int serviceId, final Str
return Single.fromCallable(() -> {
final SuggestionExtractor extractor = NewPipe.getService(serviceId)
.getSuggestionExtractor();
return extractor != null
? extractor.suggestionList(query)
: Collections.emptyList();
return extractor != null ? extractor.suggestionList(query) : List.of();
});
}

Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class PeertubeHelper {
Expand All @@ -29,7 +28,7 @@ public static List<PeertubeInstance> getInstanceList(final Context context) {
final String savedInstanceListKey = context.getString(R.string.peertube_instance_list_key);
final String savedJson = sharedPreferences.getString(savedInstanceListKey, null);
if (null == savedJson) {
return Collections.singletonList(getCurrentInstance());
return List.of(getCurrentInstance());
}

try {
Expand All @@ -45,9 +44,8 @@ public static List<PeertubeInstance> getInstanceList(final Context context) {
}
return result;
} catch (final JsonParserException e) {
return Collections.singletonList(getCurrentInstance());
return List.of(getCurrentInstance());
}

}

public static PeertubeInstance selectInstance(final PeertubeInstance instance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.schabi.newpipe.extractor.stream.StreamInfo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RelatedStreamInfo extends ListInfo<InfoItem> {
Expand All @@ -17,7 +16,7 @@ public RelatedStreamInfo(final int serviceId, final ListLinkHandler listUrlIdHan

public static RelatedStreamInfo getInfo(final StreamInfo info) {
final ListLinkHandler handler = new ListLinkHandler(
info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null);
info.getOriginalUrl(), info.getUrl(), info.getId(), List.of(), null);
final RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo(
info.getServiceId(), handler, info.getName());
final List<InfoItem> streams = new ArrayList<>(info.getRelatedStreams());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.schabi.newpipe.player.helper.PlayerHolder;
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;

import java.util.Collections;
import java.util.List;

import static org.schabi.newpipe.player.MainPlayer.PlayerType.AUDIO;
Expand Down Expand Up @@ -60,8 +59,7 @@ public enum StreamDialogEntry {

append_playlist(R.string.append_playlist, (fragment, item) -> {
if (fragment.getFragmentManager() != null) {
final PlaylistAppendDialog d = PlaylistAppendDialog
.fromStreamInfoItems(Collections.singletonList(item));
final PlaylistAppendDialog d = PlaylistAppendDialog.fromStreamInfoItems(List.of(item));

PlaylistAppendDialog.onPlaylistFound(fragment.getContext(),
() -> d.show(fragment.getFragmentManager(), "StreamDialogEntry@append_playlist"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -178,15 +177,13 @@ private View getCustomView(final int position, final View view, final ViewGroup
*/
public static class StreamSizeWrapper<T extends Stream> implements Serializable {
private static final StreamSizeWrapper<Stream> EMPTY = new StreamSizeWrapper<>(
Collections.emptyList(), null);
List.of(), null);
private final List<T> streamsList;
private final long[] streamSizes;
private final String unknownSize;

public StreamSizeWrapper(final List<T> sL, final Context context) {
this.streamsList = sL != null
? sL
: Collections.emptyList();
this.streamsList = sL != null ? sL : List.of();
this.streamSizes = new long[streamsList.size()];
this.unknownSize = context == null
? "--.-" : context.getString(R.string.unknown_content);
Expand Down