use event.rawX/Y instead of x/y everywhere
This commit is contained in:
parent
2703ae1135
commit
ccc6f33837
5 changed files with 29 additions and 29 deletions
|
@ -544,15 +544,15 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||||
private fun handleEvent(event: MotionEvent) {
|
private fun handleEvent(event: MotionEvent) {
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mTouchDownX = event.x
|
mTouchDownX = event.rawX
|
||||||
mTouchDownY = event.y
|
mTouchDownY = event.rawY
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
mProgressAtDown = mExoPlayer!!.currentPosition
|
mProgressAtDown = mExoPlayer!!.currentPosition
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val diffX = event.x - mTouchDownX
|
val diffX = event.rawX - mTouchDownX
|
||||||
val diffY = event.y - mTouchDownY
|
val diffY = event.rawY - mTouchDownY
|
||||||
|
|
||||||
if (mIsDragged || (Math.abs(diffX) > mDragThreshold && Math.abs(diffX) > Math.abs(diffY)) && video_surface_frame.controller.state.zoom == 1f) {
|
if (mIsDragged || (Math.abs(diffX) > mDragThreshold && Math.abs(diffX) > Math.abs(diffY)) && video_surface_frame.controller.state.zoom == 1f) {
|
||||||
if (!mIsDragged) {
|
if (!mIsDragged) {
|
||||||
|
@ -574,8 +574,8 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.rawY
|
||||||
|
|
||||||
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
||||||
if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold &&
|
if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold &&
|
||||||
|
|
|
@ -136,16 +136,16 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
mTouchDownX = event.x
|
mTouchDownX = event.rawX
|
||||||
mTouchDownY = event.y
|
mTouchDownY = event.rawY
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.rawY
|
||||||
|
|
||||||
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
||||||
if (!mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold && downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && context?.config?.allowDownGesture == true) {
|
if (!mIgnoreCloseDown && (Math.abs(diffY) > Math.abs(diffX)) && (diffY < -mCloseDownThreshold) && downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && context?.config?.allowDownGesture == true) {
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
activity?.overridePendingTransition(0, R.anim.slide_down)
|
activity?.overridePendingTransition(0, R.anim.slide_down)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
val x = event.x
|
val x = event.rawX
|
||||||
val y = event.y
|
val y = event.rawY
|
||||||
|
|
||||||
when (event.action and MotionEvent.ACTION_MASK) {
|
when (event.action and MotionEvent.ACTION_MASK) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
|
|
@ -36,13 +36,13 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
||||||
|
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mTouchDownX = event.x
|
mTouchDownX = event.rawX
|
||||||
mTouchDownY = event.y
|
mTouchDownY = event.rawY
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.rawY
|
||||||
if (Math.abs(diffX) < CLICK_MAX_DISTANCE && Math.abs(diffY) < CLICK_MAX_DISTANCE && System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) {
|
if (Math.abs(diffX) < CLICK_MAX_DISTANCE && Math.abs(diffY) < CLICK_MAX_DISTANCE && System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) {
|
||||||
performClick()
|
performClick()
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.rawY
|
||||||
if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
||||||
if (!passTouches) {
|
if (!passTouches) {
|
||||||
event.action = MotionEvent.ACTION_DOWN
|
event.action = MotionEvent.ACTION_DOWN
|
||||||
event.setLocation(event.rawX, event.y)
|
event.setLocation(event.rawX, event.rawY)
|
||||||
parentView?.dispatchTouchEvent(event)
|
parentView?.dispatchTouchEvent(event)
|
||||||
}
|
}
|
||||||
passTouches = true
|
passTouches = true
|
||||||
|
|
|
@ -87,9 +87,9 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
gestureDetector.onTouchEvent(event)
|
gestureDetector.onTouchEvent(event)
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mTouchDownX = event.x
|
mTouchDownX = event.rawX
|
||||||
mTouchDownY = event.y
|
mTouchDownY = event.rawY
|
||||||
mLastTouchY = event.y
|
mLastTouchY = event.rawY
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
if (mIsBrightnessScroll) {
|
if (mIsBrightnessScroll) {
|
||||||
if (mTouchDownValue == -1) {
|
if (mTouchDownValue == -1) {
|
||||||
|
@ -100,15 +100,15 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.y
|
val diffY = mTouchDownY - event.rawY
|
||||||
|
|
||||||
if (Math.abs(diffY) > dragThreshold && Math.abs(diffY) > Math.abs(diffX)) {
|
if (Math.abs(diffY) > dragThreshold && Math.abs(diffY) > Math.abs(diffX)) {
|
||||||
var percent = ((diffY / mViewHeight) * 100).toInt() * 3
|
var percent = ((diffY / mViewHeight) * 100).toInt() * 3
|
||||||
percent = Math.min(100, Math.max(-100, percent))
|
percent = Math.min(100, Math.max(-100, percent))
|
||||||
|
|
||||||
if ((percent == 100 && event.y > mLastTouchY) || (percent == -100 && event.y < mLastTouchY)) {
|
if ((percent == 100 && event.rawY > mLastTouchY) || (percent == -100 && event.rawY < mLastTouchY)) {
|
||||||
mTouchDownY = event.y
|
mTouchDownY = event.rawY
|
||||||
mTouchDownValue = if (mIsBrightnessScroll) mTempBrightness else getCurrentVolume()
|
mTouchDownValue = if (mIsBrightnessScroll) mTempBrightness else getCurrentVolume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
} else if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
} else if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
|
||||||
if (!mPassTouches) {
|
if (!mPassTouches) {
|
||||||
event.action = MotionEvent.ACTION_DOWN
|
event.action = MotionEvent.ACTION_DOWN
|
||||||
event.setLocation(event.rawX, event.y)
|
event.setLocation(event.rawX, event.rawY)
|
||||||
mParentView?.dispatchTouchEvent(event)
|
mParentView?.dispatchTouchEvent(event)
|
||||||
}
|
}
|
||||||
mPassTouches = true
|
mPassTouches = true
|
||||||
mParentView?.dispatchTouchEvent(event)
|
mParentView?.dispatchTouchEvent(event)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mLastTouchY = event.y
|
mLastTouchY = event.rawY
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
if (mIsBrightnessScroll) {
|
if (mIsBrightnessScroll) {
|
||||||
|
|
Loading…
Reference in a new issue