Java Code Examples for com.yalantis.ucrop.UCrop#getError()

The following examples show how to use com.yalantis.ucrop.UCrop#getError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostImage.java    From Hify with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode==UCrop.REQUEST_CROP && resultCode==RESULT_OK){

        long old_id=imagesList.get(selectedIndex).getId();
        String old_name=imagesList.get(selectedIndex).getName();
        String old_path=imagesList.get(selectedIndex).getOg_path();

        imagesList.remove(selectedIndex);
        imagesList.add(selectedIndex,new Images(old_name,old_path,UCrop.getOutput(data).getPath(),old_id));
        adapter=new PagerPhotosAdapter(this,imagesList);
        pager.setAdapter(adapter);
        indicator.setViewPager(pager);
        adapter.notifyDataSetChanged();
        pager.setCurrentItem(selectedIndex,true);

    }else if(resultCode==UCrop.RESULT_ERROR){
        Throwable throwable=UCrop.getError(data);
        throwable.printStackTrace();
        Toasty.error(this, "Error cropping : "+throwable.getMessage(), Toasty.LENGTH_SHORT,true).show();
    }

}
 
Example 2
Source File: PhotoActivity.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
private void handleCropError(@NonNull Intent result) {
    final Throwable cropError = UCrop.getError(result);
    if (cropError != null) {
        SnackbarUtil.show(this, cropError.getMessage());
    } else {
        SnackbarUtil.show(this, "不好意思,裁剪开小差了!");
    }
}
 
Example 3
Source File: BoxingUcrop.java    From boxing with Apache License 2.0 5 votes vote down vote up
@Override
public Uri onCropFinish(int resultCode, Intent data) {
    if (data == null) {
        return null;
    }
    Throwable throwable = UCrop.getError(data);
    if (throwable != null) {
        return null;
    }
    return UCrop.getOutput(data);
}
 
Example 4
Source File: UpdateUserInfoActivity.java    From Pigeon with MIT License 5 votes vote down vote up
private void handleCropError(@NonNull Intent result) {
    final Throwable cropError = UCrop.getError(result);
    if (cropError != null) {
        ToastUtils.showToast(UpdateUserInfoActivity.this,cropError.getMessage());
    } else {
        ToastUtils.showToast(UpdateUserInfoActivity.this,"handleCropError");
    }
}
 
Example 5
Source File: EditFamilyActivity.java    From Pigeon with MIT License 5 votes vote down vote up
private void handleCropError(@NonNull Intent result) {
    final Throwable cropError = UCrop.getError(result);
    if (cropError != null) {
        ToastUtils.showToast(EditFamilyActivity.this, cropError.getMessage());
    } else {
        ToastUtils.showToast(EditFamilyActivity.this, "handleCropError");
    }
}
 
Example 6
Source File: MatisseDemoActivity.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {

            List<Uri> mUris = Matisse.obtainResult(data);
            mStrings = Matisse.obtainPathResult(data);

//            try {
//                ExifInterface mExifInterface = new ExifInterface(mStrings.get(0));
//                Log.e(TAG, "onActivityResult: " + mExifInterface.getAttribute(ExifInterface.TAG_GPS_ALTITUDE));
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
            mMyAdapter.setData(mStrings);

            Tools.getPhotoInfo(mStrings.get(0));


//            Uri destinationUri = Uri.fromFile(new File(getCacheDir(), "test.jpg"));
//            UCrop.of(mUris.get(0), destinationUri)
//                    .withAspectRatio(16, 9)
//                    .withMaxResultSize(maxWidth, maxHeight)
//                    .start(this);
        }

        if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
            final Uri resultUri = UCrop.getOutput(data);
            Intent mIntent = new Intent(MatisseDemoActivity.this, PhotoProcessActivity.class);
            mIntent.putExtra("url", resultUri);
            startActivity(mIntent);
        } else if (resultCode == UCrop.RESULT_ERROR) {
            final Throwable cropError = UCrop.getError(data);
        }
    }
 
Example 7
Source File: ImagePickerActivity.java    From Android-Image-Picker-and-Cropping with GNU General Public License v3.0 4 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_IMAGE_CAPTURE:
            if (resultCode == RESULT_OK) {
                cropImage(getCacheImagePath(fileName));
            } else {
                setResultCancelled();
            }
            break;
        case REQUEST_GALLERY_IMAGE:
            if (resultCode == RESULT_OK) {
                Uri imageUri = data.getData();
                cropImage(imageUri);
            } else {
                setResultCancelled();
            }
            break;
        case UCrop.REQUEST_CROP:
            if (resultCode == RESULT_OK) {
                handleUCropResult(data);
            } else {
                setResultCancelled();
            }
            break;
        case UCrop.RESULT_ERROR:
            final Throwable cropError = UCrop.getError(data);
            Log.e(TAG, "Crop error: " + cropError);
            setResultCancelled();
            break;
        default:
            setResultCancelled();
    }
}