mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
tweak the functionality of Glide ImageDecoder
This commit is contained in:
parent
3341a70a4d
commit
2c2ae9b6c4
3 changed files with 11 additions and 3 deletions
|
@ -13,7 +13,6 @@ import com.simplemobiletools.gallery.extensions.config
|
|||
import com.simplemobiletools.gallery.helpers.SLIDESHOW_DEFAULT_INTERVAL
|
||||
import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
||||
|
||||
|
||||
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||
val view: View
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
val options = RequestOptions()
|
||||
.signature(medium.path.getFileSignature())
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.override(targetWidth, targetHeight)
|
||||
|
||||
Glide.with(this)
|
||||
|
@ -201,6 +201,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.visibility == View.GONE) {
|
||||
view.subsampling_view.apply {
|
||||
setBitmapDecoderClass(GlideDecoder::class.java)
|
||||
setMaxTileSize(10000)
|
||||
maxScale = 10f
|
||||
beVisible()
|
||||
setImage(ImageSource.uri(medium.path))
|
||||
|
|
|
@ -11,17 +11,25 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.davemorrissey.labs.subscaleview.decoder.ImageDecoder
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.getFileSignature
|
||||
|
||||
class GlideDecoder : ImageDecoder {
|
||||
override fun decode(context: Context, uri: Uri): Bitmap {
|
||||
val exif = android.media.ExifInterface(uri.path)
|
||||
val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL)
|
||||
|
||||
val targetWidth = if (ViewPagerActivity.screenWidth == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenWidth
|
||||
val targetHeight = if (ViewPagerActivity.screenHeight == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenHeight
|
||||
|
||||
val options = RequestOptions()
|
||||
.signature(uri.path.getFileSignature())
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.transform(GlideRotateTransformation(context, getRotationDegrees(orientation)))
|
||||
.override(targetWidth, targetHeight)
|
||||
|
||||
val drawable = Glide.with(context)
|
||||
.load(uri)
|
||||
|
|
Loading…
Reference in a new issue