I would like to know if it's possible to use glass gestures on the touch-pad to implement a number picker. The goal is that when you swipe forward and back a number displayed on the screen increases when you swipe forwards and decreases when you swipe back.
As mentioned in the comment, the Timer sample's SetTimerActivity
uses a GestureDetector
to detect motion events on the touchpad and change the value accordingly.
The main logic is in the ScrollListener#onScroll
implementation:
@Override
public boolean onScroll(float displacement, float delta, float velocity) {
mReleaseVelocity = velocity;
if (!mOptionMenuOpen) {
// Change the value, in this case, the current time in second.
addTimeSeconds(delta * Math.min(Math.abs(velocity), MAX_DRAG_VELOCITY));
}
return true;
}
The other listener implementations are used for adding some physic simulation such as an inertial scrolling effect when the user swipes fast enough.