void ReleaseDesignerOutlets() { if (FirstNameTextField != null) { FirstNameTextField.Dispose(); FirstNameTextField = null; } if (LastNameTextField != null) { LastNameTextField.Dispose(); LastNameTextField = null; } if (ProfileImageButton != null) { ProfileImageButton.Dispose(); ProfileImageButton = null; } if (SaveButton != null) { SaveButton.Dispose(); SaveButton = null; } if (ScrollView != null) { ScrollView.Dispose(); ScrollView = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); var me = RealmUserServices.GetMe(false); FirstNameTextField.KeyboardType = UIKeyboardType.EmailAddress; FirstNameTextField.Text = me.FirstName; FirstNameTextField.Placeholder = Strings.Basic.first_name; FirstNameTextField.AutocorrectionType = UITextAutocorrectionType.No; FirstNameTextField.EditingDidEndOnExit += (sender, e) => { FirstNameTextField.ResignFirstResponder(); }; LastNameTextField.KeyboardType = UIKeyboardType.EmailAddress; LastNameTextField.Text = me.LastName; LastNameTextField.Placeholder = Strings.Basic.last_name; LastNameTextField.AutocorrectionType = UITextAutocorrectionType.No; LastNameTextField.EditingDidEndOnExit += (sender, e) => { LastNameTextField.ResignFirstResponder(); }; ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); ProfileImageButton.Layer.MasksToBounds = true; ProfileImageButton.Layer.CornerRadius = ProfileImageButton.Frame.Size.Width / 2; ProfileImageButton.ClipsToBounds = true; ProfileImageButton.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray; SetProgressButton(SaveButton); RemoveBackBarButtonTitle(); }
void SelectImageFromGallery(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var vc = new GalleryImagePicker(); vc.Canceled += (s, e) => { vc.DismissViewController(true, null); }; vc.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs e) => { switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": Console.WriteLine("Image selected"); var me = RealmUserServices.GetMe(false); ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage; var smallerImage = ImageUtils.ScaledToSize(originalImage, new CGSize(200, 200)); var bytes = ImageUtils.ByteArrayFromImage(smallerImage, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); break; case "public.video": Console.WriteLine("Video selected"); break; } vc.DismissViewController(true, null); }; PresentViewController(vc, true, null); }
void DownloadFacebookImage(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } var url = me.GetFacebookProfilePictureUrl(); if (url == null) { return; } ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { ProfileImageButton.ShowLoadingIndicators(); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); }); }