refresh items only if they changed

This commit is contained in:
tibbi 2018-02-17 11:35:01 +01:00
parent f4f2a2ccbb
commit 25e4564b1e

View File

@ -42,6 +42,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
private lateinit var folderDrawable: Drawable private lateinit var folderDrawable: Drawable
private lateinit var fileDrawable: Drawable private lateinit var fileDrawable: Drawable
private var currentItemsHash = fileDirItems.hashCode()
init { init {
initDrawables() initDrawables()
@ -387,10 +388,13 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
} }
fun updateItems(newItems: MutableList<FileDirItem>) { fun updateItems(newItems: MutableList<FileDirItem>) {
if (newItems.hashCode() != currentItemsHash) {
currentItemsHash = newItems.hashCode()
fileDirItems = newItems fileDirItems = newItems
notifyDataSetChanged() notifyDataSetChanged()
finishActMode() finishActMode()
} }
}
override fun onViewRecycled(holder: ViewHolder?) { override fun onViewRecycled(holder: ViewHolder?) {
super.onViewRecycled(holder) super.onViewRecycled(holder)