Merge pull request #7904 from Stypox/fix-raw-use-of-parameterized-class

Solve Java warning "Raw use of parameterized class"
This commit is contained in:
litetex 2022-02-26 16:14:23 +01:00 committed by GitHub
commit 5be40f62f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 85 additions and 89 deletions

View file

@ -4,20 +4,19 @@ 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 java.util.stream.Collectors;
import io.reactivex.rxjava3.core.SingleObserver;
import io.reactivex.rxjava3.disposables.Disposable;
abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> extends PlayQueue {
abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>>
extends PlayQueue {
boolean isInitial;
private boolean isComplete;
@ -27,12 +26,15 @@ 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);
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<StreamInfoItem> streams, final int index) {
protected AbstractInfoPlayQueue(final int serviceId,
final String url,
final Page nextPage,
final List<StreamInfoItem> streams,
final int index) {
super(index, extractListItems(streams));
this.baseUrl = url;
@ -51,7 +53,7 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
}
SingleObserver<T> getHeadListObserver() {
return new SingleObserver<T>() {
return new SingleObserver<>() {
@Override
public void onSubscribe(@NonNull final Disposable d) {
if (isComplete || !isInitial || (fetchReactor != null
@ -85,8 +87,8 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
};
}
SingleObserver<ListExtractor.InfoItemsPage> getNextPageObserver() {
return new SingleObserver<ListExtractor.InfoItemsPage>() {
SingleObserver<ListExtractor.InfoItemsPage<StreamInfoItem>> getNextPageObserver() {
return new SingleObserver<>() {
@Override
public void onSubscribe(@NonNull final Disposable d) {
if (isComplete || isInitial || (fetchReactor != null
@ -98,7 +100,8 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
}
@Override
public void onSuccess(@NonNull final ListExtractor.InfoItemsPage result) {
public void onSuccess(
@NonNull final ListExtractor.InfoItemsPage<StreamInfoItem> result) {
if (!result.hasNextPage()) {
isComplete = true;
}
@ -129,12 +132,6 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
}
private static List<PlayQueueItem> extractListItems(final List<StreamInfoItem> infoItems) {
final List<PlayQueueItem> result = new ArrayList<>();
for (final InfoItem stream : infoItems) {
if (stream instanceof StreamInfoItem) {
result.add(new PlayQueueItem((StreamInfoItem) stream));
}
}
return result;
return infoItems.stream().map(PlayQueueItem::new).collect(Collectors.toList());
}
}

View file

@ -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<ChannelInfo, ChannelInfoItem> {
public ChannelPlayQueue(final ChannelInfoItem item) {
super(item);
}
public final class ChannelPlayQueue extends AbstractInfoPlayQueue<ChannelInfo> {
public ChannelPlayQueue(final ChannelInfo info) {
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
super(info);
}
public ChannelPlayQueue(final int serviceId,

View file

@ -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<PlaylistInfo, PlaylistInfoItem> {
public PlaylistPlayQueue(final PlaylistInfoItem item) {
super(item);
}
public final class PlaylistPlayQueue extends AbstractInfoPlayQueue<PlaylistInfo> {
public PlaylistPlayQueue(final PlaylistInfo info) {
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
super(info);
}
public PlaylistPlayQueue(final int serviceId,