//Result protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { try { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == CropImage.CropImageActivityRequestCode && resultCode == Result.Ok) // Add image { var result = CropImage.GetActivityResult(data); if (result.IsSuccessful) { var resultUri = result.Uri; if (!string.IsNullOrEmpty(resultUri.Path)) { // Chick if it was successful var check = WoWonderTools.CheckMimeTypesWithServer(resultUri.Path); if (!check) { //this file not supported on the server , please select another file Toast.MakeText(this, GetString(Resource.String.Lbl_ErrorFileNotSupported), ToastLength.Short)?.Show(); return; } var attach = new Attachments { Id = MAdapter.AttachmentList.Count + 1, TypeAttachment = "postPhotos[]", FileSimple = resultUri.Path, FileUrl = resultUri.Path }; MAdapter.Add(attach); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show(); } } else { Toast.MakeText(this, GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show(); } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void PickiTonCompleteListener(string path) { try { // Chick if it was successful var check = WoWonderTools.CheckMimeTypesWithServer(path); switch (check) { case false: //this file not supported on the server , please select another file Toast.MakeText(this, GetString(Resource.String.Lbl_ErrorFileNotSupported), ToastLength.Short)?.Show(); return; } var type = Methods.AttachmentFiles.Check_FileExtension(path); switch (type) { case "Image": MAdapter.PhotosList.Add(new PhotoAlbumObject { Image = path }); MAdapter.NotifyDataSetChanged(); PathImage.Add(new Attachments { Id = MAdapter.PhotosList.Count + 1, TypeAttachment = "postPhotos[]", FileSimple = path, FileUrl = path }); break; default: Toast.MakeText(this, GetText(Resource.String.Lbl_Failed_to_load), ToastLength.Short)?.Show(); break; } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
//private void OpenDialogGallery() //{ // try // { // // Check if we're running on Android 5.0 or higher // if ((int)Build.VERSION.SdkInt < 23) // { // Methods.Path.Chack_MyFolder(); // //Open Image // var myUri = Uri.FromFile(new File(Methods.Path.FolderDiskImage, Methods.GetTimestamp(DateTime.Now) + ".jpeg")); // CropImage.Builder() // .SetInitialCropWindowPaddingRatio(0) // .SetAutoZoomEnabled(true) // .SetMaxZoom(4) // .SetGuidelines(CropImageView.Guidelines.On) // .SetCropMenuCropButtonTitle(GetText(Resource.String.Lbl_Crop)) // .SetOutputUri(myUri).Start(this); // } // else // { // if (!CropImage.IsExplicitCameraPermissionRequired(this) && CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Granted && // CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Granted && CheckSelfPermission(Manifest.Permission.Camera) == Permission.Granted) // { // Methods.Path.Chack_MyFolder(); // //Open Image // var myUri = Uri.FromFile(new File(Methods.Path.FolderDiskImage, Methods.GetTimestamp(DateTime.Now) + ".jpeg")); // CropImage.Builder() // .SetInitialCropWindowPaddingRatio(0) // .SetAutoZoomEnabled(true) // .SetMaxZoom(4) // .SetGuidelines(CropImageView.Guidelines.On) // .SetCropMenuCropButtonTitle(GetText(Resource.String.Lbl_Crop)) // .SetOutputUri(myUri).Start(this); // } // else // { // new PermissionsController(this).RequestPermission(108); // } // } // } // catch (Exception e) // { // Console.WriteLine(e); // } //} #region PickiT >> Gert path file private void PickiTonCompleteListener(string path) { //Dismiss dialog and return the path try { // Check if it was a Drive/local/unknown provider file and display a Toast //if (wasDriveFile) => "Drive file was selected" //else if (wasUnknownProvider) => "File was selected from unknown provider" //else => "Local file was selected" // Chick if it was successful var check = WoWonderTools.CheckMimeTypesWithServer(path); if (!check) { //this file not supported on the server , please select another file Toast.MakeText(this, GetString(Resource.String.Lbl_ErrorFileNotSupported), ToastLength.Short).Show(); return; } var type = Methods.AttachmentFiles.Check_FileExtension(path); if (type == "Image") { var attach = new Attachments { Id = MAdapter.AttachmentList.Count + 1, TypeAttachment = "postPhotos[]", FileSimple = path, FileUrl = path }; MAdapter.Add(attach); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_Failed_to_load), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
private void PickiTonCompleteListener(string path) { //Dismiss dialog and return the path try { // Check if it was a Drive/local/unknown provider file and display a Toast //if (wasDriveFile) => "Drive file was selected" //else if (wasUnknownProvider) => "File was selected from unknown provider" //else => "Local file was selected" // Chick if it was successful var check = WoWonderTools.CheckMimeTypesWithServer(path); if (!check) { //this file not supported on the server , please select another file Toast.MakeText(this, GetString(Resource.String.Lbl_ErrorFileNotSupported), ToastLength.Short).Show(); return; } var type = Methods.AttachmentFiles.Check_FileExtension(path); if (type == "Image") { File file2 = new File(PathImage); var photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2); Glide.With(this).Load(photoUri).Apply(new RequestOptions()).Into(ImgGallery); //GlideImageLoader.LoadImage(this, PathImage, ImgGallery, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_Failed_to_load), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
//Result protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { try { base.OnActivityResult(requestCode, resultCode, data); switch (requestCode) { // Add image case 500 when resultCode == Result.Ok: { if (data.ClipData != null) { var mClipData = data.ClipData; for (var i = 0; i < mClipData.ItemCount; i++) { var item = mClipData.GetItemAt(i); Uri uri = item.Uri; var filepath = Methods.AttachmentFiles.GetActualPathFromFile(this, uri); PickiTonCompleteListener(filepath); } } else { Uri uri = data.Data; var filepath = Methods.AttachmentFiles.GetActualPathFromFile(this, uri); PickiTonCompleteListener(filepath); } break; } case CropImage.CropImageActivityRequestCode when resultCode == Result.Ok: { var result = CropImage.GetActivityResult(data); switch (result.IsSuccessful) { case true: { var resultUri = result.Uri; switch (string.IsNullOrEmpty(resultUri.Path)) { case false: { var check = WoWonderTools.CheckMimeTypesWithServer(resultUri.Path); switch (check) { case false: //this file not supported on the server , please select another file Toast.MakeText(this, GetString(Resource.String.Lbl_ErrorFileNotSupported), ToastLength.Short)?.Show(); return; } MAdapter.PhotosList.Add(new PhotoAlbumObject { Image = resultUri.Path }); MAdapter.NotifyDataSetChanged(); PathImage.Add(new Attachments { Id = MAdapter.PhotosList.Count + 1, TypeAttachment = "postPhotos[]", FileSimple = resultUri.Path, FileUrl = resultUri.Path }); break; } } break; } } break; } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }