properly scale drag_threshold based on device density
This commit is contained in:
parent
b179c53940
commit
ef51271909
3 changed files with 6 additions and 4 deletions
|
@ -65,7 +65,7 @@ const val NOMEDIA = ".nomedia"
|
|||
const val MAX_COLUMN_COUNT = 20
|
||||
const val SHOW_TEMP_HIDDEN_DURATION = 600000L
|
||||
const val CLICK_MAX_DURATION = 150
|
||||
const val DRAG_THRESHOLD = 15
|
||||
const val DRAG_THRESHOLD = 8
|
||||
|
||||
const val DIRECTORY = "directory"
|
||||
const val MEDIUM = "medium"
|
||||
|
|
|
@ -25,6 +25,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
|||
private var mLastTouchY = 0f
|
||||
private var mIsBrightnessScroll = false
|
||||
private var mPassTouches = false
|
||||
private var dragThreshold = DRAG_THRESHOLD * context.resources.displayMetrics.density
|
||||
|
||||
private var mSlideInfoText = ""
|
||||
private var mSlideInfoFadeHandler = Handler()
|
||||
|
@ -76,7 +77,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
|||
val diffX = mTouchDownX - event.x
|
||||
val diffY = mTouchDownY - event.y
|
||||
|
||||
if (Math.abs(diffY) > DRAG_THRESHOLD && Math.abs(diffY) > Math.abs(diffX)) {
|
||||
if (Math.abs(diffY) > dragThreshold && Math.abs(diffY) > Math.abs(diffX)) {
|
||||
var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 3
|
||||
percent = Math.min(100, Math.max(-100, percent))
|
||||
|
||||
|
@ -86,7 +87,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
|||
}
|
||||
|
||||
percentChanged(percent)
|
||||
} else if (Math.abs(diffX) > DRAG_THRESHOLD || Math.abs(diffY) > DRAG_THRESHOLD) {
|
||||
} else if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
||||
if (!mPassTouches) {
|
||||
event.action = MotionEvent.ACTION_DOWN
|
||||
event.setLocation(event.rawX, event.y)
|
||||
|
|
|
@ -14,6 +14,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
|||
private var mTouchDownX = 0f
|
||||
private var mTouchDownY = 0f
|
||||
private var passTouches = false
|
||||
private var dragThreshold = DRAG_THRESHOLD * context.resources.displayMetrics.density
|
||||
|
||||
var parentView: ViewGroup? = null
|
||||
|
||||
|
@ -50,7 +51,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
|||
|
||||
val diffX = mTouchDownX - event.x
|
||||
val diffY = mTouchDownY - event.y
|
||||
if (Math.abs(diffX) > DRAG_THRESHOLD || Math.abs(diffY) > DRAG_THRESHOLD) {
|
||||
if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
||||
if (!passTouches) {
|
||||
event.action = MotionEvent.ACTION_DOWN
|
||||
event.setLocation(event.rawX, event.y)
|
||||
|
|
Loading…
Reference in a new issue