allow closing down GestureViews only if it is zoomed out

This commit is contained in:
tibbi 2019-01-17 17:20:29 +01:00
parent c62b4205e9
commit 246bf90895

View file

@ -14,6 +14,8 @@ import android.util.DisplayMetrics
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.alexvasilkov.gestures.GestureController
import com.alexvasilkov.gestures.State
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
@ -70,6 +72,7 @@ class PhotoFragment : ViewPagerFragment() {
private var mIoadZoomableViewHandler = Handler() private var mIoadZoomableViewHandler = Handler()
private var mScreenWidth = 0 private var mScreenWidth = 0
private var mScreenHeight = 0 private var mScreenHeight = 0
private var mCurrentGestureViewZoom = 1f
private var mStoredShowExtendedDetails = false private var mStoredShowExtendedDetails = false
private var mStoredHideExtendedDetails = false private var mStoredHideExtendedDetails = false
@ -105,13 +108,23 @@ class PhotoFragment : ViewPagerFragment() {
} }
if (context.config.allowDownGesture) { if (context.config.allowDownGesture) {
gestures_view.controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener {
override fun onStateReset(oldState: State, newState: State) {}
override fun onStateChanged(state: State) {
mCurrentGestureViewZoom = state.zoom
}
})
gestures_view.setOnTouchListener { v, event -> gestures_view.setOnTouchListener { v, event ->
if (mCurrentGestureViewZoom == 1f) {
handleEvent(event) handleEvent(event)
}
false false
} }
subsampling_view.setOnTouchListener { v, event -> subsampling_view.setOnTouchListener { v, event ->
if (mView.subsampling_view.scale == mOriginalSubsamplingScale) { if (subsampling_view.scale == mOriginalSubsamplingScale) {
handleEvent(event) handleEvent(event)
} }
false false