Skip to content

Commit

Permalink
working on long tap
Browse files Browse the repository at this point in the history
  • Loading branch information
sephiroth74 committed Jan 6, 2019
1 parent 55d4a5b commit 29f1341
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class MainActivity : AppCompatActivity() {
mDelegate = UIGestureRecognizerDelegate()

val recognizer1 = UITapGestureRecognizer(this)
recognizer1.tapsRequired = 2
recognizer1.touchesRequired = 2
recognizer1.tapsRequired = 1
recognizer1.touchesRequired = 1
recognizer1.actionListener = actionListener
recognizer1.stateListener = stateListener

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Interaction {
return performMultiPointerGesture(array.toTypedArray())
}


fun swipe(downX: Int, downY: Int, upX: Int, upY: Int, steps: Int, drag: Boolean = false,
timeout: Long = ViewConfiguration.getLongPressTimeout().toLong()): Boolean {
var ret: Boolean
Expand Down Expand Up @@ -207,7 +208,10 @@ class Interaction {
return performMultiPointerGesture(array.toTypedArray())
}

fun performMultiPointerGesture(touches: Array<Array<PointerCoords>>, sleepBeforeMove: Long = 5): Boolean {
fun performMultiPointerGesture(touches: Array<Array<PointerCoords>>,
sleepBeforeMove: Long = MOTION_EVENT_INJECTION_DELAY_MILLIS.toLong(),
sleepBeforeUp: Long = MOTION_EVENT_INJECTION_DELAY_MILLIS.toLong()):
Boolean {
Log.i(LOG_TAG, "performMultiPointerGesture, size: ${touches.size}")
var ret = true

Expand All @@ -217,7 +221,7 @@ class Interaction {
Log.i(LOG_TAG, "ACTION_DOWN")

// ACTION_DOWN
var currentPointer = touches[0][0]
val currentPointer = touches[0][0]
val downTime = SystemClock.uptimeMillis()
var event: MotionEvent
event =
Expand Down Expand Up @@ -276,7 +280,7 @@ class Interaction {
}
}

SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS.toLong())
SystemClock.sleep(sleepBeforeUp)

// ACTION_POINTER_UP
Log.i(LOG_TAG, "ACTION_POINTER_UP")
Expand Down
Loading

0 comments on commit 29f1341

Please sign in to comment.