Skip to content

Commit 25e4564

Browse files
committed
refresh items only if they changed
1 parent f4f2a2c commit 25e4564

File tree

1 file changed

+7
-3
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/adapters

1 file changed

+7
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
4242

4343
private lateinit var folderDrawable: Drawable
4444
private lateinit var fileDrawable: Drawable
45+
private var currentItemsHash = fileDirItems.hashCode()
4546

4647
init {
4748
initDrawables()
@@ -387,9 +388,12 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
387388
}
388389

389390
fun updateItems(newItems: MutableList<FileDirItem>) {
390-
fileDirItems = newItems
391-
notifyDataSetChanged()
392-
finishActMode()
391+
if (newItems.hashCode() != currentItemsHash) {
392+
currentItemsHash = newItems.hashCode()
393+
fileDirItems = newItems
394+
notifyDataSetChanged()
395+
finishActMode()
396+
}
393397
}
394398

395399
override fun onViewRecycled(holder: ViewHolder?) {

0 commit comments

Comments
 (0)