fix #168, do not autoplay gifs at thumbnails if chosen so
This commit is contained in:
parent
ec11041cda
commit
f67ce86cf2
5 changed files with 35 additions and 10 deletions
|
@ -47,6 +47,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private var mIsSetWallpaperIntent = false
|
||||
private var mIsThirdPartyIntent = false
|
||||
private var mIsGettingDirs = false
|
||||
private var mStoredAnimateGifs = true
|
||||
|
||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||
|
||||
|
@ -65,6 +66,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
directories_holder.setOnRefreshListener({ getDirectories() })
|
||||
mDirs = ArrayList<Directory>()
|
||||
mStoredAnimateGifs = config.animateGifs
|
||||
storeStoragePaths()
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mStoredAnimateGifs != config.animateGifs) {
|
||||
mDirs.clear()
|
||||
}
|
||||
tryloadGallery()
|
||||
}
|
||||
|
||||
|
@ -104,6 +109,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
storeDirectories()
|
||||
directories_holder.isRefreshing = false
|
||||
mIsGettingDirs = false
|
||||
mStoredAnimateGifs = config.animateGifs
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
@ -44,6 +44,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private var mIsGettingMedia = false
|
||||
private var mShowAll = false
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mStoredAnimateGifs = true
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -56,6 +57,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
media_holder.setOnRefreshListener({ getMedia() })
|
||||
mPath = intent.getStringExtra(DIRECTORY)
|
||||
mStoredAnimateGifs = config.animateGifs
|
||||
mShowAll = config.showAll
|
||||
if (mShowAll)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||
|
@ -63,6 +65,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mShowAll && mStoredAnimateGifs != config.animateGifs) {
|
||||
mMedia.clear()
|
||||
}
|
||||
tryloadGallery()
|
||||
}
|
||||
|
||||
|
@ -71,6 +76,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
mCurrAsyncTask?.shouldStop = true
|
||||
mIsGettingMedia = false
|
||||
media_holder.isRefreshing = false
|
||||
mStoredAnimateGifs = config.animateGifs
|
||||
}
|
||||
|
||||
private fun tryloadGallery() {
|
||||
|
|
|
@ -15,10 +15,7 @@ import com.bumptech.glide.signature.StringSignature
|
|||
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.extensions.isAStorageRootFolder
|
||||
import com.simplemobiletools.commons.extensions.isImageVideoGif
|
||||
import com.simplemobiletools.commons.extensions.scanPaths
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||
|
@ -43,6 +40,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
val markedItems = HashSet<Int>()
|
||||
var foregroundColor = 0
|
||||
var backgroundColor = 0
|
||||
var animateGifs = true
|
||||
|
||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||
getProperView(itemView).isSelected = select
|
||||
|
@ -67,6 +65,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
init {
|
||||
foregroundColor = config.primaryColor
|
||||
backgroundColor = config.backgroundColor
|
||||
animateGifs = config.animateGifs
|
||||
}
|
||||
|
||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
|
@ -332,9 +331,14 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
|
||||
val tmb = directory.thumbnail
|
||||
val timestampSignature = StringSignature(directory.date_modified.toString())
|
||||
if (tmb.toLowerCase().endsWith(".gif")) {
|
||||
if (tmb.isGif()) {
|
||||
if (animateGifs) {
|
||||
Glide.with(activity).load(tmb).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature)
|
||||
.placeholder(backgroundColor).centerCrop().crossFade().into(itemView.dir_thumbnail)
|
||||
} else {
|
||||
Glide.with(activity).load(tmb).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
||||
.placeholder(backgroundColor).centerCrop().into(itemView.dir_thumbnail)
|
||||
}
|
||||
} else if (tmb.toLowerCase().endsWith(".png")) {
|
||||
Glide.with(activity).load(tmb).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||
.signature(timestampSignature).placeholder(backgroundColor).centerCrop().into(itemView.dir_thumbnail)
|
||||
|
|
|
@ -39,6 +39,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
val markedItems = HashSet<Int>()
|
||||
var foregroundColor = 0
|
||||
var backgroundColor = 0
|
||||
var animateGifs = true
|
||||
|
||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||
getProperView(itemView).isSelected = select
|
||||
|
@ -63,6 +64,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
init {
|
||||
foregroundColor = config.primaryColor
|
||||
backgroundColor = config.backgroundColor
|
||||
animateGifs = config.animateGifs
|
||||
}
|
||||
|
||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
|
@ -242,7 +244,13 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
val path = medium.path
|
||||
val timestampSignature = StringSignature(medium.date_modified.toString())
|
||||
if (medium.isGif()) {
|
||||
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(itemView.medium_thumbnail)
|
||||
if (animateGifs) {
|
||||
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature)
|
||||
.placeholder(backgroundColor).centerCrop().crossFade().into(itemView.medium_thumbnail)
|
||||
} else {
|
||||
Glide.with(activity).load(path).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature)
|
||||
.placeholder(backgroundColor).centerCrop().into(itemView.medium_thumbnail)
|
||||
}
|
||||
} else if (medium.isPng()) {
|
||||
Glide.with(activity).load(path).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||
.signature(timestampSignature).placeholder(backgroundColor).centerCrop().into(itemView.medium_thumbnail)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.gallery.models
|
||||
|
||||
import com.simplemobiletools.commons.extensions.isGif
|
||||
import com.simplemobiletools.gallery.helpers.SORT_BY_DATE_MODIFIED
|
||||
import com.simplemobiletools.gallery.helpers.SORT_BY_NAME
|
||||
import com.simplemobiletools.gallery.helpers.SORT_BY_SIZE
|
||||
|
@ -12,9 +13,9 @@ data class Medium(val name: String, var path: String, val isVideo: Boolean, val
|
|||
var sorting: Int = 0
|
||||
}
|
||||
|
||||
fun isGif() = path.toLowerCase().endsWith(".gif")
|
||||
fun isGif() = path.isGif()
|
||||
|
||||
fun isPng() = path.toLowerCase().endsWith(".png")
|
||||
fun isPng() = path.endsWith(".png", true)
|
||||
|
||||
fun isImage() = !isGif() && !isVideo
|
||||
|
||||
|
|
Loading…
Reference in a new issue