Skip to content

Commit e3550a3

Browse files
committed
progress letting users delete posts and comments
1 parent a33e98c commit e3550a3

File tree

13 files changed

+657
-141
lines changed

13 files changed

+657
-141
lines changed

app/src/main/java/com/fastcomments/CommentsDialog.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ public void setOnCommentAddedListener(OnCommentAddedListener listener) {
5454
this.commentAddedListener = listener;
5555
}
5656

57+
/**
58+
* Get the current comment added listener
59+
* @return The current listener
60+
*/
61+
public OnCommentAddedListener getOnCommentAddedListener() {
62+
return commentAddedListener;
63+
}
64+
65+
/**
66+
* Get the post ID for this dialog
67+
* @return The post ID
68+
*/
69+
public String getPostId() {
70+
return post != null ? post.getId() : null;
71+
}
72+
5773
@Override
5874
protected void onCreate(Bundle savedInstanceState) {
5975
super.onCreate(savedInstanceState);

libraries/sdk/src/main/java/com/fastcomments/sdk/CommentViewHolder.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,9 @@ private void showCommentMenu(final CommentsAdapter.OnCommentMenuItemListener com
473473
}
474474
}
475475

476-
// Show/hide edit option based on ownership
476+
// Show/hide edit and delete options based on ownership
477477
menu.findItem(R.id.menu_edit_comment).setVisible(isCurrentUserComment);
478+
menu.findItem(R.id.menu_delete_comment).setVisible(isCurrentUserComment);
478479

479480
// Set item click listener
480481
popupMenu.setOnMenuItemClickListener(item -> {
@@ -488,6 +489,13 @@ private void showCommentMenu(final CommentsAdapter.OnCommentMenuItemListener com
488489
commentMenuListener.onEdit(commentId, commentText);
489490
return true;
490491
}
492+
} else if (itemId == R.id.menu_delete_comment) {
493+
// Handle delete comment
494+
if (currentComment != null && commentMenuListener != null) {
495+
String commentId = currentComment.getComment().getId();
496+
commentMenuListener.onDelete(commentId);
497+
return true;
498+
}
491499
} else if (itemId == R.id.menu_flag_comment) {
492500
// Handle flag comment
493501
if (currentComment != null && commentMenuListener != null) {

libraries/sdk/src/main/java/com/fastcomments/sdk/CommentsAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ public interface OnToggleRepliesListener {
254254
*/
255255
public interface OnCommentMenuItemListener {
256256
void onEdit(String commentId, String commentText);
257+
void onDelete(String commentId);
257258
void onFlag(String commentId);
258259
void onBlock(String commentId, String userName);
259260
}

0 commit comments

Comments
 (0)