当前位置: 首页>>代码示例>>Java>>正文


Java GestureLibrary.load方法代码示例

本文整理汇总了Java中android.gesture.GestureLibrary.load方法的典型用法代码示例。如果您正苦于以下问题:Java GestureLibrary.load方法的具体用法?Java GestureLibrary.load怎么用?Java GestureLibrary.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.gesture.GestureLibrary的用法示例。


在下文中一共展示了GestureLibrary.load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGesture

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
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();
					}

				}
			});

}
 
开发者ID:chenyufeng1991,项目名称:BaiduMap-TrafficAssistant,代码行数:32,代码来源:MainActivity.java

示例2: addGesture

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
/**
 * Stores the given gesture.
 *
 * @param name    The name of the gesture
 * @param gesture The gesture
 * @param action  The action to perform when the touch gesture is performed
 */
public void addGesture(String name, Gesture gesture, AbstractAction action) {

    GestureLibrary fileLib = GestureLibraries.fromFile(TOUCH_GESTURES_FILE);
    if (fileLib.load()) {
        fileLib.addGesture(name, gesture);
        fileLib.save();
        this.mMap.put(name, action);
        saveHashMap();
        DeLog.d(TAG, "Gesture " + name + " saved");
        sendGestureChangedBroadcast();
    } else {
        DeLog.e(TAG, "Couldn't save gesture " + name);
    }

}
 
开发者ID:alexstyl,项目名称:Touch-Control,代码行数:23,代码来源:GestureManager.java

示例3: removeGesture

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
/**
 * Removes the gesture with the given name from the manager
 *
 * @param name The name of the entry to remove
 * @return Whether it manages to remove an entry or not
 */
public boolean removeGesture(String name) {

    boolean res = false;
    GestureLibrary fileLib = GestureLibraries.fromFile(TOUCH_GESTURES_FILE);
    if (fileLib.load()) {
        fileLib.removeEntry(name);
        fileLib.save();
        res = null != this.mMap.remove(name);
        saveHashMap();
        DeLog.d(TAG, "Gesture " + name + " removed");
        sendGestureChangedBroadcast();
    } else {
        DeLog.e(TAG, "Couldn't save gesture " + name);
    }
    return res;

}
 
开发者ID:alexstyl,项目名称:Touch-Control,代码行数:24,代码来源:GestureManager.java

示例4: getOverlayContentView

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
/**
 * Add the content view of the activity into a GestureOverlayView and return the new view
 *
 * @param contentView the original content view of the activity
 * @param packageName the package name of the app who uses this library
 * @param rawId       the resource identifier of the gesture file in your raw folder
 * @return the new contentView wrapped in a GestureOverlayView
 */
public static View getOverlayContentView(final View contentView, final String packageName,
                                         int rawId) {
    //load the gestures
    final GestureLibrary gestureLib = GestureLibraries
            .fromRawResource(contentView.getContext(), rawId);
    if (!gestureLib.load()) {
        Log.w(TAG, "could not load gestures");
        return contentView;
    }

    GestureOverlayView gestureOverlayView = new GestureOverlayView(contentView.getContext());
    gestureOverlayView.setGestureColor(Color.TRANSPARENT);
    gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
    gestureOverlayView.addView(contentView);
    gestureOverlayView
            .addOnGesturePerformedListener(new GestureOverlayView.OnGesturePerformedListener() {
                @Override
                public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
                    //load all gestures
                    ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
                    //the only received prediction should be "netural"
                    for (Prediction prediction : predictions) {
                        if (prediction.score > 1.0) {
                            showDialog(contentView.getContext(), packageName);
                        }
                    }
                }
            });
    return gestureOverlayView;
}
 
开发者ID:Netural,项目名称:AboutApp,代码行数:39,代码来源:AboutAppOverlay.java

示例5: doInBackground

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(Void... params) {
    if (isCancelled()) return STATUS_CANCELLED;
    if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        return STATUS_NO_STORAGE;
    }

    final GestureLibrary store = sStore;

    if (store.load()) {
        for (String name : store.getGestureEntries()) {
            if (isCancelled()) break;

            for (Gesture gesture : store.getGestures(name)) {
                final Bitmap bitmap = gesture.toBitmap(mThumbnailSize, mThumbnailSize,
                        mThumbnailInset, mPathColor);
                final NamedGesture namedGesture = new NamedGesture();
                namedGesture.gesture = gesture;
                namedGesture.name = name;

                mAdapter.addBitmap(namedGesture.gesture.getID(), bitmap);
                publishProgress(namedGesture);
            }
        }

        return STATUS_SUCCESS;
    }

    return STATUS_NOT_LOADED;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:31,代码来源:GestureBuilderActivity.java

示例6: doInBackground

import android.gesture.GestureLibrary; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(Void... params) {
	if (isCancelled())
		return STATUS_CANCELLED;
	if (!Environment.MEDIA_MOUNTED.equals(Environment
			.getExternalStorageState())) {
		return STATUS_NO_STORAGE;
	}

	final GestureLibrary store = SettingsUtil.getGestureLibrary(mThis);

	if (store.load()) {
		for (String name : store.getGestureEntries()) {
			if (isCancelled())
				break;

			for (Gesture gesture : store.getGestures(name)) {
				final Bitmap bitmap = gesture.toBitmap(mThumbnailSize,
						mThumbnailSize, mThumbnailInset, mPathColor);
				final NamedGesture namedGesture = new NamedGesture();
				namedGesture.gesture = gesture;
				namedGesture.name = name;

				mAdapter.addBitmap(namedGesture.gesture.getID(), bitmap);
				publishProgress(namedGesture);
			}
		}

		return STATUS_SUCCESS;
	}

	return STATUS_NOT_LOADED;
}
 
开发者ID:AndrewMurrell,项目名称:minak,代码行数:34,代码来源:SettingsActivity.java


注:本文中的android.gesture.GestureLibrary.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。