void PostCallback(object sender, EventArgs a) { sendItem.Enabled = false; if (Picture == null) { Post(); return; } var jpeg = Picture.AsJPEG(); Stream stream; unsafe { stream = new UnmanagedMemoryStream((byte *)jpeg.Bytes, jpeg.Length); } progressHud = new ProgressHud(Locale.GetText("Uploading Image"), Locale.GetText("Stop")); var uploader = TwitterAccount.CurrentAccount.UploadPicture(stream, PicUploadComplete, progressHud); progressHud.ButtonPressed += delegate { uploader.Cancel(); DestroyProgressHud(); }; View.AddSubview(progressHud); ThreadPool.QueueUserWorkItem(delegate { uploader.Upload(); // This captures the variable and handle of jpeg, and then we clear it // to release it jpeg = null; }); }
void RunDebugUi2() { var b = new ProgressHud ("Uploading image ", "Stop"); b.Progress = .5f; window.BringSubviewToFront (b); window.AddSubview (b); }
void Save() { userElement.FetchValue(); passwordElement.FetchValue(); hud = new ProgressHud(Locale.GetText("Authenticating"), Locale.GetText("Cancel")); hud.ButtonPressed += delegate { DestroyHud(); }; dvc.View.AddSubview(hud); // Send an incomplete request with login/password, if this returns 403, we got the wrong password ThreadPool.QueueUserWorkItem((x) => { bool ok = false; try { ok = ValidateCredentials(); } catch (Exception e) { Util.ReportError(this, e, Locale.GetText("While validating credentials")); } BeginInvokeOnMainThread(delegate { DestroyHud(); if (ok) { Close(true); } }); }); }
void RunDebugUi2() { var b = new ProgressHud("Uploading image ", "Stop"); b.Progress = .5f; window.BringSubviewToFront(b); window.AddSubview(b); }
public Uploader UploadPicture(Stream source, Action <string> completed, ProgressHud progressHud) { return(new Uploader(this) { SourceStream = source, UploadCompletedCallback = completed, ProgressHudView = progressHud }); }
void DestroyProgressHud() { progressHud.RemoveFromSuperview(); progressHud = null; }
void DestroyHud() { hud.RemoveFromSuperview(); hud = null; }
public Uploader UploadPicture(Stream source, Action<string> completed, ProgressHud progressHud) { return new Uploader (this) { SourceStream = source, UploadCompletedCallback = completed, ProgressHudView = progressHud }; }
void Save() { userElement.FetchValue (); passwordElement.FetchValue (); hud = new ProgressHud (Locale.GetText ("Authenticating"), Locale.GetText ("Cancel")); hud.ButtonPressed += delegate { DestroyHud (); }; dvc.View.AddSubview (hud); // Send an incomplete request with login/password, if this returns 403, we got the wrong password ThreadPool.QueueUserWorkItem ((x) => { bool ok = false; try { ok = ValidateCredentials (); } catch (Exception e){ Util.ReportError (this, e, "While validating credentials"); } BeginInvokeOnMainThread (delegate { DestroyHud (); if (ok) Close (true); }); }); }
void DestroyHud() { hud.RemoveFromSuperview (); hud = null; }
void PostCallback(object sender, EventArgs a) { sendItem.Enabled = false; if (Picture == null){ Post (); return; } var jpeg = Picture.AsJPEG (); Stream stream; unsafe { stream = new UnmanagedMemoryStream ((byte*) jpeg.Bytes, jpeg.Length); } progressHud = new ProgressHud (Locale.GetText ("Uploading Image"), Locale.GetText ("Stop")); var uploader = TwitterAccount.CurrentAccount.UploadPicture (stream, PicUploadComplete, progressHud); progressHud.ButtonPressed += delegate { uploader.Cancel (); DestroyProgressHud (); }; View.AddSubview (progressHud); ThreadPool.QueueUserWorkItem (delegate { uploader.Upload (); // This captures the variable and handle of jpeg, and then we clear it // to release it jpeg = null; }); }
void DestroyProgressHud() { progressHud.RemoveFromSuperview (); progressHud = null; }