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 08633cde..c83edfb3 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 @@ -169,7 +169,6 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb recyclerView.setAdapter(topicAdapter); replyFAB = findViewById(R.id.topic_fab); - replyFAB.hide(); bottomNavBar = findViewById(R.id.bottom_navigation_bar); if (!sessionManager.isLoggedIn()) replyFAB.hide(); else { @@ -203,12 +202,6 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb toolbarTitle.setText(topicTaskResult.getTopicTitle()); } - if (topicTaskResult.getReplyPageUrl() == null) { - replyFAB.hide(); - topicAdapter.resetTopic(false); - } else - topicAdapter.resetTopic(true); - if (!postsList.isEmpty()) { recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug postsList.clear(); @@ -229,6 +222,9 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb } progressBar.setVisibility(ProgressBar.GONE); + if (topicTaskResult.getReplyPageUrl() == null) + replyFAB.hide(); + topicAdapter.resetTopic(); break; case NETWORK_ERROR: Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); 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 9d1a94b0..fc9076e9 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 @@ -88,8 +88,6 @@ class TopicAdapter extends RecyclerView.Adapter { private static final int isQuoteButtonChecked = 1; private TopicViewModel viewModel; - private boolean canReply = false; - /** * @param context the context of the {@link RecyclerView} * @param postsList List of {@link Post} objects to use @@ -452,7 +450,7 @@ class TopicAdapter extends RecyclerView.Adapter { }); //noinspection PointlessBooleanExpression,ConstantConditions - if (!BaseActivity.getSessionManager().isLoggedIn() || !canReply) { + if (!BaseActivity.getSessionManager().isLoggedIn() || !viewModel.canReply()) { holder.quoteToggle.setVisibility(View.GONE); } else { if (viewProperties.get(position)[isQuoteButtonChecked]) @@ -559,8 +557,7 @@ class TopicAdapter extends RecyclerView.Adapter { } } - void resetTopic(boolean canReply) { - this.canReply = canReply; + void resetTopic() { viewProperties.clear(); for (int i = 0; i < postsList.size(); ++i) { //Initializes properties, array's values will be false by default diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 0fdb4c21..006d8368 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -95,6 +95,10 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa return postEditedPosition; } + public boolean canReply() { + return topicTaskResult.getValue() != null && topicTaskResult.getValue().getReplyPageUrl() != null; + } + public boolean isWritingReply() { return writingReply; }