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 cdb538151..7a8b1358e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -75,11 +75,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { media_refresh_layout.setOnRefreshListener({ getMedia() }) mPath = intent.getStringExtra(DIRECTORY) - mStoredAnimateGifs = config.animateGifs - mStoredCropThumbnails = config.cropThumbnails - mStoredScrollHorizontally = config.scrollHorizontally - mStoredTextColor = config.textColor - mShowAll = config.showAll + storeStateVariables() if (mShowAll) supportActionBar?.setDisplayHomeAsUpEnabled(false) @@ -117,10 +113,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { super.onPause() mIsGettingMedia = false media_refresh_layout.isRefreshing = false - mStoredAnimateGifs = config.animateGifs - mStoredCropThumbnails = config.cropThumbnails - mStoredScrollHorizontally = config.scrollHorizontally - mStoredTextColor = config.textColor + storeStateVariables() media_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) @@ -136,6 +129,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mMedia.clear() } + private fun storeStateVariables() { + config.apply { + mStoredAnimateGifs = animateGifs + mStoredCropThumbnails = cropThumbnails + mStoredScrollHorizontally = scrollHorizontally + mStoredTextColor = textColor + mShowAll = showAll + } + } + private fun tryloadGallery() { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { 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 46ff5a7cb..eec2636f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -301,8 +301,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, actMode?.finish() } - fun updateDisplayFilenames(display: Boolean) { - displayFilenames = display + fun updateDisplayFilenames(displayFilenames: Boolean) { + this.displayFilenames = displayFilenames notifyDataSetChanged() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index 5bf08e18d..e80f14e8c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -146,15 +146,19 @@ fun Activity.loadImage(path: String, target: MySquareImageView, horizontalScroll loadJpg(path, target, cropThumbnails) } } else if (path.isGif()) { - val gifDrawable = GifDrawable(path) - target.setImageDrawable(gifDrawable) - if (animateGifs) { - gifDrawable.start() - } else { - gifDrawable.stop() - } + try { + val gifDrawable = GifDrawable(path) + target.setImageDrawable(gifDrawable) + if (animateGifs) { + gifDrawable.start() + } else { + gifDrawable.stop() + } - target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER + target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER + } catch (e: Exception) { + showErrorToast(e) + } } }