1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Fix some code smells

This commit is contained in:
Stypox 2023-04-11 23:12:17 +02:00
parent 78cf9aaa7d
commit 591ed2e01f
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@ 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 // has the same content as super.currentInfo, except that it's never null
private CommentRepliesInfo currentInfo; private CommentRepliesInfo commentRepliesInfo;
// the original comments info loaded alongside stream // the original comments info loaded alongside stream
private CommentsInfo commentsInfo; private CommentsInfo commentsInfo;
@ -40,7 +40,7 @@ public final class CommentRepliesFragment
public CommentRepliesFragment(final CommentsInfo commentsInfo, public CommentRepliesFragment(final CommentsInfo commentsInfo,
final CommentsInfoItem commentsInfoItem) { final CommentsInfoItem commentsInfoItem) {
this(); this();
this.currentInfo = CommentRepliesInfo.getInfo(commentsInfoItem); this.commentRepliesInfo = CommentRepliesInfo.getInfo(commentsInfoItem);
this.commentsInfo = commentsInfo; this.commentsInfo = commentsInfo;
setInitialData(commentsInfo.getServiceId(), commentsInfo.getUrl(), commentsInfo.getName()); setInitialData(commentsInfo.getServiceId(), commentsInfo.getUrl(), commentsInfo.getName());
} }
@ -61,14 +61,14 @@ 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(currentInfo); objectsToSave.add(commentRepliesInfo);
objectsToSave.add(commentsInfo); objectsToSave.add(commentsInfo);
} }
@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);
currentInfo = (CommentRepliesInfo) savedObjects.poll(); commentRepliesInfo = (CommentRepliesInfo) savedObjects.poll();
commentsInfo = (CommentsInfo) savedObjects.poll(); commentsInfo = (CommentsInfo) savedObjects.poll();
} }
@ -79,7 +79,7 @@ public final class CommentRepliesFragment
@Override @Override
protected Single<CommentRepliesInfo> loadResult(final boolean forceLoad) { protected Single<CommentRepliesInfo> loadResult(final boolean forceLoad) {
return Single.just(this.currentInfo); return Single.just(this.commentRepliesInfo);
} }
@Override @Override

View File

@ -148,7 +148,7 @@ public class CommentInfoItemHolder extends InfoItemHolder {
itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE); itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE);
final boolean hasReplies = item.getReplies() != null; final boolean hasReplies = item.getReplies() != null;
repliesButton.setOnClickListener(hasReplies ? (v) -> openRepliesFragment(item) : null); repliesButton.setOnClickListener(hasReplies ? v -> openRepliesFragment(item) : null);
repliesButton.setVisibility(hasReplies ? View.VISIBLE : View.GONE); repliesButton.setVisibility(hasReplies ? View.VISIBLE : View.GONE);
repliesButton.setText(hasReplies repliesButton.setText(hasReplies
? Localization.replyCount(itemBuilder.getContext(), item.getReplyCount()) : ""); ? Localization.replyCount(itemBuilder.getContext(), item.getReplyCount()) : "");