0

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.

cdedios
  • 5
  • 2
  • 2
    Take a look at the official timer sample here https://github.com/googleglass/gdk-timer-sample Setting the timer is performed with gestures – Simon Marquis Nov 14 '14 at 12:43

1 Answers1

0

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.

Alain
  • 6,044
  • 21
  • 27