Пример #1
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    String originalImagePath = "";
    CursorLoader cursorLoader = (CursorLoader) loader;

    boolean catchedExpetion = false;

    if (data == null) {
      originalImagePath = cursorLoader.getUri().getPath();
    } else {
      int columnIndex = data.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
      data.moveToFirst();

      try {
        originalImagePath = data.getString(columnIndex);
      } catch (CursorIndexOutOfBoundsException e) {
        catchedExpetion = true;
      }
    }

    if (catchedExpetion || (data == null && originalImagePath.equals(""))) {
      Utils.showErrorDialog(getActivity(), getString(R.string.error_load_image));
      return;
    }
    copyImageToCatroid(originalImagePath);
  }
Пример #2
0
  private void loadPictureFromCameraIntoCatroid() {
    if (lookFromCameraUri != null) {
      String originalImagePath = lookFromCameraUri.getPath();

      int[] imageDimensions = ImageEditing.getImageDimensions(originalImagePath);
      if (imageDimensions[0] < 0 || imageDimensions[1] < 0) {
        Utils.showErrorDialog(getActivity(), getString(R.string.error_load_image));
        return;
      }
      copyImageToCatroid(originalImagePath);

      File pictureOnSdCard = new File(lookFromCameraUri.getPath());
      pictureOnSdCard.delete();
    }
  }
Пример #3
0
  private void loadImageIntoCatroid(Intent intent) {
    String originalImagePath = "";

    // get path of image - will work for most applications
    Bundle bundle = intent.getExtras();
    if (bundle != null) {
      originalImagePath = bundle.getString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT);
    }

    if (originalImagePath == null || originalImagePath.equals("")) {
      Bundle arguments = new Bundle();
      arguments.putParcelable(LOADER_ARGUMENTS_IMAGE_URI, intent.getData());

      LoaderManager loaderManager = getLoaderManager();

      if (loaderManager.getLoader(ID_LOADER_MEDIA_IMAGE) == null) {
        loaderManager.initLoader(ID_LOADER_MEDIA_IMAGE, arguments, this);
      } else {
        loaderManager.restartLoader(ID_LOADER_MEDIA_IMAGE, arguments, this);
      }
    } else {
      copyImageToCatroid(originalImagePath);
    }
  }