Closed tiagobuchanelli closed 6 years ago
I need to cut two different images in the same activity. But with the code I have, the return is falling into a single loop.
How could I separate this return, to treat it independently?
Code:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == UCrop.RESULT_ERROR) { Toast.makeText(this, "uCrop error", Toast.LENGTH_SHORT).show(); return; } if (requestCode == UCrop.REQUEST_CROP) { mSelectImage.setImageResource(0); final Uri imgUri = UCrop.getOutput(data); mResultUri = imgUri; mSelectImage.setImageURI(mResultUri); temDadosSalvar = true; Toast.makeText(this, "Cortada", Toast.LENGTH_SHORT).show(); return; } if (requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK) { mImageUri = data.getData(); if (mImageUri == null) { mProgress.dismiss(); return; } else { File tempCropped = new File(getCacheDir(), "tempImgCropped.png"); Uri destinationUri = Uri.fromFile(tempCropped); UCrop uCrop = UCrop.of(mImageUri, destinationUri); uCrop = advancedConfig(uCrop); uCrop.start(this); } } if (requestCode == CAMERA_REQUEST_CODE_CAPA && resultCode == RESULT_OK) { mImageUri = data.getData(); if (mImageUri == null) { mProgress.dismiss(); return; } else { File tempCropped = new File(getCacheDir(), "tempImgCropped.png"); Uri destinationUri = Uri.fromFile(tempCropped); UCrop uCrop = UCrop.of(mImageUri, destinationUri); uCrop = advancedConfig(uCrop); uCrop.start(this); } } } }
Hey Instead of uCrop.start(this); you can use uCrop.start(this, myRequestCode);
uCrop.start(this);
uCrop.start(this, myRequestCode);
myRequestCodemight be any CONSTANT int to make difference between your different requests!
myRequestCode
I need to cut two different images in the same activity. But with the code I have, the return is falling into a single loop.
How could I separate this return, to treat it independently?
Code: