mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +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 com.simplemobiletools.gallery.helpers.SLIDESHOW_DEFAULT_INTERVAL
|
||||||
import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
||||||
|
|
||||||
|
|
||||||
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||||
val view: View
|
val view: View
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(medium.path.getFileSignature())
|
.signature(medium.path.getFileSignature())
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.override(targetWidth, targetHeight)
|
.override(targetWidth, targetHeight)
|
||||||
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
|
@ -201,6 +201,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.visibility == View.GONE) {
|
if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.visibility == View.GONE) {
|
||||||
view.subsampling_view.apply {
|
view.subsampling_view.apply {
|
||||||
setBitmapDecoderClass(GlideDecoder::class.java)
|
setBitmapDecoderClass(GlideDecoder::class.java)
|
||||||
|
setMaxTileSize(10000)
|
||||||
maxScale = 10f
|
maxScale = 10f
|
||||||
beVisible()
|
beVisible()
|
||||||
setImage(ImageSource.uri(medium.path))
|
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.DecodeFormat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.davemorrissey.labs.subscaleview.decoder.ImageDecoder
|
import com.davemorrissey.labs.subscaleview.decoder.ImageDecoder
|
||||||
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
|
import com.simplemobiletools.gallery.extensions.getFileSignature
|
||||||
|
|
||||||
class GlideDecoder : ImageDecoder {
|
class GlideDecoder : ImageDecoder {
|
||||||
override fun decode(context: Context, uri: Uri): Bitmap {
|
override fun decode(context: Context, uri: Uri): Bitmap {
|
||||||
val exif = android.media.ExifInterface(uri.path)
|
val exif = android.media.ExifInterface(uri.path)
|
||||||
val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL)
|
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()
|
val options = RequestOptions()
|
||||||
|
.signature(uri.path.getFileSignature())
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.transform(GlideRotateTransformation(context, getRotationDegrees(orientation)))
|
.transform(GlideRotateTransformation(context, getRotationDegrees(orientation)))
|
||||||
|
.override(targetWidth, targetHeight)
|
||||||
|
|
||||||
val drawable = Glide.with(context)
|
val drawable = Glide.with(context)
|
||||||
.load(uri)
|
.load(uri)
|
||||||
|
|
Loading…
Reference in a new issue