コード例 #1
0
ファイル: LookFragment.java プロジェクト: vidak92/Catroid
  @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
  @Test
  public void testGetters() {
    Uri uri = Uri.parse("http://robolectric.org");
    String[] projection = new String[] {"_id", "TestColumn"};
    String selection = "_id = ?";
    String[] selectionArgs = new String[] {"5"};
    String sortOrder = "_id";
    CursorLoader cursorLoader =
        new CursorLoader(
            RuntimeEnvironment.application, uri, projection, selection, selectionArgs, sortOrder);

    assertThat(cursorLoader.getUri()).isEqualTo(uri);
    assertThat(cursorLoader.getProjection()).isEqualTo(projection);
    assertThat(cursorLoader.getSelection()).isEqualTo(selection);
    assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs);
    assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder);
  }