From 87436720b8a3b637e422b8ee37cce9d9679614ef Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Dec 2018 21:51:27 +0100 Subject: [PATCH] updating SubsamplingScaleImageView to 4.0.0 --- app/build.gradle | 5 +++-- .../gallery/pro/fragments/PhotoFragment.kt | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aa7e98b3c..818617211 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.5.4' + implementation 'com.simplemobiletools:commons:5.5.15' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.0' implementation 'it.sephiroth.android.exif:library:1.0.1' @@ -77,7 +77,8 @@ dependencies { annotationProcessor 'androidx.room:room-compiler:2.0.0' //implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' - implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' + //implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' + implementation 'com.github.tibbi:subsampling-scale-image-view:4.0.0' // implementation 'com.github.chrisbanes:PhotoView:2.1.4' implementation 'com.github.tibbi:PhotoView:2.2.1-fork' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 0580e2a48..372bc7b0c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -26,6 +26,9 @@ import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestOptions import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import com.davemorrissey.labs.subscaleview.decoder.DecoderFactory +import com.davemorrissey.labs.subscaleview.decoder.ImageDecoder +import com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.gallery.pro.R @@ -377,18 +380,26 @@ class PhotoFragment : ViewPagerFragment() { val path = getPathToLoad(medium) isSubsamplingVisible = true + val bitmapDecoder = object : DecoderFactory { + override fun make() = PicassoDecoder(path, Picasso.get(), rotation) + } + + val regionDecoder = object : DecoderFactory { + override fun make() = PicassoRegionDecoder() + } + view.subsampling_view.apply { setMaxTileSize(if (context!!.config.showHighestQuality) Integer.MAX_VALUE else 4096) setMinimumTileDpi(if (context!!.config.showHighestQuality) -1 else getMinTileDpi()) background = ColorDrawable(Color.TRANSPARENT) - setBitmapDecoderFactory { PicassoDecoder(path, Picasso.get(), rotation) } - setRegionDecoderFactory { PicassoRegionDecoder() } + setBitmapDecoderFactory(bitmapDecoder) + setRegionDecoderFactory(regionDecoder) maxScale = 10f beVisible() isQuickScaleEnabled = context.config.oneFingerZoom setResetScaleOnSizeChange(false) setImage(ImageSource.uri(path)) - orientation = rotation + setOrientation(rotation) setEagerLoadingEnabled(false) setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener { override fun onImageLoaded() { @@ -402,7 +413,7 @@ class PhotoFragment : ViewPagerFragment() { mOriginalSubsamplingScale = scale } - override fun onTileLoadError(e: Exception?) { + override fun onTileLoadError(e: Exception) { } override fun onPreviewReleased() { @@ -415,7 +426,7 @@ class PhotoFragment : ViewPagerFragment() { beGone() } - override fun onPreviewLoadError(e: Exception?) { + override fun onPreviewLoadError(e: Exception) { background = ColorDrawable(Color.TRANSPARENT) isSubsamplingVisible = false beGone()