Example #1
0
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            if (Url == null)
            {
                base.Selected(dvc, tableView, path);
                return;
            }

            tableView.DeselectRow(path, false);
            if (loading)
            {
                return;
            }
            var cell    = GetActiveCell();
            var spinner = StartSpinner(cell);

            loading = true;

            var wc = new WebClient();

            wc.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e){
                dvc.BeginInvokeOnMainThread(delegate {
                    loading = false;
                    spinner.StopAnimating();
                    spinner.RemoveFromSuperview();
                    if (e.Result != null)
                    {
                        try {
                            var obj = JsonValue.Load(new StringReader(e.Result)) as JsonObject;
                            if (obj != null)
                            {
                                var root   = JsonElement.FromJson(obj);
                                var newDvc = new DialogViewController(root, true)
                                {
                                    Autorotate = true
                                };
                                PrepareDialogViewController(newDvc);
                                dvc.ActivateController(newDvc);
                                return;
                            }
                        } catch (Exception ee) {
                            Console.WriteLine(ee);
                        }
                    }
                    IUIAlertViewDelegate avd = null;
                    var alert = new UIAlertView("Error", "Unable to download data", avd, "OK", null);
                    alert.Show();
                });
            };
            wc.DownloadStringAsync(new Uri(Url));
        }
Example #2
0
		public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			if (Url == null){
				base.Selected (dvc, tableView, path);
				return;
			}

			tableView.DeselectRow (path, false);
			if (loading)
				return;
			var cell = GetActiveCell ();
			var spinner = StartSpinner (cell);
			loading = true;

			var wc = new WebClient ();

			wc.DownloadStringCompleted += delegate  (object sender, DownloadStringCompletedEventArgs e){
				dvc.BeginInvokeOnMainThread (delegate {
					loading = false;
					spinner.StopAnimating ();
					spinner.RemoveFromSuperview ();
					if (e.Result != null){
						try {
							var obj = JsonValue.Load (new StringReader (e.Result)) as JsonObject;
							if (obj != null){
								var root = JsonElement.FromJson (obj);
								var newDvc = new DialogViewController (root, true) {
									Autorotate = true
								};
								PrepareDialogViewController (newDvc);
								dvc.ActivateController (newDvc);
								return;
							}
						} catch (Exception ee){
							Console.WriteLine (ee);
						}
					}
					var alert = new UIAlertView ("Error", "Unable to download data", null, "Ok");
					alert.Show ();
				});
			};
			wc.DownloadStringAsync (new Uri (Url));
		}