Java Code Examples for com.theartofdev.edmodo.cropper.CropImage#getActivityResult()
The following examples show how to use
com.theartofdev.edmodo.cropper.CropImage#getActivityResult() .
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: PublishProfilePictureActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { this.avatarUri = result.getUri(); if (xmppConnectionServiceBound) { loadImageIntoPreview(this.avatarUri); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); if (error != null) { ToastCompat.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == REQUEST_CHOOSE_PICTURE) { if (resultCode == RESULT_OK) { cropUri(this, data.getData()); } } }
Example 2
Source File: PublishGroupChatProfilePictureActivity.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { final CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { this.uri = result.getUri(); if (xmppConnectionServiceBound) { reloadAvatar(); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); if (error != null) { Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == REQUEST_CHOOSE_PICTURE) { if (resultCode == RESULT_OK) { PublishProfilePictureActivity.cropUri(this, data.getData()); } } }
Example 3
Source File: PublishProfilePictureActivity.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { this.avatarUri = result.getUri(); if (xmppConnectionServiceBound) { loadImageIntoPreview(this.avatarUri); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); if (error != null) { Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == REQUEST_CHOOSE_PICTURE) { if (resultCode == RESULT_OK) { cropUri(this, data.getData()); } } }
Example 4
Source File: MainActivity.java From Android-Image-Cropper with Apache License 2.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // handle result of CropImageActivity if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { ((ImageView) findViewById(R.id.quick_start_cropped_image)).setImageURI(result.getUri()); Toast.makeText( this, "Cropping successful, Sample: " + result.getSampleSize(), Toast.LENGTH_LONG) .show(); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show(); } } }
Example 5
Source File: MainActivity.java From Android-Image-Cropper with Apache License 2.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // handle result of CropImageActivity if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { ((ImageView) findViewById(R.id.quick_start_cropped_image)).setImageURI(result.getUri()); Toast.makeText( this, "Cropping successful, Sample: " + result.getSampleSize(), Toast.LENGTH_LONG) .show(); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show(); } } }
Example 6
Source File: PublishGroupChatProfilePictureActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { final CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { this.uri = result.getUri(); if (xmppConnectionServiceBound) { reloadAvatar(); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); if (error != null) { ToastCompat.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == REQUEST_CHOOSE_PICTURE) { if (resultCode == RESULT_OK) { PublishProfilePictureActivity.cropUri(this, data.getData()); } } }
Example 7
Source File: SetupActivity.java From Simple-Blog-App with MIT License | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == GALLARY_REQUEST && resultCode == RESULT_OK) { Uri imageUri = data.getData(); CropImage.activity(imageUri) .setGuidelines(CropImageView.Guidelines.ON) .setAspectRatio(1, 1) .start(this); } if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { mImageUri = result.getUri(); mSetupImage.setImageURI(mImageUri); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); Log.d("setupError", error + ""); } } }
Example 8
Source File: ProfileActivity.java From Travel-Mate with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == VERIFICATION_REQUEST_CODE) { recreate(); } if (data == null) return; //After user has picked the image if (requestCode == RESULT_PICK_IMAGE && data.hasExtra("remove_image")) { deleteProfilePicture(); } else if (requestCode == RESULT_PICK_IMAGE && resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); //startCropIntent(selectedImage); CropImage.activity(selectedImage).start(this); } //After user has cropped the image if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri croppedImage = result.getUri(); getUrlFromCloudinary(croppedImage); } } }
Example 9
Source File: ProfileEditActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK) { Uri imageUri = data.getData(); CropImage.activity(imageUri) .setGuidelines(CropImageView.Guidelines.ON) .setCropShape(CropImageView.CropShape.OVAL) .setAspectRatio(1, 1) .start(this); } if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { mImageUri = result.getUri(); editProfilepic.setImageURI(mImageUri); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); Log.e(TAG + "crop_error", error.toString()); } } }
Example 10
Source File: MainFragment.java From Android-Image-Cropper with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); handleCropResult(result); } }
Example 11
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 12
Source File: ChannelNameActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(intent); if (resultCode == RESULT_OK) { if (intent == null) { return; } if (imageChangeUri != null) { imageChangeUri = result.getUri(); applozicGroupProfileIcon.setImageDrawable(null); // <--- added to force redraw of ImageView applozicGroupProfileIcon.setImageURI(imageChangeUri); } else { imageChangeUri = result.getUri(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg"; applozicGroupProfileIcon.setImageDrawable(null); // <--- added to force redraw of ImageView applozicGroupProfileIcon.setImageURI(imageChangeUri); profilePhotoFile = FileClientService.getFilePath(imageFileName, this, "image/jpeg"); fileClientService.writeFile(imageChangeUri, profilePhotoFile); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Utils.printLog(this,ChannelNameActivity.class.getName(),this.getString(R.string.applozic_Cropping_failed)+result.getError()); } } if (resultCode == Activity.RESULT_OK) { handleOnActivityResult(requestCode, intent); } }
Example 13
Source File: ChannelCreateActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); try { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(intent); if (resultCode == RESULT_OK) { if (intent == null) { return; } if (imageChangeUri != null) { imageChangeUri = result.getUri(); circleImageView.setImageDrawable(null); // <--- added to force redraw of ImageView circleImageView.setImageURI(imageChangeUri); new ProfilePictureUpload(true, profilePhotoFile, imageChangeUri, ChannelCreateActivity.this).execute((Void[]) null); } else { imageChangeUri = result.getUri(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg"; circleImageView.setImageDrawable(null); // <--- added to force redraw of ImageView circleImageView.setImageURI(imageChangeUri); profilePhotoFile = FileClientService.getFilePath(imageFileName, this, "image/jpeg"); new ProfilePictureUpload(true, profilePhotoFile, imageChangeUri, ChannelCreateActivity.this).execute((Void[]) null); } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Toast.makeText(this, this.getString(R.string.applozic_Cropping_failed) + result.getError(), Toast.LENGTH_LONG).show(); } } if (resultCode == Activity.RESULT_OK) { handleOnActivityResult(requestCode, intent); } } catch (Exception e) { Utils.printLog(this, TAG, "exception in profile image"); } }
Example 14
Source File: MediaPagerFragment.java From Gallery-example with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri resultUri = result.getUri(); SaveTools.saveCrop(getActivity(), resultUri, url); } } }
Example 15
Source File: MediaBrowser.java From Gallery-example with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { final Uri resultUri = result.getUri(); SaveTools.saveCrop(MediaBrowser.this, resultUri, url); } } }
Example 16
Source File: SettingsFragmentView.java From FastAccess with GNU General Public License v3.0 | 4 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == IconPackHelper.PICK_ICON) { Bitmap bitmap = data.getParcelableExtra("icon"); if (bitmap == null) { Uri uri = data.getData(); if (uri != null) { File file = FileHelper.generateFile("fa_image_icon"); try { Files.copy(new File(uri.getPath()), file); } catch (IOException e) { e.printStackTrace(); showToast(R.string.error_retrieving_icon); return; } PrefHelper.set(PrefConstant.CUSTOM_ICON, file.getPath()); EventBus.getDefault().post(new FloatingEventModel(true, PrefConstant.CUSTOM_ICON)); } else { showToast(R.string.error_retrieving_icon); } } else { String path = AppHelper.saveBitmap(bitmap); if (path == null) { showToast(R.string.write_sdcard_explanation); return; } PrefHelper.set(PrefConstant.CUSTOM_ICON, path); EventBus.getDefault().post(new FloatingEventModel(true, PrefConstant.CUSTOM_ICON)); if (!bitmap.isRecycled()) { bitmap.recycle(); } } } else if (requestCode == ActivityHelper.SELECT_PHOTO_REQUEST) { CropImage.activity(data.getData()) .setCropShape(CropImageView.CropShape.OVAL) .setOutputUri(Uri.fromFile(FileHelper.generateFile("fa_image_icon"))) .setAspectRatio(5, 5) .setFixAspectRatio(true) .setOutputCompressFormat(Bitmap.CompressFormat.PNG) .start(getContext(), this); } else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); Uri resultUri = result.getUri(); PrefHelper.set(PrefConstant.CUSTOM_ICON, new File(resultUri.getPath()).getPath()); EventBus.getDefault().post(new FloatingEventModel(true, PrefConstant.CUSTOM_ICON)); } } else if (resultCode == Activity.RESULT_CANCELED) { if (requestCode == IconPackHelper.PICK_ICON) { if (data != null) { boolean defaultIcon = data.getBooleanExtra("default", false); if (defaultIcon) { PrefHelper.set(PrefConstant.CUSTOM_ICON, ""); EventBus.getDefault().post(new FloatingEventModel(true, PrefConstant.CUSTOM_ICON)); } } } } }
Example 17
Source File: FlutterImagePickCropPlugin.java From FlutterImagePickCrop with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.M) @RequiresApi(api = Build.VERSION_CODES.M) @Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri resultUri = result.getUri(); finishWithSuccess(resultUri.getPath()); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); finishWithError("Failed Permission",error.getMessage()); } return true; } if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == RESULT_OK) { Uri imageUri = CropImage.getPickImageResultUri(context, data); if (CropImage.isReadExternalStoragePermissionsRequired(context, imageUri)) { mCropImageUri = imageUri; //Toast.makeText(activity, "check: " + mCropImageUri.toString(), Toast.LENGTH_SHORT).show(); activity.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE); } else { startCropImageActivity(imageUri); } return true; } // // else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) { // Uri imageUri = CropImage.getPickImageResultUri(context, data); // if (imageUri != null) { // finishWithSuccess(imageUri.getPath()); // }else { // finishWithSuccess(null); // } // return true; // } return false; }
Example 18
Source File: ImageUtilityHelper.java From AndroidDesignPatterns with Apache License 2.0 | 4 votes |
public void onSelectionResult(int requestCode, int resultCode, Intent data) { //For Android-Image-Cropper if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri resultUri = result.getUri(); cropImageView.setImageURI(resultUri); isDeleteLocalImage = true; } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); Toast.makeText(mContext, "" + error, Toast.LENGTH_SHORT).show(); } } else //For Image chooser intent if (resultCode == RESULT_OK) { if (requestCode == MainActivity.IMAGE_CHOOSER_CODE) { boolean isCamera; if (data == null) { isCamera = true; } else { final String action = data.getAction(); if (action == null) { isCamera = false; } else { isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); } } if (isCamera) { //Result From Camera localImageFile = new File(Environment.getExternalStorageDirectory().toString()); for (File temp : localImageFile.listFiles()) { if (temp.getName().equals("temp.jpg")) { localImageFile = temp; break; } } Uri selectedFileUri = Uri.fromFile(localImageFile); //call image crop activity getSetCropImage(selectedFileUri); } else { //Result From Gallery Uri selectedImageUri = data.getData(); //call image crop activity getSetCropImage(selectedImageUri); } } } }
Example 19
Source File: ConversationActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { try { conversationUIService.onActivityResult(requestCode, resultCode, data); handleOnActivityResult(requestCode, data); if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { if (data == null) { return; } if (imageUri != null) { imageUri = result.getUri(); if (imageUri != null && profilefragment != null) { profilefragment.handleProfileimageUpload(true, imageUri, profilePhotoFile); } } else { imageUri = result.getUri(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg"; profilePhotoFile = FileClientService.getFilePath(imageFileName, this, "image/jpeg"); if (imageUri != null && profilefragment != null) { profilefragment.handleProfileimageUpload(true, imageUri, profilePhotoFile); } } } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Utils.printLog(this, ConversationActivity.class.getName(), "Cropping failed:" + result.getError()); } } if (requestCode == LOCATION_SERVICE_ENABLE) { if (((LocationManager) getSystemService(Context.LOCATION_SERVICE)) .isProviderEnabled(LocationManager.GPS_PROVIDER)) { googleApiClient.connect(); } else { Toast.makeText(ConversationActivity.this, R.string.unable_to_fetch_location, Toast.LENGTH_LONG).show(); } return; } } catch (Exception e) { e.printStackTrace(); } }