コード例 #1
0
    @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;
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.ga_create_gesture);

    mDoneButton = findViewById(R.id.done);

    final Intent intent = getIntent();
    mUri = intent.getStringExtra("uri");
    mName = intent.getStringExtra("name");

    ((TextView) findViewById(R.id.gesture_name)).setText(mName);

    GestureOverlayView overlay = (GestureOverlayView) findViewById(R.id.gestures_overlay);
    overlay.addOnGestureListener(new GesturesProcessor());

    final GestureLibrary store = GestureAnywhereBuilderActivity.getStore();
    final String gestureName = mName + '|' + mUri;
    for (String entry : store.getGestureEntries()) {
      if (gestureName.equals(entry)) {
        mGesture = store.getGestures(entry).get(0);
        mIsExistingGesture = true;
        break;
      }
    }
  }
コード例 #3
0
  @Override
  protected void onRestoreInstanceState(Bundle state) {
    super.onRestoreInstanceState(state);

    long id = state.getLong(GESTURES_INFO_ID, -1);
    if (id != -1) {
      final Set<String> entries = sStore.getGestureEntries();
      out:
      for (String name : entries) {
        for (Gesture gesture : sStore.getGestures(name)) {
          if (gesture.getID() == id) {
            mCurrentRenameGesture = new NamedGesture();
            mCurrentRenameGesture.name = name;
            mCurrentRenameGesture.gesture = gesture;
            break out;
          }
        }
      }
    }
  }