public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); try { if (resultCode == (int)Result.Ok) { if (requestCode == SELECT_PICTURE) { Uri selectedImageURI = data.Data; CropImage(selectedImageURI); } else if (requestCode == REQUEST_IMAGE_CAPTURE) { CropImage(GetCacheImagePath(fileName)); } else if (requestCode == UCrop.RequestCrop) { uri = UCrop.GetOutput(data); Glide.With(this).Load(uri).Into(postImageView); hasImage = true; doneBtn.Enabled = commentEt.EditText.Text.Length >= 6 && hasImage; } else if (requestCode == UCrop.ResultError) { throw UCrop.GetError(data); } } } catch (System.Exception) { } }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); try { if (resultCode == (int)Result.Ok) { if (requestCode == SELECT_PICTURE) { Uri selectedImageURI = data.Data; CropImage(selectedImageURI); } else if (requestCode == REQUEST_IMAGE_CAPTURE) { CropImage(GetCacheImagePath(fileName)); } else if (requestCode == UCrop.RequestCrop) { var uri = UCrop.GetOutput(data); OnCropComplete?.Invoke(this, new CropCompleteEventArgs { imageUri = uri }); DismissAllowingStateLoss(); } else if (requestCode == UCrop.ResultError) { throw UCrop.GetError(data); } } } catch (System.Exception) { } }
private void HandleCropError(Intent result) { Throwable cropError = UCrop.GetError(result); if (cropError != null) { System.Diagnostics.Debug.WriteLine(cropError.Message); Toast.MakeText(this, cropError.Message, ToastLength.Long).Show(); } else { Toast.MakeText(this, Resource.String.toast_unexpected_error, ToastLength.Short).Show(); } }
private void HandleActivityResultError(RequestCode requestCode, Intent data) { switch (requestCode) { case RequestCode.ImageOpen: System.Diagnostics.Debug.WriteLine("RequestImageOpen error"); Snackbar.Make(rootView, Resource.String.image_input_result_error, Snackbar.LengthIndefinite).SetAction(Android.Resource.String.Ok, (v) => { }).Show(); break; case RequestCode.Camera: Snackbar.Make(rootView, Resource.String.camera_result_error, Snackbar.LengthIndefinite).SetAction(Android.Resource.String.Ok, (v) => { }).Show(); break; case RequestCode.Crop: Java.Lang.Throwable cropError = UCrop.GetError(data); cropError.PrintStackTrace(); Snackbar.Make(rootView, Resource.String.crop_result_error, Snackbar.LengthIndefinite).SetAction(Android.Resource.String.Ok, (v) => { }).Show(); break; } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { switch (requestCode) { case RequestCamera when resultCode == Result.Ok: CropImage(); break; case RequestGallery when resultCode == Result.Ok && data != null: _photoUri = data.Data; CropImage(); break; case UCrop.RequestCrop when resultCode == Result.Ok: if (data == null) { return; } var croppedImageUri = UCrop.GetOutput(data); _ivResult.SetImageURI(croppedImageUri); break; case UCrop.ResultError: case 69: var error = UCrop.GetError(data); Log.Error("error", error.ToString()); Toast.MakeText(this, "Failed to crop image.", ToastLength.Long).Show(); break; default: Toast.MakeText(this, "Request has cancelled.", ToastLength.Long).Show(); break; } }