mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Set comment replies fragment title
This commit is contained in:
parent
94ea329b50
commit
4b6392df54
@ -2,8 +2,6 @@ package org.schabi.newpipe.fragments.list.comments;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@ -18,6 +16,7 @@ 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;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
|
import org.schabi.newpipe.util.Localization;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
@ -26,10 +25,10 @@ import io.reactivex.rxjava3.core.Single;
|
|||||||
public final class CommentRepliesFragment
|
public final class CommentRepliesFragment
|
||||||
extends BaseListInfoFragment<CommentsInfoItem, CommentRepliesInfo> {
|
extends BaseListInfoFragment<CommentsInfoItem, CommentRepliesInfo> {
|
||||||
|
|
||||||
// has the same content as super.currentInfo, except that it's never null
|
// the original comments info loaded alongside the stream
|
||||||
private CommentRepliesInfo commentRepliesInfo;
|
|
||||||
// the original comments info loaded alongside stream
|
|
||||||
private CommentsInfo commentsInfo;
|
private CommentsInfo commentsInfo;
|
||||||
|
// the comment to show replies of
|
||||||
|
private CommentsInfoItem commentsInfoItem;
|
||||||
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
@ -43,8 +42,8 @@ public final class CommentRepliesFragment
|
|||||||
public CommentRepliesFragment(final CommentsInfo commentsInfo,
|
public CommentRepliesFragment(final CommentsInfo commentsInfo,
|
||||||
final CommentsInfoItem commentsInfoItem) {
|
final CommentsInfoItem commentsInfoItem) {
|
||||||
this();
|
this();
|
||||||
this.commentRepliesInfo = CommentRepliesInfo.getInfo(commentsInfoItem);
|
|
||||||
this.commentsInfo = commentsInfo;
|
this.commentsInfo = commentsInfo;
|
||||||
|
this.commentsInfoItem = commentsInfoItem;
|
||||||
setInitialData(commentsInfo.getServiceId(), commentsInfo.getUrl(), commentsInfo.getName());
|
setInitialData(commentsInfo.getServiceId(), commentsInfo.getUrl(), commentsInfo.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,21 +57,21 @@ public final class CommentRepliesFragment
|
|||||||
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// State Saving
|
// State saving
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(final Queue<Object> objectsToSave) {
|
public void writeTo(final Queue<Object> objectsToSave) {
|
||||||
super.writeTo(objectsToSave);
|
super.writeTo(objectsToSave);
|
||||||
objectsToSave.add(commentRepliesInfo);
|
|
||||||
objectsToSave.add(commentsInfo);
|
objectsToSave.add(commentsInfo);
|
||||||
|
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);
|
||||||
commentRepliesInfo = (CommentRepliesInfo) savedObjects.poll();
|
|
||||||
commentsInfo = (CommentsInfo) savedObjects.poll();
|
commentsInfo = (CommentsInfo) savedObjects.poll();
|
||||||
|
commentsInfoItem = (CommentsInfoItem) savedObjects.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +81,9 @@ public final class CommentRepliesFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Single<CommentRepliesInfo> loadResult(final boolean forceLoad) {
|
protected Single<CommentRepliesInfo> loadResult(final boolean forceLoad) {
|
||||||
return Single.just(this.commentRepliesInfo);
|
return Single.fromCallable(() -> CommentRepliesInfo.getInfo(commentsInfoItem,
|
||||||
|
// the reply count string will be shown as the activity title
|
||||||
|
Localization.replyCount(requireContext(), commentsInfoItem.getReplyCount())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,11 +13,11 @@ public final class CommentRepliesInfo extends ListInfo<CommentsInfoItem> {
|
|||||||
super(serviceId, listUrlIdHandler, name);
|
super(serviceId, listUrlIdHandler, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommentRepliesInfo getInfo(final CommentsInfoItem comment) {
|
public static CommentRepliesInfo getInfo(final CommentsInfoItem comment, final String name) {
|
||||||
final ListLinkHandler handler =
|
final ListLinkHandler handler =
|
||||||
new ListLinkHandler("", "", "", Collections.emptyList(), null);
|
new ListLinkHandler("", "", "", Collections.emptyList(), null);
|
||||||
final CommentRepliesInfo relatedItemInfo = new CommentRepliesInfo(
|
final CommentRepliesInfo relatedItemInfo = new CommentRepliesInfo(
|
||||||
comment.getServiceId(), handler, comment.getName());
|
comment.getServiceId(), handler, name); // the name will be shown as fragment title
|
||||||
relatedItemInfo.setNextPage(comment.getReplies());
|
relatedItemInfo.setNextPage(comment.getReplies());
|
||||||
relatedItemInfo.setRelatedItems(Collections.emptyList()); // since it must be non-null
|
relatedItemInfo.setRelatedItems(Collections.emptyList()); // since it must be non-null
|
||||||
return relatedItemInfo;
|
return relatedItemInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user