Back to project page Muse.
The source code is released under:
Apache License
If you think the Android project Muse listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.prt2121.muse; //w w w .ja v a 2s. c o m import com.google.android.glass.touchpad.Gesture; import com.google.android.glass.touchpad.GestureDetector; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.MotionEvent; /** * Created by prt2121 on 10/4/14. */ public class BaseGlassActivity extends Activity { private GestureDetector mGestureDetector; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGestureDetector = createGestureDetector(this); } @Override public boolean onGenericMotionEvent(MotionEvent event) { return mGestureDetector.onMotionEvent(event); } protected boolean onTap() { return false; } protected boolean onTwoTap() { return false; } protected boolean onSwipeRight() { return false; } protected boolean onSwipeLeft() { return false; } private GestureDetector createGestureDetector(Context context) { GestureDetector gestureDetector = new GestureDetector(context); gestureDetector.setBaseListener(new GestureDetector.BaseListener() { @Override public boolean onGesture(Gesture gesture) { if (gesture == Gesture.TAP || gesture == Gesture.LONG_PRESS) { return onTap(); } else if (gesture == Gesture.TWO_TAP) { return onTwoTap(); } else if (gesture == Gesture.SWIPE_RIGHT) { return onSwipeRight(); } else if (gesture == Gesture.SWIPE_LEFT) { return onSwipeLeft(); } return false; } }); return gestureDetector; } }