From de63b61bf6b71051a01af2825613f7bcd2123e17 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Jan 2017 12:06:29 +0100 Subject: [PATCH] use a background thread for deleting stuff --- .../gallery/activities/ViewPagerActivity.kt | 4 +++- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 57cfcba2d..3b843fe28 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -160,7 +160,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun askConfirmDelete() { ConfirmationDialog(this) { - deleteFile() + Thread({ + deleteFile() + }).start() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index d0b5059b8..58e989713 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -171,7 +171,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, private fun askConfirmDelete() { ConfirmationDialog(activity) { actMode?.finish() - deleteFiles() + Thread({ + deleteFiles() + }).start() } } @@ -187,7 +189,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, val medium = media[it] files.add(File(medium.path)) removeMedia.add(medium) - notifyItemRemoved(it) + activity.runOnUiThread { + notifyItemRemoved(it) + } } media.removeAll(removeMedia)