Java Code Examples for com.yalantis.ucrop.UCrop#getOutput()
The following examples show how to use
com.yalantis.ucrop.UCrop#getOutput() .
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: CropUtils.java From CropUtils with Apache License 2.0 | 6 votes |
/** * 注意,调用时data为null的判断 * * @param context * @param cropHandler * @param requestCode * @param resultCode * @param data */ public static void handleResult(Activity context, CropHandler cropHandler, int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_SELECT_PICTURE) {//第一次,选择图片后返回 final Uri selectedUri = data.getData(); if (selectedUri != null) { startCropActivity(context, data.getData()); } else { Toast.makeText(context, "Cannot retrieve selected image", Toast.LENGTH_SHORT).show(); } } else if (requestCode == UCrop.REQUEST_CROP) {//第二次返回,图片已经剪切好 Uri finalUri = UCrop.getOutput(data); cropHandler.handleCropResult(finalUri,config.tag); } else if (requestCode == REQUEST_CAMERA) {//第一次,拍照后返回,因为设置了MediaStore.EXTRA_OUTPUT,所以data为null,数据直接就在uri中 startCropActivity(context, uri); } } if (resultCode == UCrop.RESULT_ERROR) { cropHandler.handleCropError(data); } }
Example 2
Source File: ImagePickerActivity.java From Android-Image-Picker-and-Cropping with GNU General Public License v3.0 | 5 votes |
private void handleUCropResult(Intent data) { if (data == null) { setResultCancelled(); return; } final Uri resultUri = UCrop.getOutput(data); setResultOk(resultUri); }
Example 3
Source File: PhotoEditorActivity.java From react-native-photo-editor with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) { if (data != null) { final Uri resultUri = UCrop.getOutput(data); if (resultUri != null) { try { selectedImagePath = resultUri.toString(); Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver() , resultUri); photoEditImageView.setImageBitmap(bitmap); } catch (Exception ex) { System.out.println("NO IMAGE DATA FOUND"); } } else { System.out.println("NO IMAGE DATA FOUND"); } } else { System.out.println("NO RESULT"); } } }
Example 4
Source File: PhotoActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
private void handleCropResult(@NonNull Intent result) { final Uri resultUri = UCrop.getOutput(result); if (resultUri != null) { mUrl = resultUri.toString(); ImageLoader.loadNoCrop(this, mUrl, mPhoto); } else { SnackbarUtil.show(this, "不好意思,裁剪开小差了!"); } }
Example 5
Source File: BoxingUcrop.java From boxing with Apache License 2.0 | 5 votes |
@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 6
Source File: UpdateUserInfoActivity.java From Pigeon with MIT License | 5 votes |
private void handleCropResult(@NonNull Intent result) { final Uri resultUri = UCrop.getOutput(result); if (resultUri != null) { mCurrentPhotoStr = resultUri.getPath(); mPhotoBitmap = BitmapFactory.decodeFile(resultUri.getPath()); mCivPhoto.setImageBitmap(mPhotoBitmap); } }
Example 7
Source File: EditFamilyActivity.java From Pigeon with MIT License | 5 votes |
private void handleCropResult(@NonNull Intent result) { final Uri resultUri = UCrop.getOutput(result); if (resultUri != null) { mCurrentPhotoStr = resultUri.getPath(); mPhotoBitmap = BitmapFactory.decodeFile(resultUri.getPath()); mFamilyPhoto.setImageBitmap(mPhotoBitmap); } }
Example 8
Source File: FragmentEditImage.java From iGap-Android with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); String path; if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) { final Uri resultUri = UCrop.getOutput(data); path = AttachFile.getFilePathFromUri(resultUri); serCropAndFilterImage(path); } else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { // result for crop CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { path = result.getUri().getPath(); serCropAndFilterImage(path); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { // Exception error = result.getError(); } } }
Example 9
Source File: MatisseDemoActivity.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@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 10
Source File: PicCrop.java From PicCrop with Apache License 2.0 | 5 votes |
/** * 注意,调用时data为null的判断 * * @param context * @param cropHandler * @param requestCode * @param resultCode * @param data */ public static void onActivityResult( int requestCode, int resultCode, Intent data,Activity context, CropHandler cropHandler) { if (resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_SELECT_PICTURE) {//第一次,选择图片后返回 final Uri selectedUri = data.getData(); if (selectedUri != null) { startCropActivity(context, data.getData()); } else { Toast.makeText(context, "Cannot retrieve selected image", Toast.LENGTH_SHORT).show(); } } else if (requestCode == UCrop.REQUEST_CROP) {//第二次返回,图片已经剪切好 Uri finalUri = UCrop.getOutput(data); cropHandler.handleCropResult(finalUri,config.tag); } else if (requestCode == REQUEST_CAMERA) {//第一次,拍照后返回,因为设置了MediaStore.EXTRA_OUTPUT,所以data为null,数据直接就在uri中 startCropActivity(context, uri); } } if (resultCode == UCrop.RESULT_ERROR) { cropHandler.handleCropError(data); } }
Example 11
Source File: SingleMediaActivity.java From leafpicrevived with GNU General Public License v3.0 | 4 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (data != null && resultCode == RESULT_OK) { switch (requestCode) { case UCrop.REQUEST_CROP: final Uri imageUri = UCrop.getOutput(data); if (imageUri != null && imageUri.getScheme().equals("file")) { try { //copyFileToDownloads(imageUri); // TODO: 21/08/16 handle this better if (StorageHelper.copyFile(getApplicationContext(), new File(imageUri.getPath()), new File(this.album.getPath()))) { //((ImageFragment) adapter.getRegisteredFragment(this.album.getCurrentMediaIndex())).displayMedia(true); Toast.makeText(this, R.string.new_file_created, Toast.LENGTH_SHORT).show(); } //adapter.notifyDataSetChanged(); } catch (Exception e) { Log.e("ERROS - uCrop", imageUri.toString(), e); } } else StringUtils.showToast(getApplicationContext(), "errori random"); break; default: super.onActivityResult(requestCode, resultCode, data); break; } } }
Example 12
Source File: ProfileDelegate.java From FastWaiMai with MIT License | 4 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case CameraRequestCodes.TAKE_PHOTO: final Uri resultUri = CameraImageBean.getInstance().getPath(); UCrop.of(resultUri, resultUri) .withMaxResultSize(400, 400) .start(getContext(), this); break; case CameraRequestCodes.PICK_PHOTO: if (data != null) { final Uri pickPath = data.getData(); //从相册选择后需要有个路径存放剪裁过的图片 final String pickCropPath = LatteCamera.createCropFile().getPath(); UCrop.of(pickPath, Uri.parse(pickCropPath)) .withMaxResultSize(400, 400) .start(getContext(), this); } break; case CameraRequestCodes.CROP_PHOTO: final Uri cropUri = UCrop.getOutput(data); //拿到剪裁后的数据进行处理 @SuppressWarnings("unchecked") final IGlobalCallback<Uri> callback = CallBackManager .getInstance() .getCallback(CallBackType.ON_CROP); if (callback != null) { callback.executeCallBack(cropUri); } break; case CameraRequestCodes.CROP_ERROR: Toast.makeText(getContext(), "剪裁出错", Toast.LENGTH_SHORT).show(); break; default: break; } } }
Example 13
Source File: ProfileFragment.java From Hify with MIT License | 4 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==PICK_IMAGE){ if(resultCode==RESULT_OK){ imageUri=data.getData(); // start crop activity UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.PNG); options.setCompressionQuality(100); options.setShowCropGrid(true); UCrop.of(imageUri, Uri.fromFile(new File(rootView.getContext().getCacheDir(), "hify_user_profile_picture.png"))) .withAspectRatio(1, 1) .withOptions(options) .start(getActivity()); } } if (requestCode == UCrop.REQUEST_CROP) { if (resultCode == RESULT_OK) { try { File compressedFile= new Compressor(rootView.getContext()).setCompressFormat(Bitmap.CompressFormat.PNG).setQuality(70).setMaxHeight(96).setMaxWidth(96).compressToFile(new File(UCrop.getOutput(data).getPath())); profile_pic.setImageURI(Uri.fromFile(compressedFile)); imageUri=Uri.fromFile(compressedFile); Toasty.info(rootView.getContext(), "Profile picture uploaded, click Save details button to apply changes", Toasty.LENGTH_LONG,true).show(); } catch (IOException e) { e.printStackTrace(); Toasty.info(rootView.getContext(), "Profile photo updated click Save details to apply but unable to compress: "+e.getLocalizedMessage(), Toasty.LENGTH_SHORT,true).show(); profile_pic.setImageURI(imageUri); imageUri = UCrop.getOutput(data); } } else if (resultCode == UCrop.RESULT_ERROR) { Log.e("Error", "Crop error:" + UCrop.getError(data).getMessage()); } } }
Example 14
Source File: RegisterActivity.java From Hify with MIT License | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==PICK_IMAGE){ if(resultCode==RESULT_OK){ imageUri=data.getData(); // start crop activity UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.PNG); options.setCompressionQuality(100); options.setShowCropGrid(true); UCrop.of(imageUri, Uri.fromFile(new File(getCacheDir(), "hify_user_profile_picture.png"))) .withAspectRatio(1, 1) .withOptions(options) .start(this); } } if (requestCode == UCrop.REQUEST_CROP) { if (resultCode == RESULT_OK) { imageUri = UCrop.getOutput(data); profile_image.setImageURI(imageUri); } else if (resultCode == UCrop.RESULT_ERROR) { Log.e("Error", "Crop error:" + UCrop.getError(data).getMessage()); } } }