mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
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:
commit
5be40f62f3
@ -272,7 +272,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<ChannelInfoItem>() {
|
infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<>() {
|
||||||
@Override
|
@Override
|
||||||
public void selected(final ChannelInfoItem selectedItem) {
|
public void selected(final ChannelInfoItem selectedItem) {
|
||||||
try {
|
try {
|
||||||
@ -288,7 +288,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture<PlaylistInfoItem>() {
|
infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture<>() {
|
||||||
@Override
|
@Override
|
||||||
public void selected(final PlaylistInfoItem selectedItem) {
|
public void selected(final PlaylistInfoItem selectedItem) {
|
||||||
try {
|
try {
|
||||||
|
@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import org.schabi.newpipe.error.ErrorInfo;
|
import org.schabi.newpipe.error.ErrorInfo;
|
||||||
import org.schabi.newpipe.error.UserAction;
|
import org.schabi.newpipe.error.UserAction;
|
||||||
|
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;
|
||||||
@ -27,8 +28,8 @@ import io.reactivex.rxjava3.core.Single;
|
|||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public abstract class BaseListInfoFragment<I extends ListInfo>
|
public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInfo<I>>
|
||||||
extends BaseListFragment<I, ListExtractor.InfoItemsPage> {
|
extends BaseListFragment<L, ListExtractor.InfoItemsPage<I>> {
|
||||||
@State
|
@State
|
||||||
protected int serviceId = Constants.NO_SERVICE_ID;
|
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||||
@State
|
@State
|
||||||
@ -37,7 +38,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
protected String url;
|
protected String url;
|
||||||
|
|
||||||
private final UserAction errorUserAction;
|
private final UserAction errorUserAction;
|
||||||
protected I currentInfo;
|
protected L currentInfo;
|
||||||
protected Page currentNextPage;
|
protected Page currentNextPage;
|
||||||
protected Disposable currentWorker;
|
protected Disposable currentWorker;
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void readFrom(@NonNull final Queue<Object> savedObjects) throws Exception {
|
public void readFrom(@NonNull final Queue<Object> savedObjects) throws Exception {
|
||||||
super.readFrom(savedObjects);
|
super.readFrom(savedObjects);
|
||||||
currentInfo = (I) savedObjects.poll();
|
currentInfo = (L) savedObjects.poll();
|
||||||
currentNextPage = (Page) savedObjects.poll();
|
currentNextPage = (Page) savedObjects.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
* @param forceLoad allow or disallow the result to come from the cache
|
* @param forceLoad allow or disallow the result to come from the cache
|
||||||
* @return Rx {@link Single} containing the {@link ListInfo}
|
* @return Rx {@link Single} containing the {@link ListInfo}
|
||||||
*/
|
*/
|
||||||
protected abstract Single<I> loadResult(boolean forceLoad);
|
protected abstract Single<L> loadResult(boolean forceLoad);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startLoading(final boolean forceLoad) {
|
public void startLoading(final boolean forceLoad) {
|
||||||
@ -140,7 +141,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
currentWorker = loadResult(forceLoad)
|
currentWorker = loadResult(forceLoad)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe((@NonNull I result) -> {
|
.subscribe((@NonNull L result) -> {
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
currentInfo = result;
|
currentInfo = result;
|
||||||
currentNextPage = result.getNextPage();
|
currentNextPage = result.getNextPage();
|
||||||
@ -157,7 +158,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
*
|
*
|
||||||
* @return Rx {@link Single} containing the {@link ListExtractor.InfoItemsPage}
|
* @return Rx {@link Single} containing the {@link ListExtractor.InfoItemsPage}
|
||||||
*/
|
*/
|
||||||
protected abstract Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic();
|
protected abstract Single<ListExtractor.InfoItemsPage<I>> loadMoreItemsLogic();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadMoreItems() {
|
protected void loadMoreItems() {
|
||||||
@ -194,7 +195,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleNextItems(final ListExtractor.InfoItemsPage result) {
|
public void handleNextItems(final ListExtractor.InfoItemsPage<I> result) {
|
||||||
super.handleNextItems(result);
|
super.handleNextItems(result);
|
||||||
|
|
||||||
currentNextPage = result.getNextPage();
|
currentNextPage = result.getNextPage();
|
||||||
@ -218,7 +219,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
|
|||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResult(@NonNull final I result) {
|
public void handleResult(@NonNull final L result) {
|
||||||
super.handleResult(result);
|
super.handleResult(result);
|
||||||
|
|
||||||
name = result.getName();
|
name = result.getName();
|
||||||
|
@ -64,7 +64,7 @@ import io.reactivex.rxjava3.functions.Consumer;
|
|||||||
import io.reactivex.rxjava3.functions.Function;
|
import io.reactivex.rxjava3.functions.Function;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
|
public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, ChannelInfo>
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
|
|
||||||
private static final int BUTTON_DEBOUNCE_INTERVAL = 100;
|
private static final int BUTTON_DEBOUNCE_INTERVAL = 100;
|
||||||
@ -374,7 +374,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
|
|||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
|
protected Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
|
||||||
return ExtractorHelper.getMoreChannelItems(serviceId, url, currentNextPage);
|
return ExtractorHelper.getMoreChannelItems(serviceId, url, currentNextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.error.UserAction;
|
import org.schabi.newpipe.error.UserAction;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||||
import org.schabi.newpipe.ktx.ViewUtils;
|
import org.schabi.newpipe.ktx.ViewUtils;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
@ -22,7 +23,7 @@ import org.schabi.newpipe.util.ExtractorHelper;
|
|||||||
import io.reactivex.rxjava3.core.Single;
|
import io.reactivex.rxjava3.core.Single;
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
|
public class CommentsFragment extends BaseListInfoFragment<CommentsInfoItem, CommentsInfo> {
|
||||||
private final CompositeDisposable disposables = new CompositeDisposable();
|
private final CompositeDisposable disposables = new CompositeDisposable();
|
||||||
|
|
||||||
private TextView emptyStateDesc;
|
private TextView emptyStateDesc;
|
||||||
@ -67,7 +68,7 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
|
|||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
|
protected Single<ListExtractor.InfoItemsPage<CommentsInfoItem>> loadMoreItemsLogic() {
|
||||||
return ExtractorHelper.getMoreCommentItems(serviceId, currentInfo, currentNextPage);
|
return ExtractorHelper.getMoreCommentItems(serviceId, currentInfo, currentNextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
import org.schabi.newpipe.util.KioskTranslator;
|
import org.schabi.newpipe.util.KioskTranslator;
|
||||||
@ -53,7 +54,7 @@ import io.reactivex.rxjava3.core.Single;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
public class KioskFragment extends BaseListInfoFragment<StreamInfoItem, KioskInfo> {
|
||||||
@State
|
@State
|
||||||
String kioskId = "";
|
String kioskId = "";
|
||||||
String kioskTranslatedName;
|
String kioskTranslatedName;
|
||||||
@ -145,7 +146,7 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
|
public Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
|
||||||
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextPage);
|
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ import io.reactivex.rxjava3.core.Single;
|
|||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, PlaylistInfo> {
|
||||||
|
|
||||||
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
|
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
|
protected Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
|
||||||
return ExtractorHelper.getMorePlaylistItems(serviceId, url, currentNextPage);
|
return ExtractorHelper.getMorePlaylistItems(serviceId, url, currentNextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import androidx.preference.PreferenceManager;
|
|||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.databinding.RelatedItemsHeaderBinding;
|
import org.schabi.newpipe.databinding.RelatedItemsHeaderBinding;
|
||||||
import org.schabi.newpipe.error.UserAction;
|
import org.schabi.newpipe.error.UserAction;
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||||
@ -26,7 +27,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import io.reactivex.rxjava3.core.Single;
|
import io.reactivex.rxjava3.core.Single;
|
||||||
|
|
||||||
public class RelatedItemsFragment extends BaseListInfoFragment<RelatedItemInfo>
|
public class RelatedItemsFragment extends BaseListInfoFragment<InfoItem, RelatedItemInfo>
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String INFO_KEY = "related_info_key";
|
private static final String INFO_KEY = "related_info_key";
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ public class RelatedItemsFragment extends BaseListInfoFragment<RelatedItemInfo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
|
protected Single<ListExtractor.InfoItemsPage<InfoItem>> loadMoreItemsLogic() {
|
||||||
return Single.fromCallable(ListExtractor.InfoItemsPage::emptyPage);
|
return Single.fromCallable(ListExtractor.InfoItemsPage::emptyPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import com.grack.nanojson.JsonAppendableWriter;
|
|||||||
import com.grack.nanojson.JsonArray;
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
import com.grack.nanojson.JsonParser;
|
import com.grack.nanojson.JsonParser;
|
||||||
import com.grack.nanojson.JsonSink;
|
|
||||||
import com.grack.nanojson.JsonWriter;
|
import com.grack.nanojson.JsonWriter;
|
||||||
|
|
||||||
import org.schabi.newpipe.BuildConfig;
|
import org.schabi.newpipe.BuildConfig;
|
||||||
@ -125,10 +124,11 @@ public final class ImportExportJsonHelper {
|
|||||||
/**
|
/**
|
||||||
* @see #writeTo(List, OutputStream, ImportExportEventListener)
|
* @see #writeTo(List, OutputStream, ImportExportEventListener)
|
||||||
* @param items the list of subscriptions items
|
* @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
|
* @param eventListener listener for the events generated
|
||||||
*/
|
*/
|
||||||
public static void writeTo(final List<SubscriptionItem> items, final JsonSink writer,
|
public static void writeTo(final List<SubscriptionItem> items,
|
||||||
|
final JsonAppendableWriter writer,
|
||||||
@Nullable final ImportExportEventListener eventListener) {
|
@Nullable final ImportExportEventListener eventListener) {
|
||||||
if (eventListener != null) {
|
if (eventListener != null) {
|
||||||
eventListener.onSizeReceived(items.size());
|
eventListener.onSizeReceived(items.size());
|
||||||
|
@ -4,20 +4,19 @@ 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.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
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, U extends InfoItem> extends PlayQueue {
|
abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>>
|
||||||
|
extends PlayQueue {
|
||||||
boolean isInitial;
|
boolean isInitial;
|
||||||
private boolean isComplete;
|
private boolean isComplete;
|
||||||
|
|
||||||
@ -27,12 +26,15 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
|
|||||||
|
|
||||||
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;
|
||||||
@ -51,7 +53,7 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
SingleObserver<T> getHeadListObserver() {
|
SingleObserver<T> getHeadListObserver() {
|
||||||
return new SingleObserver<T>() {
|
return new SingleObserver<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull final Disposable d) {
|
public void onSubscribe(@NonNull final Disposable d) {
|
||||||
if (isComplete || !isInitial || (fetchReactor != null
|
if (isComplete || !isInitial || (fetchReactor != null
|
||||||
@ -85,8 +87,8 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleObserver<ListExtractor.InfoItemsPage> getNextPageObserver() {
|
SingleObserver<ListExtractor.InfoItemsPage<StreamInfoItem>> getNextPageObserver() {
|
||||||
return new SingleObserver<ListExtractor.InfoItemsPage>() {
|
return new SingleObserver<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull final Disposable d) {
|
public void onSubscribe(@NonNull final Disposable d) {
|
||||||
if (isComplete || isInitial || (fetchReactor != null
|
if (isComplete || isInitial || (fetchReactor != null
|
||||||
@ -98,7 +100,8 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@NonNull final ListExtractor.InfoItemsPage result) {
|
public void onSuccess(
|
||||||
|
@NonNull final ListExtractor.InfoItemsPage<StreamInfoItem> result) {
|
||||||
if (!result.hasNextPage()) {
|
if (!result.hasNextPage()) {
|
||||||
isComplete = true;
|
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) {
|
private static List<PlayQueueItem> extractListItems(final List<StreamInfoItem> infoItems) {
|
||||||
final List<PlayQueueItem> result = new ArrayList<>();
|
return infoItems.stream().map(PlayQueueItem::new).collect(Collectors.toList());
|
||||||
for (final InfoItem stream : infoItems) {
|
|
||||||
if (stream instanceof StreamInfoItem) {
|
|
||||||
result.add(new PlayQueueItem((StreamInfoItem) stream));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
import com.grack.nanojson.JsonSink;
|
import com.grack.nanojson.JsonStringWriter;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.LocalItem.LocalItemType;
|
import org.schabi.newpipe.database.LocalItem.LocalItemType;
|
||||||
@ -132,7 +132,7 @@ public abstract class Tab {
|
|||||||
// JSON Handling
|
// JSON Handling
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public void writeJsonOn(final JsonSink jsonSink) {
|
public void writeJsonOn(final JsonStringWriter jsonSink) {
|
||||||
jsonSink.object();
|
jsonSink.object();
|
||||||
|
|
||||||
jsonSink.value(JSON_TAB_ID_KEY, getTabId());
|
jsonSink.value(JSON_TAB_ID_KEY, getTabId());
|
||||||
@ -141,7 +141,7 @@ public abstract class Tab {
|
|||||||
jsonSink.end();
|
jsonSink.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeDataToJson(final JsonSink writerSink) {
|
protected void writeDataToJson(final JsonStringWriter writerSink) {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ public abstract class Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeDataToJson(final JsonSink writerSink) {
|
protected void writeDataToJson(final JsonStringWriter writerSink) {
|
||||||
writerSink.value(JSON_KIOSK_SERVICE_ID_KEY, kioskServiceId)
|
writerSink.value(JSON_KIOSK_SERVICE_ID_KEY, kioskServiceId)
|
||||||
.value(JSON_KIOSK_ID_KEY, kioskId);
|
.value(JSON_KIOSK_ID_KEY, kioskId);
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ public abstract class Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeDataToJson(final JsonSink writerSink) {
|
protected void writeDataToJson(final JsonStringWriter writerSink) {
|
||||||
writerSink.value(JSON_CHANNEL_SERVICE_ID_KEY, channelServiceId)
|
writerSink.value(JSON_CHANNEL_SERVICE_ID_KEY, channelServiceId)
|
||||||
.value(JSON_CHANNEL_URL_KEY, channelUrl)
|
.value(JSON_CHANNEL_URL_KEY, channelUrl)
|
||||||
.value(JSON_CHANNEL_NAME_KEY, channelName);
|
.value(JSON_CHANNEL_NAME_KEY, channelName);
|
||||||
@ -584,7 +584,7 @@ public abstract class Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeDataToJson(final JsonSink writerSink) {
|
protected void writeDataToJson(final JsonStringWriter writerSink) {
|
||||||
writerSink.value(JSON_PLAYLIST_SERVICE_ID_KEY, playlistServiceId)
|
writerSink.value(JSON_PLAYLIST_SERVICE_ID_KEY, playlistServiceId)
|
||||||
.value(JSON_PLAYLIST_URL_KEY, playlistUrl)
|
.value(JSON_PLAYLIST_URL_KEY, playlistUrl)
|
||||||
.value(JSON_PLAYLIST_NAME_KEY, playlistName)
|
.value(JSON_PLAYLIST_NAME_KEY, playlistName)
|
||||||
|
@ -30,6 +30,7 @@ import androidx.preference.PreferenceManager;
|
|||||||
|
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.util.external_communication.TextLinkifier;
|
import org.schabi.newpipe.util.external_communication.TextLinkifier;
|
||||||
import org.schabi.newpipe.extractor.Info;
|
import org.schabi.newpipe.extractor.Info;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
@ -84,7 +85,8 @@ public final class ExtractorHelper {
|
|||||||
.fromQuery(searchString, contentFilter, sortFilter)));
|
.fromQuery(searchString, contentFilter, sortFilter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage> getMoreSearchItems(final int serviceId,
|
public static Single<InfoItemsPage<InfoItem>> getMoreSearchItems(
|
||||||
|
final int serviceId,
|
||||||
final String searchString,
|
final String searchString,
|
||||||
final List<String> contentFilter,
|
final List<String> contentFilter,
|
||||||
final String sortFilter,
|
final String sortFilter,
|
||||||
@ -124,7 +126,8 @@ public final class ExtractorHelper {
|
|||||||
ChannelInfo.getInfo(NewPipe.getService(serviceId), url)));
|
ChannelInfo.getInfo(NewPipe.getService(serviceId), url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage> getMoreChannelItems(final int serviceId, final String url,
|
public static Single<InfoItemsPage<StreamInfoItem>> getMoreChannelItems(final int serviceId,
|
||||||
|
final String url,
|
||||||
final Page nextPage) {
|
final Page nextPage) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(() ->
|
return Single.fromCallable(() ->
|
||||||
@ -155,7 +158,8 @@ public final class ExtractorHelper {
|
|||||||
CommentsInfo.getInfo(NewPipe.getService(serviceId), url)));
|
CommentsInfo.getInfo(NewPipe.getService(serviceId), url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage> getMoreCommentItems(final int serviceId,
|
public static Single<InfoItemsPage<CommentsInfoItem>> getMoreCommentItems(
|
||||||
|
final int serviceId,
|
||||||
final CommentsInfo info,
|
final CommentsInfo info,
|
||||||
final Page nextPage) {
|
final Page nextPage) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
@ -163,7 +167,8 @@ public final class ExtractorHelper {
|
|||||||
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
|
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId, final String url,
|
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId,
|
||||||
|
final String url,
|
||||||
final boolean forceLoad) {
|
final boolean forceLoad) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return checkCache(forceLoad, serviceId, url, InfoItem.InfoType.PLAYLIST,
|
return checkCache(forceLoad, serviceId, url, InfoItem.InfoType.PLAYLIST,
|
||||||
@ -171,7 +176,8 @@ public final class ExtractorHelper {
|
|||||||
PlaylistInfo.getInfo(NewPipe.getService(serviceId), url)));
|
PlaylistInfo.getInfo(NewPipe.getService(serviceId), url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage> getMorePlaylistItems(final int serviceId, final String url,
|
public static Single<InfoItemsPage<StreamInfoItem>> getMorePlaylistItems(final int serviceId,
|
||||||
|
final String url,
|
||||||
final Page nextPage) {
|
final Page nextPage) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(() ->
|
return Single.fromCallable(() ->
|
||||||
@ -184,7 +190,8 @@ public final class ExtractorHelper {
|
|||||||
Single.fromCallable(() -> KioskInfo.getInfo(NewPipe.getService(serviceId), url)));
|
Single.fromCallable(() -> KioskInfo.getInfo(NewPipe.getService(serviceId), url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage> getMoreKioskItems(final int serviceId, final String url,
|
public static Single<InfoItemsPage<StreamInfoItem>> getMoreKioskItems(final int serviceId,
|
||||||
|
final String url,
|
||||||
final Page nextPage) {
|
final Page nextPage) {
|
||||||
return Single.fromCallable(() ->
|
return Single.fromCallable(() ->
|
||||||
KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
|
KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
|
||||||
|
@ -19,7 +19,7 @@ public final class SerializedCache {
|
|||||||
private static final boolean DEBUG = MainActivity.DEBUG;
|
private static final boolean DEBUG = MainActivity.DEBUG;
|
||||||
private static final SerializedCache INSTANCE = new SerializedCache();
|
private static final SerializedCache INSTANCE = new SerializedCache();
|
||||||
private static final int MAX_ITEMS_ON_CACHE = 5;
|
private static final int MAX_ITEMS_ON_CACHE = 5;
|
||||||
private static final LruCache<String, CacheData> LRU_CACHE =
|
private static final LruCache<String, CacheData<?>> LRU_CACHE =
|
||||||
new LruCache<>(MAX_ITEMS_ON_CACHE);
|
new LruCache<>(MAX_ITEMS_ON_CACHE);
|
||||||
private static final String TAG = "SerializedCache";
|
private static final String TAG = "SerializedCache";
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public final class SerializedCache {
|
|||||||
Log.d(TAG, "get() called with: key = [" + key + "]");
|
Log.d(TAG, "get() called with: key = [" + key + "]");
|
||||||
}
|
}
|
||||||
synchronized (LRU_CACHE) {
|
synchronized (LRU_CACHE) {
|
||||||
final CacheData data = LRU_CACHE.get(key);
|
final CacheData<?> data = LRU_CACHE.get(key);
|
||||||
return data != null ? getItem(data, type) : null;
|
return data != null ? getItem(data, type) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public final class SerializedCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private <T> T getItem(@NonNull final CacheData data, @NonNull final Class<T> type) {
|
private <T> T getItem(@NonNull final CacheData<?> data, @NonNull final Class<T> type) {
|
||||||
return type.isAssignableFrom(data.type) ? type.cast(data.item) : null;
|
return type.isAssignableFrom(data.type) ? type.cast(data.item) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.schabi.newpipe.DownloaderImpl;
|
import org.schabi.newpipe.DownloaderImpl;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||||
import org.schabi.newpipe.extractor.stream.Stream;
|
import org.schabi.newpipe.extractor.stream.Stream;
|
||||||
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
||||||
@ -137,7 +138,7 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (streamsWrapper.getSizeInBytes(position) > 0) {
|
if (streamsWrapper.getSizeInBytes(position) > 0) {
|
||||||
final SecondaryStreamHelper secondary = secondaryStreams == null ? null
|
final SecondaryStreamHelper<U> secondary = secondaryStreams == null ? null
|
||||||
: secondaryStreams.get(position);
|
: secondaryStreams.get(position);
|
||||||
if (secondary != null) {
|
if (secondary != null) {
|
||||||
final long size
|
final long size
|
||||||
@ -153,16 +154,11 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
|
|||||||
|
|
||||||
if (stream instanceof SubtitlesStream) {
|
if (stream instanceof SubtitlesStream) {
|
||||||
formatNameView.setText(((SubtitlesStream) stream).getLanguageTag());
|
formatNameView.setText(((SubtitlesStream) stream).getLanguageTag());
|
||||||
} else {
|
} else if (stream.getFormat() == MediaFormat.WEBMA_OPUS) {
|
||||||
switch (stream.getFormat()) {
|
|
||||||
case WEBMA_OPUS:
|
|
||||||
// noinspection AndroidLintSetTextI18n
|
// noinspection AndroidLintSetTextI18n
|
||||||
formatNameView.setText("opus");
|
formatNameView.setText("opus");
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
formatNameView.setText(stream.getFormat().getName());
|
formatNameView.setText(stream.getFormat().getName());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qualityView.setText(qualityString);
|
qualityView.setText(qualityString);
|
||||||
|
Loading…
Reference in New Issue
Block a user