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

This code example shows how to use the following methods:load
    public static GestureLibrary getStore(Context c) {
 
        if (sStore == null) {
            File storeFile = new File(c.getFilesDir(), "sms_templates_gestures");
            sStore = GestureLibraries.fromFile(storeFile);
            sStore.load();
        } 
 
        return sStore;
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:load
		this.gesture = gesture;
	} 
 
	private void updateGestureLibrary() { 
		library = GestureLibraries.fromFile("/sdcard/gestureexample");
		library.load();
	} 
 
	private boolean storeGesture() { 
		if(gesture != null) {
			String name = null;
			if(((EditText) findViewById(R.id.name)).getText() != null) {
				name = ((EditText) findViewById(R.id.name)).getText().toString();
			} 
			if(name == null || name.trim().length() < 1) {
				Toast.makeText(this, "You must provide a name", Toast.LENGTH_SHORT).show();
				return false; 
			} 
			library.addGesture(name, gesture);
			library.save();
6
CodeRank
This code example shows how to use the following methods:recognize
 
    public void onGesturePerformed(GestureOverlayView overlay,
                                   Gesture gesture) {
        // 解析します 
        ArrayList<Prediction> predictions;
        predictions = mLibrary.recognize(gesture);
 
        // 結果が1つ以上あったら 
        if (predictions.size() > 0) {
            Prediction prediction = predictions.get(0);
            // スコアが1.0以上 
            // (これはアプリの特性に応じて調整してください) 
            if (prediction.score > 1.0) {
                // ジェスチャーの名前をトーストでチン 
                Toast.makeText(this, prediction.name,
                               Toast.LENGTH_SHORT).show();
            } 
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:recognize
 
    public void onGesturePerformed(GestureOverlayView overlay,
                                   Gesture gesture) {
        // 解析します 
        ArrayList<Prediction> predictions;
        predictions = mLibrary.recognize(gesture);
 
        // 結果が1つ以上あったら 
        if (predictions.size() > 0) {
            Prediction prediction = predictions.get(0);
            // スコアが1.0以上 
            // (これはアプリの特性に応じて調整してください) 
            if (prediction.score > 1.0) {
                // ジェスチャーの名前をトーストでチン 
                Toast.makeText(this, prediction.name,
                               Toast.LENGTH_SHORT).show();
                if ("back".equals(prediction.name)) {
                    // 戻れるか判定して 
                    if(mWebView.canGoBack()) {
                        // 戻る! 
5
CodeRank
This code example shows how to use the following methods:recognize
  
  OnGesturePerformedListener gesturePerformedListener= new OnGesturePerformedListener(){
  
 public void onGesturePerformed(GestureOverlayView view, Gesture gesture) { 
  // TODO Auto-generated method stub 
  ArrayList<Prediction> prediction = gestureLibrary.recognize(gesture); 
    if(prediction.size() > 0){ 
    	String gesture_found = prediction.get(0).name; 
    	Log.d("gesture tag", "gesture detected"); 
    	//Toast.makeText(GestureMonitorActivity.this, gesture_found, Toast.LENGTH_SHORT).show(); 
 
    	Intent intent= new Intent(); 
    	intent.putExtra("gesture",gesture_found); 
    	setResult(RESULT_OK,intent); 
    	finish(); 
    	 
      } 
   
  }}; 
} 
5
CodeRank
This code example shows how to use the following methods:removeEntry, save
	} 
	 
	public void cancelGesture(View v) {
        setResult(RESULT_CANCELED);
        mLibrary = GestureLibraries.fromFile(path);
        mLibrary.removeEntry("PRUEBA");
        mLibrary.removeEntry("PSW_GESTURE");
		mLibrary.save();
        finish();
         
	} 
	 
	public void okGesture(View v) {
        
            setResult(RESULT_OK);
          //Intent MainA = new Intent(getApplicationContext(), ValidateGesture.class); 
      	  	finish();
      	  	//startActivity(MainA); 
             
        } 
5
CodeRank
This code example shows how to use the following methods:removeEntry, save
	} 
	 
	public void cancelGesture(View v) {
        setResult(RESULT_CANCELED);
        mLibrary = GestureLibraries.fromFile(path);
        mLibrary.removeEntry("PRUEBA");
        mLibrary.removeEntry("PSW_GESTURE");
		mLibrary.save();
        finish();
         
	} 
	 
	public void okGesture(View v) {
        
            setResult(RESULT_OK);
          //Intent MainA = new Intent(getApplicationContext(), ValidateGesture.class); 
      	  	finish();
      	  	//startActivity(MainA); 
             
        } 
5
CodeRank
This code example shows how to use the following methods:recognize
	} 
 
	@Override 
	public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
		if (gesture.getLength() > 500) {
			ArrayList<Prediction> predictions = gesturelib.recognize(gesture);
			if (predictions.size() > 0) {
				Prediction prediction = (Prediction) predictions.get(0);
				if (prediction.score > 1.0) {
					Toast.makeText(GestureWithFlingActivity.this, "Circle",
							Toast.LENGTH_SHORT).show();
				} 
			} 
		} 
	} 
 
	private static final int SWIPE_MIN_DISTANCE = 60;
	private static final int SWIPE_MAX_OFF_PATH = 250;
	private static final int SWIPE_THRESHOLD_VELOCITY = 200;
 
4
CodeRank
This code example shows how to use the following methods:recognize
	 * Prediction prediction = predictions.get(0); // We want at least some 
	 * confidence in the result if (prediction.score > 1.0) { // Show the spell 
	 * Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show(); } } 
	 */ 
	public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
		ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
		if (predictions.size() > 0 && predictions.get(0).score > 1.0) {
			String action = predictions.get(0).name;
			if ("action_add".equals(action)) {
				Toast.makeText(this, "Adding a contact", Toast.LENGTH_SHORT)
						.show();
			} else if ("action_delete".equals(action)) {
				Toast.makeText(this, "Removing a contact", Toast.LENGTH_SHORT)
						.show();
			} else if ("action_refresh".equals(action)) {
				Toast.makeText(this, "Reloading contacts", Toast.LENGTH_SHORT)
						.show();
			} 
		} 
	} 
4
CodeRank
This code example shows how to use the following methods:recognize
		return true; 
	} 
 
	@Override 
	public void onGesturePerformed(GestureOverlayView arg0, Gesture g) {
		ArrayList<Prediction> predictions = gestureLib.recognize(g); 
		if(predictions.size() >0 ){
			Prediction prediction = predictions.get(0);
			if(prediction.score >1){
				String s = prediction.name;
				if(s.equals("UP") || s.equals("up"))
					Toast.makeText(getApplicationContext(), "UP", 1).show();
				else if(s.equals("DOWN") || s.equals("down"))
					Toast.makeText(getApplicationContext(), "DOWN", 1).show();
			} 
		} 
		 
	} 
 
} 
4
CodeRank

Related Android GestureLibrary Questions & Answers:

Other Android GestureLibrary Examples

14:	
15:	public class GestureTest extends Activity implements OnGesturePerformedListener {
16:	  private GestureLibrary gestureLib;
17:	
18:	  /** Called when the activity is first created. */

Read More