Search in sources :

Example 1 with GestureStroke

use of android.gesture.GestureStroke in project platform_frameworks_base by android.

the class AccessibilityGestureDetector method recognizeGesture.

private boolean recognizeGesture(MotionEvent event, int policyFlags) {
    Gesture gesture = new Gesture();
    gesture.addStroke(new GestureStroke(mStrokeBuffer));
    ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
    if (!predictions.isEmpty()) {
        Prediction bestPrediction = predictions.get(0);
        if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
            if (DEBUG) {
                Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
            }
            try {
                final int gestureId = Integer.parseInt(bestPrediction.name);
                return mListener.onGestureCompleted(gestureId);
            } catch (NumberFormatException nfe) {
                Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
            }
        }
    }
    return mListener.onGestureCancelled(event, policyFlags);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 2 with GestureStroke

use of android.gesture.GestureStroke in project android_frameworks_base by DirtyUnicorns.

the class AccessibilityGestureDetector method recognizeGesture.

private boolean recognizeGesture(MotionEvent event, int policyFlags) {
    Gesture gesture = new Gesture();
    gesture.addStroke(new GestureStroke(mStrokeBuffer));
    ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
    if (!predictions.isEmpty()) {
        Prediction bestPrediction = predictions.get(0);
        if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
            if (DEBUG) {
                Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
            }
            try {
                final int gestureId = Integer.parseInt(bestPrediction.name);
                return mListener.onGestureCompleted(gestureId);
            } catch (NumberFormatException nfe) {
                Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
            }
        }
    }
    return mListener.onGestureCancelled(event, policyFlags);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 3 with GestureStroke

use of android.gesture.GestureStroke in project android_frameworks_base by AOSPA.

the class AccessibilityGestureDetector method recognizeGesture.

private boolean recognizeGesture(MotionEvent event, int policyFlags) {
    Gesture gesture = new Gesture();
    gesture.addStroke(new GestureStroke(mStrokeBuffer));
    ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
    if (!predictions.isEmpty()) {
        Prediction bestPrediction = predictions.get(0);
        if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
            if (DEBUG) {
                Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
            }
            try {
                final int gestureId = Integer.parseInt(bestPrediction.name);
                return mListener.onGestureCompleted(gestureId);
            } catch (NumberFormatException nfe) {
                Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
            }
        }
    }
    return mListener.onGestureCancelled(event, policyFlags);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 4 with GestureStroke

use of android.gesture.GestureStroke in project android_frameworks_base by ResurrectionRemix.

the class AccessibilityGestureDetector method recognizeGesture.

private boolean recognizeGesture(MotionEvent event, int policyFlags) {
    Gesture gesture = new Gesture();
    gesture.addStroke(new GestureStroke(mStrokeBuffer));
    ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
    if (!predictions.isEmpty()) {
        Prediction bestPrediction = predictions.get(0);
        if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
            if (DEBUG) {
                Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
            }
            try {
                final int gestureId = Integer.parseInt(bestPrediction.name);
                return mListener.onGestureCompleted(gestureId);
            } catch (NumberFormatException nfe) {
                Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
            }
        }
    }
    return mListener.onGestureCancelled(event, policyFlags);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 5 with GestureStroke

use of android.gesture.GestureStroke in project android_frameworks_base by crdroidandroid.

the class AccessibilityGestureDetector method recognizeGesture.

private boolean recognizeGesture(MotionEvent event, int policyFlags) {
    Gesture gesture = new Gesture();
    gesture.addStroke(new GestureStroke(mStrokeBuffer));
    ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
    if (!predictions.isEmpty()) {
        Prediction bestPrediction = predictions.get(0);
        if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
            if (DEBUG) {
                Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
            }
            try {
                final int gestureId = Integer.parseInt(bestPrediction.name);
                return mListener.onGestureCompleted(gestureId);
            } catch (NumberFormatException nfe) {
                Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
            }
        }
    }
    return mListener.onGestureCancelled(event, policyFlags);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Aggregations

Gesture (android.gesture.Gesture)5 GesturePoint (android.gesture.GesturePoint)5 GestureStroke (android.gesture.GestureStroke)5 Prediction (android.gesture.Prediction)5