Browse Source

notify adapter only once on new topic task result success, improving UI update speed

pull/34/head
Thodoris1999 7 years ago
parent
commit
0e54bce1c5
  1. 10
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

10
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()));

Loading…
Cancel
Save