From 0e54bce1c5c3c0bd59196fa14aff2d400797193e Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Tue, 31 Jul 2018 14:45:44 +0300 Subject: [PATCH] notify adapter only once on new topic task result success, improving UI update speed --- .../thmmy/mthmmy/activities/topic/TopicActivity.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 10c2cf39..197ddf74 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 @@ -210,14 +210,10 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb toolbarTitle.setText(topicTaskResult.getTopicTitle()); } - if (!postsList.isEmpty()) { - recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug - postsList.clear(); - if (topicTitle != null) toolbarTitle.setText(topicTitle); - topicAdapter.notifyItemRangeRemoved(0, postsList.size() - 1); - } + recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug + postsList.clear(); postsList.addAll(topicTaskResult.getNewPostsList()); - topicAdapter.notifyItemRangeInserted(0, postsList.size()); + topicAdapter.notifyDataSetChanged(); pageIndicator.setText(String.valueOf(topicTaskResult.getCurrentPageIndex()) + "/" + String.valueOf(topicTaskResult.getPageCount()));