improving rotation handling
This commit is contained in:
parent
60da404865
commit
77b4a65ac3
|
@ -75,7 +75,7 @@ dependencies {
|
|||
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||
implementation 'com.caverock:androidsvg-aar:1.3'
|
||||
implementation 'com.github.tibbi:gestureviews:985ba285fb'
|
||||
implementation 'com.github.tibbi:subsampling-scale-image-view:40dc6ee2b1'
|
||||
implementation 'com.github.tibbi:subsampling-scale-image-view:51cb8f922c'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.8.0' // keep it here too, not just in Commons, else loading SVGs wont work
|
||||
|
||||
kapt 'androidx.room:room-compiler:2.0.0'
|
||||
|
|
|
@ -444,6 +444,11 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
override fun make() = PicassoRegionDecoder()
|
||||
}
|
||||
|
||||
var newOrientation = (rotation + mCurrentRotationDegrees) % 360
|
||||
if (newOrientation < 0) {
|
||||
newOrientation += 360
|
||||
}
|
||||
|
||||
val config = context!!.config
|
||||
mView.subsampling_view.apply {
|
||||
setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096)
|
||||
|
@ -454,7 +459,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
maxScale = 10f
|
||||
beVisible()
|
||||
isOneToOneZoomEnabled = config.allowOneToOneZoom
|
||||
orientation = (rotation + mCurrentRotationDegrees) % 360
|
||||
orientation = newOrientation
|
||||
setImage(path)
|
||||
onImageEventListener = object : SubsamplingScaleImageView.OnImageEventListener {
|
||||
override fun onReady() {
|
||||
|
@ -472,16 +477,14 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
override fun onImageRotation(degrees: Int) {
|
||||
if (mCurrentRotationDegrees != degrees) {
|
||||
val fullRotation = (rotation + degrees) % 360
|
||||
val useWidth = if (fullRotation == 90 || fullRotation == 270) sHeight else sWidth
|
||||
val useHeight = if (fullRotation == 90 || fullRotation == 270) sWidth else sHeight
|
||||
doubleTapZoomScale = getDoubleTapZoomScale(useWidth, useHeight)
|
||||
loadBitmap(degrees, false)
|
||||
mCurrentRotationDegrees = (mCurrentRotationDegrees + degrees) % 360
|
||||
loadBitmap(mCurrentRotationDegrees, false)
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
mCurrentRotationDegrees = degrees
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue