Last active
December 16, 2022 21:00
-
-
Save sonique6784/57e98247d677e98c2c0b793ebff1f6b2 to your computer and use it in GitHub Desktop.
MotionEventPredicor setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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