aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedComment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedCommentReveddit.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java8
4 files changed, 28 insertions, 14 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index df2718cf..2046f5ed 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -963,15 +963,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
public void editComment(String commentAuthor, String commentContentMarkdown, int position) {
- editComment(commentAuthor, mVisibleComments.get(position).isSubmitter(), commentContentMarkdown, position);
- }
-
- public void editComment(String commentAuthor, boolean isSubmitter, String commentContentMarkdown, int position) {
if (commentAuthor != null) {
mVisibleComments.get(position).setAuthor(commentAuthor);
}
- mVisibleComments.get(position).setSubmittedByAuthor(isSubmitter);
+ mVisibleComments.get(position).setSubmittedByAuthor(mVisibleComments.get(position).isSubmitter());
mVisibleComments.get(position).setCommentMarkdown(commentContentMarkdown);
if (mIsSingleCommentThreadMode) {
@@ -981,6 +977,24 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
}
+ public void editComment(Comment fetchedComment, Comment originalComment, int position) {
+ if (position >= mVisibleComments.size() || !mVisibleComments.get(position).equals(originalComment)) {
+ position = mVisibleComments.indexOf(originalComment);
+ if (position < 0) {
+ Toast.makeText(mActivity, R.string.show_removed_comment_failed, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ }
+ mVisibleComments.get(position).setSubmittedByAuthor(originalComment.isSubmitter());
+ mVisibleComments.get(position).setCommentMarkdown(fetchedComment.getCommentMarkdown());
+
+ if (mIsSingleCommentThreadMode) {
+ notifyItemChanged(position + 1);
+ } else {
+ notifyItemChanged(position);
+ }
+ }
+
public void deleteComment(int position) {
if (mVisibleComments != null && position >= 0 && position < mVisibleComments.size()) {
if (mVisibleComments.get(position).hasReply()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedComment.java
index 90102d41..1c2e3199 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedComment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedComment.java
@@ -29,7 +29,7 @@ public class FetchRemovedComment {
Comment removedComment = parseComment(response.body(), comment);
handler.post(() -> {
if (removedComment != null) {
- listener.fetchSuccess(removedComment);
+ listener.fetchSuccess(removedComment, comment);
} else {
listener.fetchFailed();
}
@@ -64,7 +64,7 @@ public class FetchRemovedComment {
Comment removedComment = parseComment(response.body(), comment);
handler.post(() -> {
if (removedComment != null) {
- listener.fetchSuccess(removedComment);
+ listener.fetchSuccess(removedComment, comment);
} else {
listener.fetchFailed();
}
@@ -124,7 +124,7 @@ public class FetchRemovedComment {
}
public interface FetchRemovedCommentListener {
- void fetchSuccess(Comment comment);
+ void fetchSuccess(Comment fetchedComment, Comment originalComment);
void fetchFailed();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedCommentReveddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedCommentReveddit.java
index 82222caa..b7c2e30d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedCommentReveddit.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchRemovedCommentReveddit.java
@@ -36,7 +36,7 @@ public class FetchRemovedCommentReveddit {
Comment removedComment = parseRemovedComment(new JSONObject(response.body()).getJSONObject(comment.getId()), comment);
handler.post(() -> {
if (removedComment != null) {
- listener.fetchSuccess(removedComment);
+ listener.fetchSuccess(removedComment, comment);
} else {
listener.fetchFailed();
}
@@ -69,7 +69,7 @@ public class FetchRemovedCommentReveddit {
}
public interface FetchRemovedCommentListener {
- void fetchSuccess(Comment comment);
+ void fetchSuccess(Comment fetchedComment, Comment originalComment);
void fetchFailed();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index 0383baf0..4475e8f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -1811,8 +1811,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mExecutor, new Handler(), pushshiftRetrofit, comment,
new FetchRemovedComment.FetchRemovedCommentListener() {
@Override
- public void fetchSuccess(Comment comment) {
- mCommentsAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position);
+ public void fetchSuccess(Comment fetchedComment, Comment originalComment) {
+ mCommentsAdapter.editComment(fetchedComment, originalComment, position);
}
@Override
@@ -1822,8 +1822,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
comment, mPost.getPostTimeMillis(), mPost.getNComments(),
new FetchRemovedCommentReveddit.FetchRemovedCommentListener() {
@Override
- public void fetchSuccess(Comment comment) {
- mCommentsAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position);
+ public void fetchSuccess(Comment fetchedComment, Comment originalComment) {
+ mCommentsAdapter.editComment(fetchedComment, originalComment, position);
}
@Override