feat: 优化代码

pull/164/head
kunfei 5 years ago
parent a4505fdf02
commit 8e422121a3
  1. 5
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -283,11 +283,12 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
*/
@Synchronized
private fun upSearchItems(items: List<SearchBook>, isMandatoryUpdate: Boolean) {
val searchItems = ArrayList(items)
if (isMandatoryUpdate || System.currentTimeMillis() - refreshTime > 500) {
refreshTime = System.currentTimeMillis()
val diffResult =
DiffUtil.calculateDiff(DiffCallBack(ArrayList(adapter.getItems()), items))
adapter.setItems(items, diffResult)
DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), searchItems))
adapter.setItems(searchItems, diffResult)
}
}

Loading…
Cancel
Save