1
0
mirror of https://framagit.org/tom79/fedilab-tube synced 2025-02-16 12:00:42 +01:00
This commit is contained in:
Thomas 2020-12-06 11:24:36 +01:00
parent e9c10b17e0
commit 0a12020fd8
2 changed files with 25 additions and 5 deletions

View File

@ -403,7 +403,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.closeReply.setOnClickListener(v -> closeCommentThread()); binding.closeReply.setOnClickListener(v -> closeCommentThread());
binding.closePost.setOnClickListener(v -> closePostComment()); binding.closePost.setOnClickListener(v -> closePostComment());
commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false, peertubeInstance); commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false, peertubeInstance, sepiaSearch);
commentListAdapter.allCommentRemoved = PeertubeActivity.this; commentListAdapter.allCommentRemoved = PeertubeActivity.this;
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this); LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeComments.setLayoutManager(mLayoutManager); binding.peertubeComments.setLayoutManager(mLayoutManager);
@ -532,7 +532,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
comment.setInReplyToCommentId(null); comment.setInReplyToCommentId(null);
comment.setTotalReplies(0); comment.setTotalReplies(0);
commentsThread.add(0, comment); commentsThread.add(0, comment);
commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true, peertubeInstance); commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true, peertubeInstance, sepiaSearch);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this); LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeReply.setLayoutManager(mLayoutManager); binding.peertubeReply.setLayoutManager(mLayoutManager);
binding.peertubeReply.setNestedScrollingEnabled(false); binding.peertubeReply.setNestedScrollingEnabled(false);

View File

@ -66,6 +66,7 @@ import es.dmoral.toasty.Toasty;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -78,13 +79,15 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
boolean isVideoOwner; boolean isVideoOwner;
private Context context; private Context context;
private final String instance; private final String instance;
private final boolean sepiaSearch;
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner, boolean isThread, String instance) { public CommentListAdapter(List<Comment> comments, boolean isVideoOwner, boolean isThread, String instance, boolean sepiaSearch) {
this.comments = comments; this.comments = comments;
commentListAdapter = this; commentListAdapter = this;
this.isVideoOwner = isVideoOwner; this.isVideoOwner = isVideoOwner;
this.isThread = isThread; this.isThread = isThread;
this.instance = instance; this.instance = instance;
this.sepiaSearch = sepiaSearch;
} }
@Override @Override
@ -296,8 +299,25 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
} else { } else {
holder.binding.postReplyButton.setVisibility(View.GONE); holder.binding.postReplyButton.setVisibility(View.GONE);
} }
holder.binding.postReplyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); holder.binding.postReplyButton.setOnClickListener(v -> {
holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); if (isLoggedIn(context) && !sepiaSearch) {
((PeertubeActivity) context).openPostComment(comment, i);
} else {
if (sepiaSearch) {
Toasty.info(context, context.getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
} else {
Toasty.error(context, context.getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
if (isLoggedIn(context) && !sepiaSearch) {
holder.binding.replyButton.setVisibility(View.VISIBLE);
holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
} else {
holder.binding.replyButton.setVisibility(View.GONE);
}
} }
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) { public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) {