mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
style update + wrap gifDrawables in try/catch
This commit is contained in:
@@ -75,11 +75,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||||||
|
|
||||||
media_refresh_layout.setOnRefreshListener({ getMedia() })
|
media_refresh_layout.setOnRefreshListener({ getMedia() })
|
||||||
mPath = intent.getStringExtra(DIRECTORY)
|
mPath = intent.getStringExtra(DIRECTORY)
|
||||||
mStoredAnimateGifs = config.animateGifs
|
storeStateVariables()
|
||||||
mStoredCropThumbnails = config.cropThumbnails
|
|
||||||
mStoredScrollHorizontally = config.scrollHorizontally
|
|
||||||
mStoredTextColor = config.textColor
|
|
||||||
mShowAll = config.showAll
|
|
||||||
if (mShowAll)
|
if (mShowAll)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||||
|
|
||||||
@@ -117,10 +113,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||||||
super.onPause()
|
super.onPause()
|
||||||
mIsGettingMedia = false
|
mIsGettingMedia = false
|
||||||
media_refresh_layout.isRefreshing = false
|
media_refresh_layout.isRefreshing = false
|
||||||
mStoredAnimateGifs = config.animateGifs
|
storeStateVariables()
|
||||||
mStoredCropThumbnails = config.cropThumbnails
|
|
||||||
mStoredScrollHorizontally = config.scrollHorizontally
|
|
||||||
mStoredTextColor = config.textColor
|
|
||||||
media_grid.listener = null
|
media_grid.listener = null
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
@@ -136,6 +129,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||||||
mMedia.clear()
|
mMedia.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun storeStateVariables() {
|
||||||
|
config.apply {
|
||||||
|
mStoredAnimateGifs = animateGifs
|
||||||
|
mStoredCropThumbnails = cropThumbnails
|
||||||
|
mStoredScrollHorizontally = scrollHorizontally
|
||||||
|
mStoredTextColor = textColor
|
||||||
|
mShowAll = showAll
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun tryloadGallery() {
|
private fun tryloadGallery() {
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
@@ -301,8 +301,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateDisplayFilenames(display: Boolean) {
|
fun updateDisplayFilenames(displayFilenames: Boolean) {
|
||||||
displayFilenames = display
|
this.displayFilenames = displayFilenames
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -146,15 +146,19 @@ fun Activity.loadImage(path: String, target: MySquareImageView, horizontalScroll
|
|||||||
loadJpg(path, target, cropThumbnails)
|
loadJpg(path, target, cropThumbnails)
|
||||||
}
|
}
|
||||||
} else if (path.isGif()) {
|
} else if (path.isGif()) {
|
||||||
val gifDrawable = GifDrawable(path)
|
try {
|
||||||
target.setImageDrawable(gifDrawable)
|
val gifDrawable = GifDrawable(path)
|
||||||
if (animateGifs) {
|
target.setImageDrawable(gifDrawable)
|
||||||
gifDrawable.start()
|
if (animateGifs) {
|
||||||
} else {
|
gifDrawable.start()
|
||||||
gifDrawable.stop()
|
} 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user