From 62abfa96b82d4b197d55c0eabe5da0d1b3b33516 Mon Sep 17 00:00:00 2001
From: Stypox
Date: Sat, 19 Feb 2022 16:53:37 +0100
Subject: [PATCH 1/3] Solve Java warning "Raw use of parameterized class"
---
.../fragments/list/BaseListFragment.java | 4 +-
.../fragments/list/BaseListInfoFragment.java | 19 +++++-----
.../list/channel/ChannelFragment.java | 4 +-
.../list/comments/CommentsFragment.java | 5 ++-
.../fragments/list/kiosk/KioskFragment.java | 5 ++-
.../list/playlist/PlaylistFragment.java | 4 +-
.../list/videos/RelatedItemsFragment.java | 5 ++-
.../services/ImportExportJsonHelper.java | 6 +--
.../playqueue/AbstractInfoPlayQueue.java | 18 ++++-----
.../org/schabi/newpipe/settings/tabs/Tab.java | 12 +++---
.../schabi/newpipe/util/ExtractorHelper.java | 37 +++++++++++--------
.../schabi/newpipe/util/SerializedCache.java | 6 +--
.../newpipe/util/StreamItemAdapter.java | 16 +++-----
13 files changed, 74 insertions(+), 67 deletions(-)
diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java
index 6ea0a8a0d..987d8c21f 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java
@@ -272,7 +272,7 @@ public abstract class BaseListFragment extends BaseStateFragment
}
});
- infoListAdapter.setOnChannelSelectedListener(new OnClickGesture() {
+ infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<>() {
@Override
public void selected(final ChannelInfoItem selectedItem) {
try {
@@ -288,7 +288,7 @@ public abstract class BaseListFragment extends BaseStateFragment
}
});
- infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture() {
+ infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture<>() {
@Override
public void selected(final PlaylistInfoItem selectedItem) {
try {
diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java
index ebd586e35..35424437d 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.UserAction;
+import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.Page;
@@ -27,8 +28,8 @@ import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
-public abstract class BaseListInfoFragment
- extends BaseListFragment {
+public abstract class BaseListInfoFragment>
+ extends BaseListFragment> {
@State
protected int serviceId = Constants.NO_SERVICE_ID;
@State
@@ -37,7 +38,7 @@ public abstract class BaseListInfoFragment
protected String url;
private final UserAction errorUserAction;
- protected I currentInfo;
+ protected L currentInfo;
protected Page currentNextPage;
protected Disposable currentWorker;
@@ -97,7 +98,7 @@ public abstract class BaseListInfoFragment
@SuppressWarnings("unchecked")
public void readFrom(@NonNull final Queue
*/
-public class KioskFragment extends BaseListInfoFragment {
+public class KioskFragment extends BaseListInfoFragment {
@State
String kioskId = "";
String kioskTranslatedName;
@@ -145,7 +146,7 @@ public class KioskFragment extends BaseListInfoFragment {
}
@Override
- public Single loadMoreItemsLogic() {
+ public Single> loadMoreItemsLogic() {
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextPage);
}
diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
index 84dcb4fd9..31aaf988d 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
@@ -64,7 +64,7 @@ import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.disposables.Disposable;
-public class PlaylistFragment extends BaseListInfoFragment {
+public class PlaylistFragment extends BaseListInfoFragment {
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
@@ -249,7 +249,7 @@ public class PlaylistFragment extends BaseListInfoFragment {
//////////////////////////////////////////////////////////////////////////*/
@Override
- protected Single loadMoreItemsLogic() {
+ protected Single> loadMoreItemsLogic() {
return ExtractorHelper.getMorePlaylistItems(serviceId, url, currentNextPage);
}
diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java
index 7ba6aa2ab..f0ece69f3 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java
@@ -15,6 +15,7 @@ import androidx.preference.PreferenceManager;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.RelatedItemsHeaderBinding;
import org.schabi.newpipe.error.UserAction;
+import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@@ -26,7 +27,7 @@ import java.util.function.Supplier;
import io.reactivex.rxjava3.core.Single;
-public class RelatedItemsFragment extends BaseListInfoFragment
+public class RelatedItemsFragment extends BaseListInfoFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String INFO_KEY = "related_info_key";
@@ -86,7 +87,7 @@ public class RelatedItemsFragment extends BaseListInfoFragment
}
@Override
- protected Single loadMoreItemsLogic() {
+ protected Single> loadMoreItemsLogic() {
return Single.fromCallable(ListExtractor.InfoItemsPage::emptyPage);
}
diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelper.java b/app/src/main/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelper.java
index 8e3aad893..611a1cd30 100644
--- a/app/src/main/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelper.java
@@ -25,7 +25,6 @@ import com.grack.nanojson.JsonAppendableWriter;
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
-import com.grack.nanojson.JsonSink;
import com.grack.nanojson.JsonWriter;
import org.schabi.newpipe.BuildConfig;
@@ -125,10 +124,11 @@ public final class ImportExportJsonHelper {
/**
* @see #writeTo(List, OutputStream, ImportExportEventListener)
* @param items the list of subscriptions items
- * @param writer the output {@link JsonSink}
+ * @param writer the output {@link JsonAppendableWriter}
* @param eventListener listener for the events generated
*/
- public static void writeTo(final List items, final JsonSink writer,
+ public static void writeTo(final List items,
+ final JsonAppendableWriter writer,
@Nullable final ImportExportEventListener eventListener) {
if (eventListener != null) {
eventListener.onSizeReceived(items.size());
diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
index 07c8d9f90..72c8d1850 100644
--- a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
+++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
@@ -17,7 +17,8 @@ import java.util.List;
import io.reactivex.rxjava3.core.SingleObserver;
import io.reactivex.rxjava3.disposables.Disposable;
-abstract class AbstractInfoPlayQueue extends PlayQueue {
+abstract class AbstractInfoPlayQueue, U extends InfoItem>
+ extends PlayQueue {
boolean isInitial;
private boolean isComplete;
@@ -51,7 +52,7 @@ abstract class AbstractInfoPlayQueue ext
}
SingleObserver getHeadListObserver() {
- return new SingleObserver() {
+ return new SingleObserver<>() {
@Override
public void onSubscribe(@NonNull final Disposable d) {
if (isComplete || !isInitial || (fetchReactor != null
@@ -85,8 +86,8 @@ abstract class AbstractInfoPlayQueue ext
};
}
- SingleObserver getNextPageObserver() {
- return new SingleObserver() {
+ SingleObserver> getNextPageObserver() {
+ return new SingleObserver<>() {
@Override
public void onSubscribe(@NonNull final Disposable d) {
if (isComplete || isInitial || (fetchReactor != null
@@ -98,7 +99,8 @@ abstract class AbstractInfoPlayQueue ext
}
@Override
- public void onSuccess(@NonNull final ListExtractor.InfoItemsPage result) {
+ public void onSuccess(
+ @NonNull final ListExtractor.InfoItemsPage result) {
if (!result.hasNextPage()) {
isComplete = true;
}
@@ -130,10 +132,8 @@ abstract class AbstractInfoPlayQueue ext
private static List extractListItems(final List infoItems) {
final List result = new ArrayList<>();
- for (final InfoItem stream : infoItems) {
- if (stream instanceof StreamInfoItem) {
- result.add(new PlayQueueItem((StreamInfoItem) stream));
- }
+ for (final StreamInfoItem stream : infoItems) {
+ result.add(new PlayQueueItem(stream));
}
return result;
}
diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
index aa03bbfa6..cfe618f3e 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
@@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.grack.nanojson.JsonObject;
-import com.grack.nanojson.JsonSink;
+import com.grack.nanojson.JsonStringWriter;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.LocalItem.LocalItemType;
@@ -132,7 +132,7 @@ public abstract class Tab {
// JSON Handling
//////////////////////////////////////////////////////////////////////////*/
- public void writeJsonOn(final JsonSink jsonSink) {
+ public void writeJsonOn(final JsonStringWriter jsonSink) {
jsonSink.object();
jsonSink.value(JSON_TAB_ID_KEY, getTabId());
@@ -141,7 +141,7 @@ public abstract class Tab {
jsonSink.end();
}
- protected void writeDataToJson(final JsonSink writerSink) {
+ protected void writeDataToJson(final JsonStringWriter writerSink) {
// No-op
}
@@ -355,7 +355,7 @@ public abstract class Tab {
}
@Override
- protected void writeDataToJson(final JsonSink writerSink) {
+ protected void writeDataToJson(final JsonStringWriter writerSink) {
writerSink.value(JSON_KIOSK_SERVICE_ID_KEY, kioskServiceId)
.value(JSON_KIOSK_ID_KEY, kioskId);
}
@@ -437,7 +437,7 @@ public abstract class Tab {
}
@Override
- protected void writeDataToJson(final JsonSink writerSink) {
+ protected void writeDataToJson(final JsonStringWriter writerSink) {
writerSink.value(JSON_CHANNEL_SERVICE_ID_KEY, channelServiceId)
.value(JSON_CHANNEL_URL_KEY, channelUrl)
.value(JSON_CHANNEL_NAME_KEY, channelName);
@@ -584,7 +584,7 @@ public abstract class Tab {
}
@Override
- protected void writeDataToJson(final JsonSink writerSink) {
+ protected void writeDataToJson(final JsonStringWriter writerSink) {
writerSink.value(JSON_PLAYLIST_SERVICE_ID_KEY, playlistServiceId)
.value(JSON_PLAYLIST_URL_KEY, playlistUrl)
.value(JSON_PLAYLIST_NAME_KEY, playlistName)
diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java
index af94e3366..db7da48f7 100644
--- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java
@@ -30,6 +30,7 @@ import androidx.preference.PreferenceManager;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
+import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
import org.schabi.newpipe.util.external_communication.TextLinkifier;
import org.schabi.newpipe.extractor.Info;
import org.schabi.newpipe.extractor.InfoItem;
@@ -84,11 +85,12 @@ public final class ExtractorHelper {
.fromQuery(searchString, contentFilter, sortFilter)));
}
- public static Single getMoreSearchItems(final int serviceId,
- final String searchString,
- final List contentFilter,
- final String sortFilter,
- final Page page) {
+ public static Single> getMoreSearchItems(
+ final int serviceId,
+ final String searchString,
+ final List contentFilter,
+ final String sortFilter,
+ final Page page) {
checkServiceId(serviceId);
return Single.fromCallable(() ->
SearchInfo.getMoreItems(NewPipe.getService(serviceId),
@@ -124,8 +126,9 @@ public final class ExtractorHelper {
ChannelInfo.getInfo(NewPipe.getService(serviceId), url)));
}
- public static Single getMoreChannelItems(final int serviceId, final String url,
- final Page nextPage) {
+ public static Single> getMoreChannelItems(final int serviceId,
+ final String url,
+ final Page nextPage) {
checkServiceId(serviceId);
return Single.fromCallable(() ->
ChannelInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
@@ -155,15 +158,17 @@ public final class ExtractorHelper {
CommentsInfo.getInfo(NewPipe.getService(serviceId), url)));
}
- public static Single getMoreCommentItems(final int serviceId,
- final CommentsInfo info,
- final Page nextPage) {
+ public static Single> getMoreCommentItems(
+ final int serviceId,
+ final CommentsInfo info,
+ final Page nextPage) {
checkServiceId(serviceId);
return Single.fromCallable(() ->
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
}
- public static Single getPlaylistInfo(final int serviceId, final String url,
+ public static Single getPlaylistInfo(final int serviceId,
+ final String url,
final boolean forceLoad) {
checkServiceId(serviceId);
return checkCache(forceLoad, serviceId, url, InfoItem.InfoType.PLAYLIST,
@@ -171,8 +176,9 @@ public final class ExtractorHelper {
PlaylistInfo.getInfo(NewPipe.getService(serviceId), url)));
}
- public static Single getMorePlaylistItems(final int serviceId, final String url,
- final Page nextPage) {
+ public static Single> getMorePlaylistItems(final int serviceId,
+ final String url,
+ final Page nextPage) {
checkServiceId(serviceId);
return Single.fromCallable(() ->
PlaylistInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
@@ -184,8 +190,9 @@ public final class ExtractorHelper {
Single.fromCallable(() -> KioskInfo.getInfo(NewPipe.getService(serviceId), url)));
}
- public static Single getMoreKioskItems(final int serviceId, final String url,
- final Page nextPage) {
+ public static Single> getMoreKioskItems(final int serviceId,
+ final String url,
+ final Page nextPage) {
return Single.fromCallable(() ->
KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
}
diff --git a/app/src/main/java/org/schabi/newpipe/util/SerializedCache.java b/app/src/main/java/org/schabi/newpipe/util/SerializedCache.java
index 9d97e013a..b4c196ce4 100644
--- a/app/src/main/java/org/schabi/newpipe/util/SerializedCache.java
+++ b/app/src/main/java/org/schabi/newpipe/util/SerializedCache.java
@@ -19,7 +19,7 @@ public final class SerializedCache {
private static final boolean DEBUG = MainActivity.DEBUG;
private static final SerializedCache INSTANCE = new SerializedCache();
private static final int MAX_ITEMS_ON_CACHE = 5;
- private static final LruCache LRU_CACHE =
+ private static final LruCache> LRU_CACHE =
new LruCache<>(MAX_ITEMS_ON_CACHE);
private static final String TAG = "SerializedCache";
@@ -47,7 +47,7 @@ public final class SerializedCache {
Log.d(TAG, "get() called with: key = [" + key + "]");
}
synchronized (LRU_CACHE) {
- final CacheData data = LRU_CACHE.get(key);
+ final CacheData> data = LRU_CACHE.get(key);
return data != null ? getItem(data, type) : null;
}
}
@@ -91,7 +91,7 @@ public final class SerializedCache {
}
@Nullable
- private T getItem(@NonNull final CacheData data, @NonNull final Class type) {
+ private T getItem(@NonNull final CacheData> data, @NonNull final Class type) {
return type.isAssignableFrom(data.type) ? type.cast(data.item) : null;
}
diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java b/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java
index 9150b5c1a..c89da9d45 100644
--- a/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java
+++ b/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java
@@ -12,6 +12,7 @@ import android.widget.TextView;
import org.schabi.newpipe.DownloaderImpl;
import org.schabi.newpipe.R;
+import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.Stream;
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
@@ -137,7 +138,7 @@ public class StreamItemAdapter extends BaseA
}
if (streamsWrapper.getSizeInBytes(position) > 0) {
- final SecondaryStreamHelper secondary = secondaryStreams == null ? null
+ final SecondaryStreamHelper secondary = secondaryStreams == null ? null
: secondaryStreams.get(position);
if (secondary != null) {
final long size
@@ -153,16 +154,11 @@ public class StreamItemAdapter extends BaseA
if (stream instanceof SubtitlesStream) {
formatNameView.setText(((SubtitlesStream) stream).getLanguageTag());
+ } else if (stream.getFormat() == MediaFormat.WEBMA_OPUS) {
+ // noinspection AndroidLintSetTextI18n
+ formatNameView.setText("opus");
} else {
- switch (stream.getFormat()) {
- case WEBMA_OPUS:
- // noinspection AndroidLintSetTextI18n
- formatNameView.setText("opus");
- break;
- default:
- formatNameView.setText(stream.getFormat().getName());
- break;
- }
+ formatNameView.setText(stream.getFormat().getName());
}
qualityView.setText(qualityString);
From 5f1f52b6ceb1e8d3f7a540faaa40d5b1dc5cd45e Mon Sep 17 00:00:00 2001
From: Stypox
Date: Sat, 19 Feb 2022 17:49:43 +0100
Subject: [PATCH 2/3] Remove useless constructor in *PlayQueue
Also removes unused <> parameter in AbstractInfoPlayQueue and deduplicates constructor code in extending classes
---
.../player/playqueue/AbstractInfoPlayQueue.java | 15 ++++++++-------
.../player/playqueue/ChannelPlayQueue.java | 8 ++------
.../player/playqueue/PlaylistPlayQueue.java | 8 ++------
3 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
index 72c8d1850..dc1c960cb 100644
--- a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
+++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
@@ -4,20 +4,18 @@ import android.util.Log;
import androidx.annotation.NonNull;
-import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.Page;
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;
import io.reactivex.rxjava3.disposables.Disposable;
-abstract class AbstractInfoPlayQueue, U extends InfoItem>
+abstract class AbstractInfoPlayQueue>
extends PlayQueue {
boolean isInitial;
private boolean isComplete;
@@ -28,12 +26,15 @@ abstract class AbstractInfoPlayQueue, U exten
private transient Disposable fetchReactor;
- AbstractInfoPlayQueue(final U item) {
- this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0);
+ protected AbstractInfoPlayQueue(final T info) {
+ this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
}
- AbstractInfoPlayQueue(final int serviceId, final String url, final Page nextPage,
- final List streams, final int index) {
+ protected AbstractInfoPlayQueue(final int serviceId,
+ final String url,
+ final Page nextPage,
+ final List streams,
+ final int index) {
super(index, extractListItems(streams));
this.baseUrl = url;
diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/ChannelPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/ChannelPlayQueue.java
index f85349797..1e1fef85e 100644
--- a/app/src/main/java/org/schabi/newpipe/player/playqueue/ChannelPlayQueue.java
+++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/ChannelPlayQueue.java
@@ -3,7 +3,6 @@ package org.schabi.newpipe.player.playqueue;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.channel.ChannelInfo;
-import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.util.ExtractorHelper;
@@ -12,13 +11,10 @@ import java.util.List;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.schedulers.Schedulers;
-public final class ChannelPlayQueue extends AbstractInfoPlayQueue {
- public ChannelPlayQueue(final ChannelInfoItem item) {
- super(item);
- }
+public final class ChannelPlayQueue extends AbstractInfoPlayQueue {
public ChannelPlayQueue(final ChannelInfo info) {
- this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
+ super(info);
}
public ChannelPlayQueue(final int serviceId,
diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlaylistPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlaylistPlayQueue.java
index ac5dce9ba..01883d7d9 100644
--- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlaylistPlayQueue.java
+++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlaylistPlayQueue.java
@@ -2,7 +2,6 @@ package org.schabi.newpipe.player.playqueue;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
-import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.util.ExtractorHelper;
@@ -11,13 +10,10 @@ import java.util.List;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.schedulers.Schedulers;
-public final class PlaylistPlayQueue extends AbstractInfoPlayQueue {
- public PlaylistPlayQueue(final PlaylistInfoItem item) {
- super(item);
- }
+public final class PlaylistPlayQueue extends AbstractInfoPlayQueue {
public PlaylistPlayQueue(final PlaylistInfo info) {
- this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
+ super(info);
}
public PlaylistPlayQueue(final int serviceId,
From 4789cf6c3161419cfb353fc8be658a352ad62261 Mon Sep 17 00:00:00 2001
From: Stypox
Date: Sat, 19 Feb 2022 18:01:04 +0100
Subject: [PATCH 3/3] Use Java streams in AbstractInfoPlayQueue
---
.../newpipe/player/playqueue/AbstractInfoPlayQueue.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
index dc1c960cb..df2747c3b 100644
--- a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
+++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java
@@ -9,8 +9,8 @@ import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
-import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
import io.reactivex.rxjava3.core.SingleObserver;
import io.reactivex.rxjava3.disposables.Disposable;
@@ -132,10 +132,6 @@ abstract class AbstractInfoPlayQueue>
}
private static List extractListItems(final List infoItems) {
- final List result = new ArrayList<>();
- for (final StreamInfoItem stream : infoItems) {
- result.add(new PlayQueueItem(stream));
- }
- return result;
+ return infoItems.stream().map(PlayQueueItem::new).collect(Collectors.toList());
}
}