updating SubsamplingScaleImageView to 4.0.0

This commit is contained in:
tibbi 2018-12-11 21:51:27 +01:00
parent f91f1819b0
commit 87436720b8
2 changed files with 19 additions and 7 deletions

View File

@ -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'

View File

@ -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<ImageDecoder> {
override fun make() = PicassoDecoder(path, Picasso.get(), rotation)
}
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
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()