mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-03 05:50:32 +00:00
Revert relying on source ListInfo, use commentsInfoItem.getUrl() instead
This reverts commit bb01da3691ff1d5c3dccd41b7ca1a5deb1b5676f. This commit was not needed
This commit is contained in:
parent
3f37e27852
commit
8c9287d0c8
@ -66,7 +66,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Check if it was loading when the fragment was stopped/paused,
|
// Check if it was loading when the fragment was stopped/paused,
|
||||||
if (wasLoading.getAndSet(false)) {
|
if (wasLoading.getAndSet(false)) {
|
||||||
if (hasMoreItems() && !infoListAdapter.getItemsList().isEmpty()) {
|
if (hasMoreItems() && !infoListAdapter.getItemsList().isEmpty()) {
|
||||||
@ -75,8 +74,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||||||
doInitialLoadLogic();
|
doInitialLoadLogic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
infoListAdapter.setSourceListInfo(currentInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,8 +137,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||||||
infoListAdapter.clearStreamItemList();
|
infoListAdapter.clearStreamItemList();
|
||||||
|
|
||||||
currentInfo = null;
|
currentInfo = null;
|
||||||
infoListAdapter.setSourceListInfo(null);
|
|
||||||
|
|
||||||
if (currentWorker != null) {
|
if (currentWorker != null) {
|
||||||
currentWorker.dispose();
|
currentWorker.dispose();
|
||||||
}
|
}
|
||||||
@ -151,7 +146,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||||||
.subscribe((@NonNull L result) -> {
|
.subscribe((@NonNull L result) -> {
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
currentInfo = result;
|
currentInfo = result;
|
||||||
infoListAdapter.setSourceListInfo(result);
|
|
||||||
currentNextPage = result.getNextPage();
|
currentNextPage = result.getNextPage();
|
||||||
handleResult(result);
|
handleResult(result);
|
||||||
}, throwable ->
|
}, throwable ->
|
||||||
|
@ -16,7 +16,6 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.databinding.CommentRepliesHeaderBinding;
|
import org.schabi.newpipe.databinding.CommentRepliesHeaderBinding;
|
||||||
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.CommentsInfoItem;
|
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.info_list.ItemViewMode;
|
import org.schabi.newpipe.info_list.ItemViewMode;
|
||||||
@ -37,10 +36,7 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
|||||||
public final class CommentRepliesFragment
|
public final class CommentRepliesFragment
|
||||||
extends BaseListInfoFragment<CommentsInfoItem, CommentRepliesInfo> {
|
extends BaseListInfoFragment<CommentsInfoItem, CommentRepliesInfo> {
|
||||||
|
|
||||||
// the original comments info loaded alongside the stream
|
private CommentsInfoItem commentsInfoItem; // the comment to show replies of
|
||||||
private CommentsInfo commentsInfo;
|
|
||||||
// the comment to show replies of
|
|
||||||
private CommentsInfoItem commentsInfoItem;
|
|
||||||
private final CompositeDisposable disposables = new CompositeDisposable();
|
private final CompositeDisposable disposables = new CompositeDisposable();
|
||||||
|
|
||||||
|
|
||||||
@ -48,16 +44,16 @@ public final class CommentRepliesFragment
|
|||||||
// Constructors and lifecycle
|
// Constructors and lifecycle
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
// only called by the Android framework, after which readFrom is called and restores all data
|
||||||
public CommentRepliesFragment() {
|
public CommentRepliesFragment() {
|
||||||
super(UserAction.REQUESTED_COMMENT_REPLIES);
|
super(UserAction.REQUESTED_COMMENT_REPLIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommentRepliesFragment(final CommentsInfo commentsInfo,
|
public CommentRepliesFragment(final CommentsInfoItem commentsInfoItem) {
|
||||||
final CommentsInfoItem commentsInfoItem) {
|
|
||||||
this();
|
this();
|
||||||
this.commentsInfo = commentsInfo;
|
|
||||||
this.commentsInfoItem = commentsInfoItem;
|
this.commentsInfoItem = commentsInfoItem;
|
||||||
setInitialData(commentsInfo.getServiceId(), commentsInfo.getUrl(), commentsInfo.getName());
|
// setting "" as title since the title will be properly set right after
|
||||||
|
setInitialData(commentsInfoItem.getServiceId(), commentsInfoItem.getUrl(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -122,14 +118,12 @@ public final class CommentRepliesFragment
|
|||||||
@Override
|
@Override
|
||||||
public void writeTo(final Queue<Object> objectsToSave) {
|
public void writeTo(final Queue<Object> objectsToSave) {
|
||||||
super.writeTo(objectsToSave);
|
super.writeTo(objectsToSave);
|
||||||
objectsToSave.add(commentsInfo);
|
|
||||||
objectsToSave.add(commentsInfoItem);
|
objectsToSave.add(commentsInfoItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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);
|
||||||
commentsInfo = (CommentsInfo) savedObjects.poll();
|
|
||||||
commentsInfoItem = (CommentsInfoItem) savedObjects.poll();
|
commentsInfoItem = (CommentsInfoItem) savedObjects.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +141,10 @@ public final class CommentRepliesFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<ListExtractor.InfoItemsPage<CommentsInfoItem>> loadMoreItemsLogic() {
|
protected Single<ListExtractor.InfoItemsPage<CommentsInfoItem>> loadMoreItemsLogic() {
|
||||||
return ExtractorHelper.getMoreCommentItems(serviceId, commentsInfo, currentNextPage);
|
// commentsInfoItem.getUrl() should contain the url of the original
|
||||||
|
// ListInfo<CommentsInfoItem>, which should be the stream url
|
||||||
|
return ExtractorHelper.getMoreCommentItems(
|
||||||
|
serviceId, commentsInfoItem.getUrl(), currentNextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
package org.schabi.newpipe.info_list;
|
package org.schabi.newpipe.info_list;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.Info;
|
import androidx.annotation.NonNull;
|
||||||
import org.schabi.newpipe.extractor.ListInfo;
|
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
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.info_list.holder.ChannelInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.CommentInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.InfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.PlaylistInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.PlaylistMiniInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.StreamInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.info_list.holder.StreamMiniInfoItemHolder;
|
||||||
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,12 +54,44 @@ public class InfoItemBuilder {
|
|||||||
private OnClickGesture<PlaylistInfoItem> onPlaylistSelectedListener;
|
private OnClickGesture<PlaylistInfoItem> onPlaylistSelectedListener;
|
||||||
private OnClickGesture<CommentsInfoItem> onCommentsSelectedListener;
|
private OnClickGesture<CommentsInfoItem> onCommentsSelectedListener;
|
||||||
|
|
||||||
private ListInfo<?> sourceListInfo; // the list-info the info-items from this list belong to
|
|
||||||
|
|
||||||
public InfoItemBuilder(final Context context) {
|
public InfoItemBuilder(final Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem,
|
||||||
|
final HistoryRecordManager historyRecordManager) {
|
||||||
|
return buildView(parent, infoItem, historyRecordManager, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem,
|
||||||
|
final HistoryRecordManager historyRecordManager,
|
||||||
|
final boolean useMiniVariant) {
|
||||||
|
final InfoItemHolder holder =
|
||||||
|
holderFromInfoType(parent, infoItem.getInfoType(), useMiniVariant);
|
||||||
|
holder.updateFromItem(infoItem, historyRecordManager);
|
||||||
|
return holder.itemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InfoItemHolder holderFromInfoType(@NonNull final ViewGroup parent,
|
||||||
|
@NonNull final InfoItem.InfoType infoType,
|
||||||
|
final boolean useMiniVariant) {
|
||||||
|
switch (infoType) {
|
||||||
|
case STREAM:
|
||||||
|
return useMiniVariant ? new StreamMiniInfoItemHolder(this, parent)
|
||||||
|
: new StreamInfoItemHolder(this, parent);
|
||||||
|
case CHANNEL:
|
||||||
|
return useMiniVariant ? new ChannelMiniInfoItemHolder(this, parent)
|
||||||
|
: new ChannelInfoItemHolder(this, parent);
|
||||||
|
case PLAYLIST:
|
||||||
|
return useMiniVariant ? new PlaylistMiniInfoItemHolder(this, parent)
|
||||||
|
: new PlaylistInfoItemHolder(this, parent);
|
||||||
|
case COMMENT:
|
||||||
|
return new CommentInfoItemHolder(this, parent);
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("InfoType not expected = " + infoType.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@ -84,12 +128,4 @@ public class InfoItemBuilder {
|
|||||||
final OnClickGesture<CommentsInfoItem> onCommentsSelectedListener) {
|
final OnClickGesture<CommentsInfoItem> onCommentsSelectedListener) {
|
||||||
this.onCommentsSelectedListener = onCommentsSelectedListener;
|
this.onCommentsSelectedListener = onCommentsSelectedListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info getSourceListInfo() {
|
|
||||||
return sourceListInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceListInfo(final ListInfo<?> sourceListInfo) {
|
|
||||||
this.sourceListInfo = sourceListInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import org.schabi.newpipe.databinding.PignateFooterBinding;
|
import org.schabi.newpipe.databinding.PignateFooterBinding;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.ListInfo;
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||||
@ -116,10 +115,6 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
infoItemBuilder.setOnCommentsSelectedListener(listener);
|
infoItemBuilder.setOnCommentsSelectedListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSourceListInfo(final ListInfo<?> sourceInfo) {
|
|
||||||
infoItemBuilder.setSourceListInfo(sourceInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUseMiniVariant(final boolean useMiniVariant) {
|
public void setUseMiniVariant(final boolean useMiniVariant) {
|
||||||
this.useMiniVariant = useMiniVariant;
|
this.useMiniVariant = useMiniVariant;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import androidx.fragment.app.FragmentActivity;
|
|||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.stream.Description;
|
import org.schabi.newpipe.extractor.stream.Description;
|
||||||
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
||||||
@ -174,7 +173,7 @@ public class CommentInfoItemHolder extends InfoItemHolder {
|
|||||||
|
|
||||||
private void openCommentReplies(final CommentsInfoItem item) {
|
private void openCommentReplies(final CommentsInfoItem item) {
|
||||||
NavigationHelper.openCommentRepliesFragment((FragmentActivity) itemBuilder.getContext(),
|
NavigationHelper.openCommentRepliesFragment((FragmentActivity) itemBuilder.getContext(),
|
||||||
(CommentsInfo) itemBuilder.getSourceListInfo(), item);
|
item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void allowLinkFocus() {
|
private void allowLinkFocus() {
|
||||||
|
@ -162,6 +162,15 @@ public final class ExtractorHelper {
|
|||||||
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
|
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Single<InfoItemsPage<CommentsInfoItem>> getMoreCommentItems(
|
||||||
|
final int serviceId,
|
||||||
|
final String url,
|
||||||
|
final Page nextPage) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
|
return Single.fromCallable(() ->
|
||||||
|
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
|
||||||
|
}
|
||||||
|
|
||||||
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId,
|
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId,
|
||||||
final String url,
|
final String url,
|
||||||
final boolean forceLoad) {
|
final boolean forceLoad) {
|
||||||
|
@ -34,7 +34,6 @@ import org.schabi.newpipe.download.DownloadActivity;
|
|||||||
import org.schabi.newpipe.error.ErrorUtil;
|
import org.schabi.newpipe.error.ErrorUtil;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||||
@ -503,11 +502,9 @@ public final class NavigationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openCommentRepliesFragment(@NonNull final FragmentActivity activity,
|
public static void openCommentRepliesFragment(@NonNull final FragmentActivity activity,
|
||||||
final CommentsInfo commentsInfo,
|
|
||||||
final CommentsInfoItem commentsInfoItem) {
|
final CommentsInfoItem commentsInfoItem) {
|
||||||
defaultTransaction(activity.getSupportFragmentManager())
|
defaultTransaction(activity.getSupportFragmentManager())
|
||||||
.replace(R.id.fragment_holder,
|
.replace(R.id.fragment_holder, new CommentRepliesFragment(commentsInfoItem))
|
||||||
new CommentRepliesFragment(commentsInfo, commentsInfoItem))
|
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user