Permalink
Browse files

UI Tuneups, and avoid a crash on simulator

  • Loading branch information...
migueldeicaza committed Mar 9, 2011
1 parent b0ae8c0 commit d6980add67c9d87d10fcdc2be227c91937aeecb0
@@ -197,12 +197,14 @@ void Launch (string url, bool callbackOnMainThread, Action<Stream> callback)
}
} catch (WebException we){
var response = we.Response as HttpWebResponse;
- switch (response.StatusCode){
- case HttpStatusCode.Unauthorized:
- // This is the case of sharing two keys
- break;
+ if (response != null){
+ switch (response.StatusCode){
+ case HttpStatusCode.Unauthorized:
+ // This is the case of sharing two keys
+ break;
+ }
+ stream = null;
}
- stream = null;
Console.WriteLine (we);
} catch (Exception e) {
Console.WriteLine (e);
@@ -308,7 +310,7 @@ void SetProgress (float newvalue)
progressValue = newvalue;
TwitterAccount.invoker.BeginInvokeOnMainThread (delegate {
- ProgressHudView.Progress = progressValue;
+ // ProgressHudView.Progress = progressValue;
});
}
@@ -331,15 +333,19 @@ public void Upload ()
Stream upload = GenerateYFrogFrom (boundary, SourceStream, account.Username);
req.ContentLength = upload.Length;
SetProgress (0);
- using (var rs = req.GetRequestStream ()){
- SetProgress (0.1f);
- upload.Position = 0;
- CopyToEnd (upload, rs, (sofar) => {
- SetProgress (.1f + ((sofar/upload.Length) * 0.9f));
- });
- try {
- rs.Close ();
- } catch {}
+ try {
+ using (var rs = req.GetRequestStream ()){
+ SetProgress (0.1f);
+ upload.Position = 0;
+ CopyToEnd (upload, rs, (sofar) => {
+ SetProgress (.1f + ((sofar/upload.Length) * 0.9f));
+ });
+ try {
+ rs.Close ();
+ } catch {}
+ }
+ } catch (Exception e){
+ UploadCompletedCallback (null);
}
if (stop)
return;
@@ -359,7 +365,7 @@ public void Upload ()
return;
invoker.BeginInvokeOnMainThread (delegate {
- ProgressHudView.Progress = 1;
+ //ProgressHudView.Progress = 1;
UploadCompletedCallback (urlToPic);
});
}
@@ -33,7 +33,6 @@
<MtouchExtraArgs>-i18n=west -mapinject</MtouchExtraArgs>
<MtouchI18n />
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <MtouchSdkVersion>4.3</MtouchSdkVersion>
<MtouchUseLlvm>false</MtouchUseLlvm>
<MtouchUseArmv7>false</MtouchUseArmv7>
<MtouchUseThumb>false</MtouchUseThumb>
@@ -52,8 +52,13 @@ public ComposerView (RectangleF bounds, Composer composer, EventHandler cameraTa
{
this.composer = composer;
textView = new UITextView (RectangleF.Empty) {
- Font = UIFont.SystemFontOfSize (18)
+ Font = UIFont.SystemFontOfSize (18),
};
+
+ // Work around an Apple bug in the UITextView that crashes
+ if (MonoTouch.ObjCRuntime.Runtime.Arch == MonoTouch.ObjCRuntime.Arch.SIMULATOR)
+ textView.AutocorrectionType = UITextAutocorrectionType.No;
+
textView.Changed += HandleTextViewChanged;
charsLeft = new UILabel (RectangleF.Empty) {
@@ -406,13 +411,12 @@ void PostCallback (object sender, EventArgs a)
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 ();
@@ -73,7 +73,7 @@ public override void LayoutSubviews ()
float width = captionSize.Width < minWidth ? minWidth : captionSize.Width;
var bounds = Bounds;
- HudRect = new RectangleF ((bounds.Width-width)/2, bounds.Height > bounds.Width ? 120 : 60, width, 120);
+ HudRect = new RectangleF ((bounds.Width-width)/2, bounds.Height > bounds.Width ? 60 : 30, width, 120);
var ss = StringSize (buttonText, font);
var sh = Math.Max (ss.Height, 30);

0 comments on commit d6980ad

Please sign in to comment.