我正在使用uCrop库来执行图像裁剪。
我需要在同一个活动中剪切两个不同的图像。但是使用我拥有的代码,返回会落入一个循环中。
我怎么能把这个回报分开,独立对待呢?
代码:
@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);
}
}
}
}