本文整理汇总了Java中android.gesture.GestureLibrary类的典型用法代码示例。如果您正苦于以下问题:Java GestureLibrary类的具体用法?Java GestureLibrary怎么用?Java GestureLibrary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GestureLibrary类属于android.gesture包,在下文中一共展示了GestureLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGesture
import android.gesture.GestureLibrary; //导入依赖的package包/类
@SuppressWarnings({"UnusedDeclaration"})
public void addGesture(View v) {
if (mGesture != null) {
final TextView input = (TextView) findViewById(R.id.gesture_name);
final CharSequence name = input.getText();
if (name.length() == 0) {
input.setError(getString(R.string.error_missing_name));
return;
}
final GestureLibrary store = GestureBuilderActivity.getStore();
store.addGesture(name.toString(), mGesture);
store.save();
setResult(RESULT_OK);
final String path = new File(Environment.getExternalStorageDirectory(),
"gestures").getAbsolutePath();
Toast.makeText(this, getString(R.string.save_success, path), Toast.LENGTH_LONG).show();
} else {
setResult(RESULT_CANCELED);
}
finish();
}
示例2: 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();
}
}
});
}
示例3: addGesture
import android.gesture.GestureLibrary; //导入依赖的package包/类
public void addGesture(View v) {
if (mGesture != null) {
final TextView input = (TextView) findViewById(R.id.gesture_command);
final CharSequence name = input.getText();
if (name.length() == 0) {
input.setError(getString(R.string.error_missing_name_str));
return;
}
final GestureLibrary store = GestureBuilderActivity.getStore();
store.addGesture(name.toString(), mGesture);
store.save();
setResult(RESULT_OK);
final String path = new File(Environment.getExternalStorageDirectory(),
"gestures").getAbsolutePath();
Toast.makeText(this, getString(R.string.save_success_str, path), Toast.LENGTH_LONG).show();
} else {
setResult(RESULT_CANCELED);
}
finish();
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: addGesture
import android.gesture.GestureLibrary; //导入依赖的package包/类
public void addGesture(View v) {
if (mGesture != null) {
final TextView input = (TextView) findViewById(R.id.gesture_name);
final CharSequence name = input.getText();
if (name.length() == 0) {
input.setError(getString(R.string.error_missing_name));
return;
}
final GestureLibrary store = SettingsUtil.getGestureLibrary(this);
store.addGesture(name.toString(), mGesture);
store.save();
setResult(RESULT_OK);
final String path = SettingsUtil.getGestureFile(this)
.getAbsolutePath();
Toast.makeText(this, getString(R.string.save_success, path),
Toast.LENGTH_LONG).show();
} else {
setResult(RESULT_CANCELED);
}
finish();
}
示例8: 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;
}
示例9: type
import android.gesture.GestureLibrary; //导入依赖的package包/类
public static SubjectFactory<GestureLibrarySubject, GestureLibrary> type() {
return new SubjectFactory<GestureLibrarySubject, GestureLibrary>() {
@Override
public GestureLibrarySubject getSubject(FailureStrategy fs, GestureLibrary that) {
return new GestureLibrarySubject(fs, that);
}
};
}
示例10: printLibrary
import android.gesture.GestureLibrary; //导入依赖的package包/类
private void printLibrary(GestureLibrary lib) {
Set<String> nameEntries = lib.getGestureEntries();
for (String name : nameEntries) {
for (Gesture gesture : lib.getGestures(name)) {
DeLog.v(TAG, name + " " + gesture);
}
}
}
示例11: 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;
}
示例12: getStore
import android.gesture.GestureLibrary; //导入依赖的package包/类
static GestureLibrary getStore() {
return sStore;
}
示例13: GestureLibrarySubject
import android.gesture.GestureLibrary; //导入依赖的package包/类
protected GestureLibrarySubject(FailureStrategy failureStrategy, GestureLibrary subject) {
super(failureStrategy, subject);
}
示例14: getGestureLibrary
import android.gesture.GestureLibrary; //导入依赖的package包/类
public static GestureLibrary getGestureLibrary(Context context) {
if (sGestureLibrary == null)
sGestureLibrary = GestureLibraries.fromFile(getGestureFile(context));
return sGestureLibrary;
}
示例15: getStore
import android.gesture.GestureLibrary; //导入依赖的package包/类
static GestureLibrary getStore(){
return sStore;
}