本文整理汇总了Java中com.theartofdev.edmodo.cropper.CropImage.getActivityResult方法的典型用法代码示例。如果您正苦于以下问题:Java CropImage.getActivityResult方法的具体用法?Java CropImage.getActivityResult怎么用?Java CropImage.getActivityResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.theartofdev.edmodo.cropper.CropImage
的用法示例。
在下文中一共展示了CropImage.getActivityResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_REQUEST_CODE && 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();
mProfilePicture.setImageURI(mImageUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(CreateProfileActivity.this, "Failed to get profile picture, Try Again.", Toast.LENGTH_LONG).show();
}
}
}
示例2: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_REQUEST_CODE && 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) {
imageUri = result.getUri();
getProfilePicture.setImageURI(imageUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(ViewEditProfileActivity.this, "Failed to get profile picture, please try again.", Toast.LENGTH_LONG).show();
}
}
}
示例3: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri resultUri = result.getUri();
File file = FunctionHelper.createFileFromUri(this, resultUri);
if (file == null) return;
if (view_ShowMenu == img_avatar) {
changeImage(img_avatar, file.getAbsolutePath());
} else if (view_ShowMenu == img_background) {
changeImage(img_background, file.getAbsolutePath());
}
view_ShowMenu = null;
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
@SuppressWarnings("ThrowableNotThrown") Exception error = result.getError();
Log.d(TAG, error.toString());
}
break;
}
}
示例4: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
addImageLabel.setVisibility(View.GONE);
CropImage.ActivityResult result = CropImage.getActivityResult(data);
Uri resultUri = result.getUri();
imageURi = resultUri;
if (resultUri != null) {
feedImage.setImageURI(resultUri);
}
}
}
}
示例5: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case GALLERY_CODE:
if (data != null) {
Uri uri = data.getData();
cropImage(uri);
}
break;
case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri picUri = result.getUri();
saveBImage(picUri);
demoIv.setImageURI(picUri);
//demoIv.setBackgroundColor(Color.TRANSPARENT);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
break;
}
}
示例6: handleCropImageResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
protected void handleCropImageResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
if (ValidationUtil.checkImageMinSize(result.getCropRect())) {
imageUri = result.getUri();
loadImageToImageView();
} else {
showSnackBar(R.string.error_smaller_image);
}
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
LogUtil.logError(TAG, "crop image error", result.getError());
showSnackBar(R.string.error_fail_crop_image);
}
}
}
示例7: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE: {
if (resultCode == RESULT_OK) {
CropImage.activity(data.getData())
.setActivityTitle(getString(R.string.crop))
.setAspectRatio(1, 1)
.setFixAspectRatio(true)
.start(this);
}
break;
}
case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE: {
if (resultCode == RESULT_OK) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
returnUri(result.getUri());
}
break;
}
}
}
示例8: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == RQ_GALLERY) {
if (data != null) {
initCropImageActivity(data.getData());
}
} else if (resultCode == Activity.RESULT_OK && requestCode == RQ_CAMERA) {
profilePicturePath = editAccountPresenter.getSelectedFile().getAbsolutePath();
Uri selectedPhotoUri = Uri.fromFile(new File(profilePicturePath));
initCropImageActivity(selectedPhotoUri);
} else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == Activity.RESULT_OK) {
Uri croppedImageUri = result.getUri();
profilePicturePath = croppedImageUri.getPath();
editAccountPresenter.uploadImage(MediaUtils.get().getReducedBitmapFile(croppedImageUri));
}
}
}
示例9: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@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();
}
}
}
示例10: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@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();
}
}
}
示例11: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@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);
}
}
示例12: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// handle result of pick image chooser
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
Uri imageUri = CropImage.getPickImageResultUri(this, data);
if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
cropImageUri = imageUri;
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
} else {
startCropImageActivity(imageUri);
}
} else {
Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, ""), Snackbar.LENGTH_SHORT).show();
}
} else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
vehiclePicturePath = result.getUri().getPath();
Picasso.with(getApplicationContext()).load(new File(vehiclePicturePath)).into(imgCarPhoto);
imgCarPhoto.setAlpha(REMOVE_PHOTO_ALPHA_CHANNEL);
imgCarPhotoRemove.setVisibility(View.VISIBLE);
Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_success), Snackbar.LENGTH_SHORT).show();
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, error), Snackbar.LENGTH_SHORT).show();
}
}
}
示例13: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@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();
Event_image.setImageURI(resultUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
Log.d("someerror",error.toString());
}
}
}
示例14: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// handle result of pick image chooser
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
this.imageUri = CropImage.getPickImageResultUri(this, data);
// For API >= 23 we need to check specifically that we have permissions to read external storage.
if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
// request permissions and handle the result in onRequestPermissionsResult()
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
} else {
// no permissions required or already grunted, can start crop image activity
startCropper(imageUri);
}
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
Uri resultUri = result.getUri();
// Start creator
new CustomCreator(this, resultUri).setListener(this).execute();
}
if (requestCode == PreviewActivity.PREVIEW_ACTIVITY_REQUEST_CODE && resultCode == PreviewActivity.RESULT_OK) {
if (data != null) {
CatalogItem catalogItem = data.getParcelableExtra(PreviewActivity.EXTRA_CATALOG_ITEM);
if (catalogItem != null) {
downloadBackground(catalogItem);
}
}
}
}
示例15: onActivityResult
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constants.RESULT_PROFILE_IMAGE_SELECTED) { // image selected. Crop the image
if (resultCode == RESULT_OK && data != null && data.getData() != null) {
startImageCrop(data.getData());
} else if (resultCode != RESULT_CANCELED) {
Toast.makeText(getActivity(), getString(R.string.image_selection_error), Toast.LENGTH_SHORT).show();
}
} else if (requestCode == Constants.RESULT_PROFILE_IMAGE_TAKEN) { // image taken. Crop the image
if (resultCode == RESULT_OK) {
Uri uri = FileProvider.getUriForFile(getActivity(), getString(R.string.file_provider),
mPresenter.getTempImageFileForOwner());
getActivity().revokeUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startImageCrop(uri);
} else if (resultCode != RESULT_CANCELED) {
Toast.makeText(getActivity(), getString(R.string.image_taking_error), Toast.LENGTH_SHORT).show();
}
} else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { // image cropped
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Bitmap bitmap = ImageHelper.decodeSampledBitmapFromUri(getActivity().getContentResolver(),
result.getUri(), Constants.PROFILE_IMAGE_WIDTH, Constants.PROFILE_IMAGE_HEIGHT);
mPresenter.newProfileImageSelected(bitmap);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Diagnostic.logError(Diagnostic.DiagnosticFlag.Other, "Image failed to be cropped");
Toast.makeText(getActivity(), getString(R.string.image_selection_error), Toast.LENGTH_SHORT).show();
}
} else if (requestCode == Constants.RESULT_PROFILE_UPDATE && resultCode == Activity.RESULT_OK) { // bio updated
if (getView() != null) {
((TextView) getView().findViewById(R.id.profile_bio)).setText(data.getStringExtra("bio"));
Toast.makeText(getActivity(), getString(R.string.updated), Toast.LENGTH_SHORT).show();
}
}
}