@SuppressWarnings({"UnusedDeclaration"}) public void addGesture(View v) { if (mGesture != null) { if (TextUtils.isEmpty(mName) || TextUtils.isEmpty(mUri)) { return; } final GestureLibrary store = GestureAnywhereBuilderActivity.getStore(); final String gestureName = mName + "|" + mUri; if (mIsExistingGesture) { store.removeEntry(gestureName); } store.addGesture(gestureName, mGesture); store.save(); setResult(RESULT_OK); } else { setResult(RESULT_CANCELED); } finish(); }
private void changeGestureName() { final String name = mInput.getText().toString(); if (!TextUtils.isEmpty(name)) { final NamedGesture renameGesture = mCurrentRenameGesture; final GesturesAdapter adapter = mAdapter; final int count = adapter.getCount(); // Simple linear search, there should not be enough items to warrant // a more sophisticated search for (int i = 0; i < count; i++) { final NamedGesture gesture = adapter.getItem(i); if (gesture.gesture.getID() == renameGesture.gesture.getID()) { sStore.removeGesture(gesture.name, gesture.gesture); gesture.name = mInput.getText().toString(); sStore.addGesture(gesture.name, gesture.gesture); break; } } adapter.notifyDataSetChanged(); } mCurrentRenameGesture = null; }