From 450a9d96e489f76adc1a9ef91cabf8dffb9dd301 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 8 Jan 2019 13:47:23 +0100 Subject: [PATCH] adding some search related crashfix at MediaActivity --- .../gallery/pro/activities/MediaActivity.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index fdca85100..7618bd98b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -320,12 +320,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun searchQueryChanged(text: String) { Thread { - val filtered = mMedia.filter { it is Medium && it.name.contains(text, true) } as ArrayList - filtered.sortBy { it is Medium && !it.name.startsWith(text, true) } - val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList, mPath) - runOnUiThread { - getMediaAdapter()?.updateMedia(grouped) - measureRecyclerViewContent(grouped) + try { + val filtered = mMedia.filter { it is Medium && it.name.contains(text, true) } as ArrayList + filtered.sortBy { it is Medium && !it.name.startsWith(text, true) } + val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList, mPath) + runOnUiThread { + getMediaAdapter()?.updateMedia(grouped) + measureRecyclerViewContent(grouped) + } + } catch (ignored: Exception) { } }.start() }