use of android.gesture.Prediction in project android_frameworks_base by ResurrectionRemix.
the class GestureAnywhereView method onGestureEnded.
@Override
public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
Gesture gesture = overlay.getGesture();
List<Prediction> predictions = mStore.recognize(gesture);
for (Prediction prediction : predictions) {
if (prediction.score >= 2.0) {
switchToState(State.Closing);
String uri = prediction.name.substring(prediction.name.indexOf('|') + 1);
launchShortcut(uri);
break;
}
}
}
use of android.gesture.Prediction 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);
}
use of android.gesture.Prediction in project AndroidSDK-RecipeBook by gabu.
the class Recipe038 method onGesturePerformed.
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// 解析します
ArrayList<Prediction> predictions;
predictions = mLibrary.recognize(gesture);
// 結果が1つ以上あったら
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// (これはアプリの特性に応じて調整してください)
if (prediction.score > 1.0) {
// ジェスチャーの名前をトーストでチン
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
}
}
}
use of android.gesture.Prediction in project AndroidSDK-RecipeBook by gabu.
the class Recipe039 method onGesturePerformed.
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// 解析します
ArrayList<Prediction> predictions;
predictions = mLibrary.recognize(gesture);
// 結果が1つ以上あったら
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// (これはアプリの特性に応じて調整してください)
if (prediction.score > 1.0) {
// ジェスチャーの名前をトーストでチン
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
if ("back".equals(prediction.name)) {
// 戻れるか判定して
if (mWebView.canGoBack()) {
// 戻る!
mWebView.goBack();
}
}
}
}
// ジェスチャー受け付けを無効にする
overlay.setEnabled(false);
}
use of android.gesture.Prediction in project coursera-android by aporter.
the class GesturesActivity method onGesturePerformed.
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// Get gesture predictions
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
// Get highest-ranked prediction
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
if (prediction.score > 2.0) {
if (prediction.name.equals(PREV)) {
mBgColor -= 100;
mFrame.setBackgroundColor(mBgColor);
} else if (prediction.name.equals(NEXT)) {
mBgColor += 100;
mFrame.setBackgroundColor(mBgColor);
} else if (prediction.name.equals(YES)) {
mLayout.setBackgroundColor(mBgColor);
} else if (prediction.name.equals(NO)) {
mLayout.setBackgroundColor(mStartBgColor);
mFrame.setBackgroundColor(mFirstColor);
} else {
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "No prediction", Toast.LENGTH_SHORT).show();
}
}
}
Aggregations