Skip to content

Instantly share code, notes, and snippets.

@sonique6784
Last active December 16, 2022 21:00
Show Gist options
  • Save sonique6784/57e98247d677e98c2c0b793ebff1f6b2 to your computer and use it in GitHub Desktop.
Save sonique6784/57e98247d677e98c2c0b793ebff1f6b2 to your computer and use it in GitHub Desktop.
MotionEventPredicor setup
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class InputView : View {
// init motion predictor
val motionEventPredicor: MotionEventPredicor = MotionEventPredictor.newInstance(this)
setOnTouchListener
{
_, event ->
// record MotionEvent
motionEventPredictor.record(event)
}
// predict next MotionEvent
val event = motionEventPredictor.predict()
// then inject the motion event into your processing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment