properly handle image rotation with picasso

This commit is contained in:
tibbi 2019-01-20 22:39:40 +01:00
parent 7a408e050d
commit 63d8462ce0

View file

@ -335,7 +335,6 @@ class PhotoFragment : ViewPagerFragment() {
} }
private fun loadSVG() { private fun loadSVG() {
setupGestureView()
Glide.with(context!!) Glide.with(context!!)
.`as`(PictureDrawable::class.java) .`as`(PictureDrawable::class.java)
.listener(SvgSoftwareLayerSetter()) .listener(SvgSoftwareLayerSetter())
@ -356,9 +355,10 @@ class PhotoFragment : ViewPagerFragment() {
if (degrees != 0) { if (degrees != 0) {
picasso.rotate(degrees.toFloat()) picasso.rotate(degrees.toFloat())
} else {
degreesForRotation(mImageOrientation).toFloat()
} }
setupGestureView()
picasso.into(mView.gestures_view, object : Callback { picasso.into(mView.gestures_view, object : Callback {
override fun onSuccess() { override fun onSuccess() {
mView.gestures_view.controller.settings.isZoomEnabled = degrees != 0 || context?.config?.allowZoomingImages == false mView.gestures_view.controller.settings.isZoomEnabled = degrees != 0 || context?.config?.allowZoomingImages == false
@ -377,13 +377,6 @@ class PhotoFragment : ViewPagerFragment() {
} }
} }
private fun setupGestureView() {
mView.gestures_view.controller.apply {
settings.maxZoom = 3f
settings.overzoomFactor = 1.2f
}
}
private fun tryLoadingWithGlide() { private fun tryLoadingWithGlide() {
var targetWidth = if (mScreenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenWidth var targetWidth = if (mScreenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenWidth
var targetHeight = if (mScreenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenHeight var targetHeight = if (mScreenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenHeight
@ -456,9 +449,9 @@ class PhotoFragment : ViewPagerFragment() {
isQuickScaleEnabled = config.oneFingerZoom isQuickScaleEnabled = config.oneFingerZoom
isOneToOneZoomEnabled = config.allowOneToOneZoom isOneToOneZoomEnabled = config.allowOneToOneZoom
setResetScaleOnSizeChange(false) setResetScaleOnSizeChange(false)
setImage(ImageSource.uri(path))
setOrientation(rotation) setOrientation(rotation)
setEagerLoadingEnabled(false) setEagerLoadingEnabled(false)
setImage(ImageSource.uri(path))
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener { setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
override fun onImageLoaded() { override fun onImageLoaded() {
} }