android.gesture.GestureOverlayView.OnGesturePerformedListener Java Examples

The following examples show how to use android.gesture.GestureOverlayView.OnGesturePerformedListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
private void initGesture() {
	final GestureLibrary gestureLibrary = GestureLibraries.fromRawResource(
			context, R.raw.gestures);
	gestureLibrary.load();

	gestureOverlayView
			.addOnGesturePerformedListener(new OnGesturePerformedListener() {

				@Override
				public void onGesturePerformed(GestureOverlayView overlay,
						Gesture gesture) {
					ArrayList<Prediction> arrayList = gestureLibrary
							.recognize(gesture);

					Prediction prediction = arrayList.get(0);
					if (prediction.score >= 3.0) {
						if (prediction.name.equals("back")) {
							Toast.makeText(context, "退出",
									Toast.LENGTH_SHORT).show();
							finish();
						}

					} else {
						Toast.makeText(context, "手势不存在", Toast.LENGTH_SHORT)
								.show();
					}

				}
			});

}