Code example for GestureDetector

Methods: setOnDoubleTapListener

0
 * User: obrok 
 * Date: 11/4/11 
 * Time: 1:12 PM 
 */ 
public class TouchPane extends View implements GestureDetector.OnDoubleTapListener, GestureDetector.OnGestureListener {
    GestureDetector gestureDetector = new GestureDetector(this);
    @Inject EventBus eventBus;
 
    @SuppressWarnings("UnusedDeclaration") 
    public TouchPane(Context context) {
        super(context);
        initialize(context);
    } 
 
    @SuppressWarnings("UnusedDeclaration") 
    public TouchPane(Context context, AttributeSet attrs) {
        super(context, attrs);
        initialize(context);
    } 
 
    @SuppressWarnings("UnusedDeclaration") 
    public TouchPane(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initialize(context);
    } 
 
    private void initialize(Context context) {
        Context applicationContext = context.getApplicationContext();
        Injector injector = AirCastingApplication.class.cast(applicationContext).getInjector();
        injector.injectMembers(this);
 
        gestureDetector.setOnDoubleTapListener(this);
    } 
 
    @Override 
    public boolean dispatchTouchEvent(MotionEvent event) {
        gestureDetector.onTouchEvent(event);