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. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

6
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()); toolbarTitle.setText(topicTaskResult.getTopicTitle());
} }
if (!postsList.isEmpty()) {
recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug
postsList.clear(); postsList.clear();
if (topicTitle != null) toolbarTitle.setText(topicTitle);
topicAdapter.notifyItemRangeRemoved(0, postsList.size() - 1);
}
postsList.addAll(topicTaskResult.getNewPostsList()); postsList.addAll(topicTaskResult.getNewPostsList());
topicAdapter.notifyItemRangeInserted(0, postsList.size()); topicAdapter.notifyDataSetChanged();
pageIndicator.setText(String.valueOf(topicTaskResult.getCurrentPageIndex()) + "/" + pageIndicator.setText(String.valueOf(topicTaskResult.getCurrentPageIndex()) + "/" +
String.valueOf(topicTaskResult.getPageCount())); String.valueOf(topicTaskResult.getPageCount()));

Loading…
Cancel
Save