use event.rawX/Y instead of x/y everywhere

This commit is contained in:
tibbi 2022-11-02 18:08:14 +01:00
parent 2703ae1135
commit ccc6f33837
5 changed files with 29 additions and 29 deletions

View file

@ -544,15 +544,15 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
private fun handleEvent(event: MotionEvent) {
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
mTouchDownX = event.x
mTouchDownY = event.y
mTouchDownX = event.rawX
mTouchDownY = event.rawY
mTouchDownTime = System.currentTimeMillis()
mProgressAtDown = mExoPlayer!!.currentPosition
}
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
MotionEvent.ACTION_MOVE -> {
val diffX = event.x - mTouchDownX
val diffY = event.y - mTouchDownY
val diffX = event.rawX - mTouchDownX
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) {
@ -574,8 +574,8 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
}
}
MotionEvent.ACTION_UP -> {
val diffX = mTouchDownX - event.x
val diffY = mTouchDownY - event.y
val diffX = mTouchDownX - event.rawX
val diffY = mTouchDownY - event.rawY
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold &&

View file

@ -136,16 +136,16 @@ abstract class ViewPagerFragment : Fragment() {
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
mTouchDownTime = System.currentTimeMillis()
mTouchDownX = event.x
mTouchDownY = event.y
mTouchDownX = event.rawX
mTouchDownY = event.rawY
}
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
val diffX = mTouchDownX - event.x
val diffY = mTouchDownY - event.y
val diffX = mTouchDownX - event.rawX
val diffY = mTouchDownY - event.rawY
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?.overridePendingTransition(0, R.anim.slide_down)
}

View file

@ -55,8 +55,8 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
}
override fun onTouchEvent(event: MotionEvent): Boolean {
val x = event.x
val y = event.y
val x = event.rawX
val y = event.rawY
when (event.action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_DOWN -> {

View file

@ -36,13 +36,13 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
mTouchDownX = event.x
mTouchDownY = event.y
mTouchDownX = event.rawX
mTouchDownY = event.rawY
mTouchDownTime = System.currentTimeMillis()
}
MotionEvent.ACTION_UP -> {
val diffX = mTouchDownX - event.x
val diffY = mTouchDownY - event.y
val diffX = mTouchDownX - event.rawX
val diffY = mTouchDownY - event.rawY
if (Math.abs(diffX) < CLICK_MAX_DISTANCE && Math.abs(diffY) < CLICK_MAX_DISTANCE && System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) {
performClick()
}
@ -52,12 +52,12 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
return false
}
val diffX = mTouchDownX - event.x
val diffY = mTouchDownY - event.y
val diffX = mTouchDownX - event.rawX
val diffY = mTouchDownY - event.rawY
if (Math.abs(diffX) > dragThreshold || Math.abs(diffY) > dragThreshold) {
if (!passTouches) {
event.action = MotionEvent.ACTION_DOWN
event.setLocation(event.rawX, event.y)
event.setLocation(event.rawX, event.rawY)
parentView?.dispatchTouchEvent(event)
}
passTouches = true

View file

@ -87,9 +87,9 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
gestureDetector.onTouchEvent(event)
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
mTouchDownX = event.x
mTouchDownY = event.y
mLastTouchY = event.y
mTouchDownX = event.rawX
mTouchDownY = event.rawY
mLastTouchY = event.rawY
mTouchDownTime = System.currentTimeMillis()
if (mIsBrightnessScroll) {
if (mTouchDownValue == -1) {
@ -100,15 +100,15 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
}
}
MotionEvent.ACTION_MOVE -> {
val diffX = mTouchDownX - event.x
val diffY = mTouchDownY - event.y
val diffX = mTouchDownX - event.rawX
val diffY = mTouchDownY - event.rawY
if (Math.abs(diffY) > dragThreshold && Math.abs(diffY) > Math.abs(diffX)) {
var percent = ((diffY / mViewHeight) * 100).toInt() * 3
percent = Math.min(100, Math.max(-100, percent))
if ((percent == 100 && event.y > mLastTouchY) || (percent == -100 && event.y < mLastTouchY)) {
mTouchDownY = event.y
if ((percent == 100 && event.rawY > mLastTouchY) || (percent == -100 && event.rawY < mLastTouchY)) {
mTouchDownY = event.rawY
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) {
if (!mPassTouches) {
event.action = MotionEvent.ACTION_DOWN
event.setLocation(event.rawX, event.y)
event.setLocation(event.rawX, event.rawY)
mParentView?.dispatchTouchEvent(event)
}
mPassTouches = true
mParentView?.dispatchTouchEvent(event)
return false
}
mLastTouchY = event.y
mLastTouchY = event.rawY
}
MotionEvent.ACTION_UP -> {
if (mIsBrightnessScroll) {