Android GestureDetector - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GestureDetector class.

This code example shows how to use the following methods:onTouchEvent
		boolean handled = false;
		if (enableZoomControls) {
			if (zoomControls.getVisibility() == View.VISIBLE) {
				zoomControls.onTouchEvent(ev);
			} 
			handled = gestureDetector.onTouchEvent(ev);
		} 
		if (!handled) {
			handled = super.onTouchEvent(ev);
		} 
		return handled;
	} 
 
	@Override 
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
	{ 
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
		int maxWidth = 0;
		int maxHeight = 0;
9
CodeRank
This code example shows how to use the following methods:onTouchEvent
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        if (this.gestureDetector != null)
            this.gestureDetector.onTouchEvent(ev);
        return super.onTouchEvent(ev);
    } 
 
    @Override 
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (this.gestureDetector != null && ev.getActionMasked() == MotionEvent.ACTION_DOWN)
            this.gestureDetector.onTouchEvent(ev);
        return super.dispatchTouchEvent(ev);
 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:
 
class OFGestureListener extends SimpleOnGestureListener implements OnClickListener {
	 
 
	OFGestureListener(Activity activity){
		gestureDetector = new GestureDetector(activity,this);
        touchListener = new View.OnTouchListener() {
        	 
            public boolean onTouch(View v, MotionEvent event) {
            	final int action = event.getAction();
            	final int pointerIndex = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) 
                >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
                final int pointerId = event.getPointerId(pointerIndex);
                switch((action & MotionEvent.ACTION_MASK)){
                case MotionEvent.ACTION_MOVE:
                { 
            		for(int i=0; i<event.getHistorySize(); i++)
            		{            			 
		                for(int j=0; j<event.getPointerCount(); j++){	                			
	                		OFAndroid.onTouchMoved(event.getPointerId(j), event.getHistoricalX(j, i), event.getHistoricalY(j, i), event.getHistoricalPressure(j, i));
8
CodeRank
This code example shows how to use the following methods:onTouchEvent
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        try { 
            gestureDetector.onTouchEvent(ev);
            return super.onTouchEvent(ev);
        } catch (Exception e) {
            Log.e("GoogleMapView.onTouchEvent", e);
        } 
        return false; 
    } 
 
    private class GestureListener extends SimpleOnGestureListener {
        @Override 
        public boolean onDoubleTap(MotionEvent e) {
            getController().zoomInFixing((int) e.getX(), (int) e.getY());
            if (onDragListener != null) {
                onDragListener.onDrag();
            } 
8
CodeRank
This code example shows how to use the following methods:setOnDoubleTapListener
        mContext = context;
        mController = controller;
        mRenderer = new LayerRenderer(this);
        setRenderer(mRenderer);
        setRenderMode(RENDERMODE_WHEN_DIRTY);
        mGestureDetector = new GestureDetector(context, controller.getGestureListener());
        mScaleGestureDetector =
            new SimpleScaleGestureDetector(controller.getScaleGestureListener());
        mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
        mInputConnectionHandler = null;
 
        setFocusable(true);
        setFocusableInTouchMode(true);
    } 
 
    private void addToEventQueue(MotionEvent event) {
        MotionEvent copy = MotionEvent.obtain(event);
        mEventQueue.add(copy);
    } 
 
7
CodeRank
This code example shows how to use the following methods:onTouchEvent
		// event.getAction() codes. 
 
		// Note that we are now calling the gesture Detectors onTouchEvent. 
		// And given we've set this class as the GestureDetectors listener 
		// the onFling, onSingleTap etc methods will be executed. 
		return gDetector.onTouchEvent(event);
	} 
 
	public GestureDetector getDetector() {
		return gDetector;
	} 
} 
8
CodeRank
This code example shows how to use the following methods:onTouchEvent
		return true; 
	} 
 
	@Override 
	public final boolean onTouch(final View v, final MotionEvent event) {
		mGestureDector.onTouchEvent(event);
		return false; 
	} 
 
	public void setPullToRefreshEnabled(final boolean enabled) {
		if (mPullToRefreshAttacherActivity == null) return;
		mPullToRefreshAttacherActivity.setPullToRefreshEnabled(this, enabled);
	} 
 
	public void setRefreshComplete() { 
		if (mPullToRefreshAttacherActivity == null) return;
		mPulledUp = false;
		mPullToRefreshAttacherActivity.setRefreshComplete(this);
	} 
 
8
CodeRank
This code example shows how to use the following methods:setOnDoubleTapListener
 
	public ResidualVMEvents(Context context, ResidualVM residualvm) {
		_context = context;
		_residualvm = residualvm;
 
		_gd = new GestureDetector(context, this);
		_gd.setOnDoubleTapListener(this);
		//_gd.setIsLongpressEnabled(false); 
 
		_longPress = ViewConfiguration.getLongPressTimeout();
	} 
 
	final public void sendQuitEvent() { 
		_residualvm.pushEvent(JE_QUIT, 0, 0, 0, 0, 0, 0);
	} 
 
	public boolean onTrackballEvent(MotionEvent e) {
		_residualvm.pushEvent(JE_BALL, e.getAction(),
							(int)(e.getX() * e.getXPrecision() * 100),
							(int)(e.getY() * e.getYPrecision() * 100),
7
CodeRank
This code example shows how to use the following methods:onTouchEvent
			return getWidth();
		} 
	} 
	@Override 
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mGestureDetector.onTouchEvent(ev)) {
            return true; 
        } 
        if(!mInterceptClicks){
	        return super.onInterceptTouchEvent(ev);
        } 
        return true; 
    }	 
	@Override 
    public boolean onTouchEvent(MotionEvent ev) {
        if (mGestureDetector.onTouchEvent(ev)) {
            return true; 
        } 
        if(!mInterceptClicks){
	        return super.onTouchEvent(ev);
8
CodeRank
This code example shows how to use the following methods:onTouchEvent
 
	}; 
	 
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		boolean retval = mScrollGestureDetector.onTouchEvent(event);
		 
		if(event.getAction() == MotionEvent.ACTION_UP){
			mIsFingerDown = false;
			if(getChildCount() > 0){
				int topOfFirstChild = getChildAt(0).getTop();
				if(topOfFirstChild + mdY > 0){
					mScroller.forceFinished(true);
					mLastY = 0;
					mScroller.startScroll(0, 0, mdY, -mYOffset);
					requestLayout();
				} 
			} 
		} 
		 
8
CodeRank

Related Android GestureDetector Questions & Answers:

See Code Examples for Android GestureDetector Methods: