diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index e50ee4eea..2399a6aa1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -757,10 +757,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun setupAdapter(dirs: ArrayList) { val currAdapter = directories_grid.adapter + val directories = dirs.clone() as ArrayList if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller - DirectoryAdapter(this, dirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { + DirectoryAdapter(this, directories, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { val path = (it as Directory).path if (path != config.tempFolderPath) { itemClicked(path) @@ -770,7 +771,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { directories_grid.adapter = this } } else { - (currAdapter as DirectoryAdapter).updateDirs(dirs) + (currAdapter as DirectoryAdapter).updateDirs(directories) } setupScrollDirection() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 25f0a2e63..adcbc7484 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -312,18 +312,19 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { return } + val media = mMedia.clone() as ArrayList val currAdapter = media_grid.adapter if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) media_horizontal_fastscroller else media_vertical_fastscroller - MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid, fastscroller) { + MediaAdapter(this, media, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid, fastscroller) { itemClicked((it as Medium).path) }.apply { setupZoomListener(mZoomListener) media_grid.adapter = this } } else { - (currAdapter as MediaAdapter).updateMedia(mMedia) + (currAdapter as MediaAdapter).updateMedia(media) } setupScrollDirection() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index b44e0f7f4..2a5712912 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -409,7 +409,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList) { if (newDirs.hashCode() != currentDirectoriesHash) { currentDirectoriesHash = newDirs.hashCode() - dirs = newDirs.clone() as ArrayList + dirs = newDirs notifyDataSetChanged() finishActMode() fastScroller?.measureRecyclerView() 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 a2e963800..c501eb471 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -288,7 +288,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, if (newMedia.hashCode() != currentMediaHash) { currentMediaHash = newMedia.hashCode() Handler().postDelayed({ - media = newMedia.clone() as ArrayList + media = newMedia enableInstantLoad() notifyDataSetChanged() finishActMode()