load png files as argb_8888 for higher quality
This commit is contained in:
parent
ac9132bf6b
commit
a51083be16
3 changed files with 12 additions and 2 deletions
|
@ -8,6 +8,7 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
|||
import com.bignerdranch.android.multiselector.MultiSelector
|
||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.signature.StringSignature
|
||||
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
||||
|
@ -16,11 +17,11 @@ import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
|
|||
import com.simplemobiletools.filepicker.extensions.scanPaths
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
import kotlinx.android.synthetic.main.directory_item.view.*
|
||||
import kotlinx.android.synthetic.main.directory_tmb.view.*
|
||||
|
@ -223,9 +224,12 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
|
||||
val tmb = directory.thumbnail
|
||||
val timestampSignature = StringSignature(directory.timestamp.toString())
|
||||
if (tmb.endsWith(".gif")) {
|
||||
if (tmb.toLowerCase().endsWith(".gif")) {
|
||||
Glide.with(activity).load(tmb).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature)
|
||||
.placeholder(R.color.tmb_background).centerCrop().crossFade().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(R.color.tmb_background).centerCrop().into(itemView.dir_thumbnail)
|
||||
} else {
|
||||
Glide.with(activity).load(tmb).diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
||||
.placeholder(R.color.tmb_background).centerCrop().crossFade().into(itemView.dir_thumbnail)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
|||
import com.bignerdranch.android.multiselector.MultiSelector
|
||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.signature.StringSignature
|
||||
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
||||
|
@ -188,6 +189,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
val timestampSignature = StringSignature(medium.timestamp.toString())
|
||||
if (medium.isGif()) {
|
||||
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).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(R.color.tmb_background).centerCrop().into(itemView.medium_thumbnail)
|
||||
} else {
|
||||
Glide.with(activity).load(path).diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
||||
.placeholder(R.color.tmb_background).centerCrop().crossFade().into(itemView.medium_thumbnail)
|
||||
|
|
|
@ -13,6 +13,8 @@ class Medium(val name: String, var path: String, val isVideo: Boolean, val times
|
|||
|
||||
fun isGif() = path.toLowerCase().endsWith(".gif")
|
||||
|
||||
fun isPng() = path.toLowerCase().endsWith(".png")
|
||||
|
||||
fun isImage() = !isGif() && !isVideo
|
||||
|
||||
fun getMimeType() = if (isVideo) "video/*" else "image/*"
|
||||
|
|
Loading…
Reference in a new issue