recreate Subsampling Scale Imageview if some option related to it changed

This commit is contained in:
tibbi 2018-09-28 19:25:07 +02:00
parent fe186bcabc
commit e062872a29

View file

@ -71,6 +71,9 @@ class PhotoFragment : ViewPagerFragment() {
private var storedShowExtendedDetails = false private var storedShowExtendedDetails = false
private var storedHideExtendedDetails = false private var storedHideExtendedDetails = false
private var storedAllowDeepZoomableImages = false
private var storedShowHighestQuality = false
private var storedAllowOneFingerZoom = false
private var storedExtendedDetails = 0 private var storedExtendedDetails = 0
lateinit var view: ViewGroup lateinit var view: ViewGroup
@ -155,18 +158,26 @@ class PhotoFragment : ViewPagerFragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (wasInit && (context!!.config.showExtendedDetails != storedShowExtendedDetails || context!!.config.extendedDetails != storedExtendedDetails)) { val config = context!!.config
if (wasInit && (config.showExtendedDetails != storedShowExtendedDetails || config.extendedDetails != storedExtendedDetails)) {
initExtendedDetails() initExtendedDetails()
} }
val allowPhotoGestures = context!!.config.allowPhotoGestures if (wasInit && (config.allowZoomingImages != storedAllowDeepZoomableImages || config.showHighestQuality != storedShowHighestQuality ||
val allowInstantChange = context!!.config.allowInstantChange config.oneFingerZoom != storedAllowOneFingerZoom)) {
isSubsamplingVisible = false
view.subsampling_view.beGone()
loadImage()
}
val allowPhotoGestures = config.allowPhotoGestures
val allowInstantChange = config.allowInstantChange
view.apply { view.apply {
photo_brightness_controller.beVisibleIf(allowPhotoGestures) photo_brightness_controller.beVisibleIf(allowPhotoGestures)
instant_prev_item.beVisibleIf(allowInstantChange) instant_prev_item.beVisibleIf(allowInstantChange)
instant_next_item.beVisibleIf(allowInstantChange) instant_next_item.beVisibleIf(allowInstantChange)
photo_view.setAllowFingerDragZoom(activity!!.config.oneFingerZoom) photo_view.setAllowFingerDragZoom(config.oneFingerZoom)
} }
storeStateVariables() storeStateVariables()
@ -188,6 +199,9 @@ class PhotoFragment : ViewPagerFragment() {
context!!.config.apply { context!!.config.apply {
storedShowExtendedDetails = showExtendedDetails storedShowExtendedDetails = showExtendedDetails
storedHideExtendedDetails = hideExtendedDetails storedHideExtendedDetails = hideExtendedDetails
storedAllowDeepZoomableImages = allowZoomingImages
storedShowHighestQuality = showHighestQuality
storedAllowOneFingerZoom = oneFingerZoom
storedExtendedDetails = extendedDetails storedExtendedDetails = extendedDetails
} }
} }
@ -369,9 +383,7 @@ class PhotoFragment : ViewPagerFragment() {
view.subsampling_view.apply { view.subsampling_view.apply {
setMaxTileSize(4096) setMaxTileSize(4096)
if (!context!!.config.showHighestQuality) { setMinimumTileDpi(if (context!!.config.showHighestQuality) -1 else getMinTileDpi())
setMinimumTileDpi(getMinTileDpi())
}
background = ColorDrawable(Color.TRANSPARENT) background = ColorDrawable(Color.TRANSPARENT)
setBitmapDecoderFactory { PicassoDecoder(path, Picasso.get(), rotation) } setBitmapDecoderFactory { PicassoDecoder(path, Picasso.get(), rotation) }
setRegionDecoderFactory { PicassoRegionDecoder() } setRegionDecoderFactory { PicassoRegionDecoder() }