diff --git a/app/src/main/java/com/simplemobiletools/gallery/adapters/DirectoryAdapter.java b/app/src/main/java/com/simplemobiletools/gallery/adapters/DirectoryAdapter.java index 6571af5b4..7222ad032 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/adapters/DirectoryAdapter.java +++ b/app/src/main/java/com/simplemobiletools/gallery/adapters/DirectoryAdapter.java @@ -10,6 +10,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.signature.StringSignature; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.models.Directory; @@ -44,12 +45,13 @@ public class DirectoryAdapter extends BaseAdapter { viewHolder.dirName.setText(dir.getName()); viewHolder.photoCnt.setText(String.valueOf(dir.getMediaCnt())); final String tmb = dir.getThumbnail(); + final StringSignature timestampSignature = new StringSignature(String.valueOf(dir.getTimestamp())); if (tmb.endsWith(".gif")) { - Glide.with(mContext).load(tmb).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.color.tmb_background) - .centerCrop().crossFade().into(viewHolder.dirThumbnail); + Glide.with(mContext).load(tmb).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature) + .placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.dirThumbnail); } else { - Glide.with(mContext).load(tmb).diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.color.tmb_background) - .centerCrop().crossFade().into(viewHolder.dirThumbnail); + Glide.with(mContext).load(tmb).diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature) + .placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.dirThumbnail); } return convertView; diff --git a/app/src/main/java/com/simplemobiletools/gallery/adapters/MediaAdapter.java b/app/src/main/java/com/simplemobiletools/gallery/adapters/MediaAdapter.java index b82885705..cf3ef4001 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/adapters/MediaAdapter.java +++ b/app/src/main/java/com/simplemobiletools/gallery/adapters/MediaAdapter.java @@ -9,6 +9,7 @@ import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.signature.StringSignature; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.models.Medium; @@ -47,11 +48,12 @@ public class MediaAdapter extends BaseAdapter { } final String path = medium.getPath(); + final StringSignature timestampSignature = new StringSignature(String.valueOf(medium.getTimestamp())); if (medium.isGif()) { - Glide.with(mContext).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(viewHolder.photoThumbnail); + Glide.with(mContext).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(viewHolder.photoThumbnail); } else { - Glide.with(mContext).load(path).diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.color.tmb_background) - .centerCrop().crossFade().into(viewHolder.photoThumbnail); + Glide.with(mContext).load(path).diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature) + .placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.photoThumbnail); } return convertView; diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 0141d2f8e..af5aea4ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -62,7 +62,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener var out: FileOutputStream? = null try { out = FileOutputStream(file) - result.bitmap.compress(getFileExtension(file), 100, out) + result.bitmap.compress(getCompressionFormat(file), 100, out) setResult(Activity.RESULT_OK, intent) } catch (e: Exception) { Log.e(TAG, "Crop compressing failed $e") @@ -83,7 +83,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } - private fun getFileExtension(file: File): Bitmap.CompressFormat { + private fun getCompressionFormat(file: File): Bitmap.CompressFormat { return when (file.extension) { "png" -> Bitmap.CompressFormat.PNG "webp" -> Bitmap.CompressFormat.WEBP