Remove useless constructor in *PlayQueue

Also removes unused <> parameter in AbstractInfoPlayQueue and deduplicates constructor code in extending classes
This commit is contained in:
Stypox 2022-02-19 17:49:43 +01:00
parent 62abfa96b8
commit 5f1f52b6ce
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 12 additions and 19 deletions

View File

@ -4,20 +4,18 @@ import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
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;
import io.reactivex.rxjava3.core.SingleObserver; import io.reactivex.rxjava3.core.SingleObserver;
import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.disposables.Disposable;
abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>, U extends InfoItem> abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>>
extends PlayQueue { extends PlayQueue {
boolean isInitial; boolean isInitial;
private boolean isComplete; private boolean isComplete;
@ -28,12 +26,15 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>, U exten
private transient Disposable fetchReactor; private transient Disposable fetchReactor;
AbstractInfoPlayQueue(final U item) { protected AbstractInfoPlayQueue(final T info) {
this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0); this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
} }
AbstractInfoPlayQueue(final int serviceId, final String url, final Page nextPage, protected AbstractInfoPlayQueue(final int serviceId,
final List<StreamInfoItem> streams, final int index) { final String url,
final Page nextPage,
final List<StreamInfoItem> streams,
final int index) {
super(index, extractListItems(streams)); super(index, extractListItems(streams));
this.baseUrl = url; this.baseUrl = url;

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.player.playqueue;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.channel.ChannelInfo; 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.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.util.ExtractorHelper; 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.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.schedulers.Schedulers; import io.reactivex.rxjava3.schedulers.Schedulers;
public final class ChannelPlayQueue extends AbstractInfoPlayQueue<ChannelInfo, ChannelInfoItem> { public final class ChannelPlayQueue extends AbstractInfoPlayQueue<ChannelInfo> {
public ChannelPlayQueue(final ChannelInfoItem item) {
super(item);
}
public ChannelPlayQueue(final ChannelInfo info) { public ChannelPlayQueue(final ChannelInfo info) {
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0); super(info);
} }
public ChannelPlayQueue(final int serviceId, 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.Page;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo; 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.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.util.ExtractorHelper; 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.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.schedulers.Schedulers; import io.reactivex.rxjava3.schedulers.Schedulers;
public final class PlaylistPlayQueue extends AbstractInfoPlayQueue<PlaylistInfo, PlaylistInfoItem> { public final class PlaylistPlayQueue extends AbstractInfoPlayQueue<PlaylistInfo> {
public PlaylistPlayQueue(final PlaylistInfoItem item) {
super(item);
}
public PlaylistPlayQueue(final PlaylistInfo info) { public PlaylistPlayQueue(final PlaylistInfo info) {
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0); super(info);
} }
public PlaylistPlayQueue(final int serviceId, public PlaylistPlayQueue(final int serviceId,