Android Gesture - 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 Gesture class.

This code example shows how to use the following methods:getBoundingBox, getLength
        } 
 
        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
            mGesture = overlay.getGesture();
            //Ignore short strokes and horizontal swipes (for compatibility with playback controls) 
            if (mGesture.getLength() < THRESHOLD ||
                    mGesture.getBoundingBox().height() < THRESHOLD) {
                overlay.clear(false);
            } else { 
                mDoneButton.setEnabled(true);
            } 
        } 
 
        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getLength
        public void onGesture(GestureOverlayView overlay, MotionEvent event) {
        } 
 
        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
            mGesture = overlay.getGesture();
            if (mGesture.getLength() < LENGTH_THRESHOLD) {
                overlay.clear(false);
            } 
            mDoneButton.setEnabled(true);
        } 
 
        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getStrokesCount
 
	@Override 
	public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
		mGesture = overlay.getGesture();
		Log.i( TAG, "got a gesture" );
		if (mGesture.getStrokesCount() == 2) {
			if (event.getAction() == MotionEvent.ACTION_UP) {
				String guestureName = GestureADao.INSTACE.matchGesture(mGesture);
				if (guestureName.compareTo("No.0") == 0) {
					// do gesture lock 
					Log.i( TAG, "unlock" );
					GestureLockStatusService.INSTANCE.unlock(); 
				} else if (guestureName.compareTo("No.2") == 0) {
					// do gesture unlock 
					Log.i( TAG, "lock" );
					GestureLockStatusService.INSTANCE.lock(); 
				} 
			} 
		} 
	} 
4
CodeRank
This code example shows how to use the following methods:getStrokesCount
 
	@Override 
	public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
		Log.i(TAG, "gesture ended");
		mGesture = overlay.getGesture();// 从绘图区取出形成的手势
		if (mGesture.getStrokesCount() == 2) {// 我判定当用户用了两笔划
			// (强调:如果一开始设置手势笔画类型是单一笔画,那你这里始终得到的只是1!) 
			if (event.getAction() == MotionEvent.ACTION_UP) {// 判定第两笔划离开屏幕
				Log.i(TAG, "准备处理手势...");
				Object[] gestureNames = GestureADao.INSTACE.getGesturesNames();
				int index = gestureNames.length;
				GestureADao.INSTACE.addMyGesture("No." + index, mGesture, this.mGestureView);
 
				if (gestureNames.length >= 9) {
					GestureADao.INSTACE.deleteGesture(); 
				} 
			} 
		} else { 
			Log.i(TAG, "请您在紧凑的时间内用两笔划来完成一个手势");
		} 
5
CodeRank
This code example shows how to use the following methods:getBoundingBox
		} 
 
		public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
			Gesture gesture = overlay.getGesture();
			if (event.getAction() == MotionEvent.ACTION_UP) {
				String strName = findGesture(gesture);
				if (mHandler != null && strName != null) {
					mHandler.processGesture(strName, gesture.getBoundingBox());
				} 
			} 
			disableGesture(); 
		} 
 
		public void onGestureCancelled(GestureOverlayView overlay,
				MotionEvent event) {
		} 
 
		public void onGesture(GestureOverlayView overlay, MotionEvent event) {
		} 
	} 
4
CodeRank
This code example shows how to use the following methods:getLength
        public void onGesture(GestureOverlayView overlay, MotionEvent event) {
        } 
 
        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
            mGesture = overlay.getGesture();
            if (mGesture.getLength() < LENGTH_THRESHOLD) {
                overlay.clear(false);
            } 
            mDoneButton.setEnabled(true);
        } 
 
        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        } 
    } 
 
    public void pickShortcut(View v) {
        Bundle bundle = new Bundle();
 
        ArrayList<String> shortcutNames = new ArrayList<String>();
        shortcutNames.add(getString(R.string.group_applications));
4
CodeRank
This code example shows how to use the following methods:getLength
This code example shows how to use the following methods:getLength
        public void onGesture(GestureOverlayView overlay, MotionEvent event) {
        } 
 
        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
            mGesture = overlay.getGesture();
            if (mGesture.getLength() < LENGTH_THRESHOLD) {
                overlay.clear(false);
            } 
            mDoneButton.setEnabled(true);
        } 
 
        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        } 
    } 
 
    public void pickShortcut(View v) {
        Bundle bundle = new Bundle();
 
        ArrayList<String> shortcutNames = new ArrayList<String>();
        shortcutNames.add(getString(R.string.group_applications));
4
CodeRank
This code example shows how to use the following methods:getLength
        public void onGesture(GestureOverlayView overlay, MotionEvent event) {
        } 
 
        public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
            mGesture = overlay.getGesture();
            if (mGesture.getLength() < LENGTH_THRESHOLD) {
                overlay.clear(false);
            } 
            mDoneButton.setEnabled(true);
        } 
 
        public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:toBitmap
			} 
		}  
	} 
 
	public static void addGestureBmp(String name, Gesture gesture) {
		mGestureBitmap.put(name, gesture.toBitmap(BITMAP_WIDTH, BITMAP_HEIGHT, 12, Color.GREEN));
	} 
	 
	public static void clearGestureBmp() { 
		mGestureBitmap.clear();
	} 
 
	private void draw() { 
		try { 
			mCanvas = mSurfaceHolder.lockCanvas(); // 得到一个canvas实例
			if( mCanvas == null ){
				return; 
			} 
			mCanvas.drawColor(Color.WHITE);// 刷屏
			 
4
CodeRank

Related Android Gesture Questions & Answers:

Other Android Gesture Examples

32:	
33:	  @Override
34:	  public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
35:	    ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
36:	    for (Prediction prediction : predictions) {

Read More

See Code Examples for Android Gesture Methods: