From acf62587968c670fbcece023b86e2ade7415c00d Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Wed, 18 Jul 2018 14:06:24 +0300 Subject: [PATCH] allow only one post to be edited at a time --- .../thmmy/mthmmy/activities/topic/TopicActivity.java | 2 ++ .../thmmy/mthmmy/activities/topic/TopicAdapter.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 284510c7..009c8cf2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -1049,6 +1049,7 @@ public class TopicActivity extends BaseActivity { replyFAB.setEnabled(false); replyFAB.hide(); bottomNavBar.setVisibility(View.GONE); + topicAdapter.disablePostEditing(); } @Override @@ -1157,6 +1158,7 @@ public class TopicActivity extends BaseActivity { Toast.makeText(TopicActivity.this, "Edit failed!", Toast.LENGTH_SHORT).show(); paginationEnabled(true); replyFAB.setEnabled(true); + topicAdapter.enablePostEditing(); if (result) { topicTask = new TopicTask(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index e95e60cc..df252fc2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -98,6 +98,7 @@ class TopicAdapter extends RecyclerView.Adapter { private final int replySubject = 0, replyText = 1; private String commitEditURL, numReplies, seqnum, sc, topic, buildedQuotes, postText; private boolean canReply = false; + private boolean postEditingDisabled = false; /** * @param context the context of the {@link RecyclerView} @@ -493,7 +494,7 @@ class TopicAdapter extends RecyclerView.Adapter { final TextView editPostButton = popUpContent.findViewById(R.id.edit_post); - if (currentPost.getPostEditURL() == null || currentPost.getPostEditURL().equals("")) { + if (postEditingDisabled || currentPost.getPostEditURL() == null || currentPost.getPostEditURL().equals("")) { editPostButton.setVisibility(View.GONE); } else { editPostButton.setOnClickListener(new View.OnClickListener() { @@ -865,4 +866,12 @@ class TopicAdapter extends RecyclerView.Adapter { return context.getResources().getString(R.string.fa_file); } + + public void disablePostEditing() { + postEditingDisabled = true; + } + + public void enablePostEditing() { + postEditingDisabled = false; + } } \ No newline at end of file