Пример #1
0
		public async override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			var remoteExplorer = new RemoteExplorer ();

			try {
				var remoteSites = await remoteExplorer.GetSites ();

				foreach (LocalBox box in DataLayer.Instance.GetLocalBoxesSync()) {
					for (int i = 0; i < remoteSites.Count; i++) {
						if (box.BaseUrl == remoteSites[i].Url) {
							remoteSites.RemoveAt(i);
							break;
						}
					}
				}

				foreach (Site site in remoteSites) {
					sites.Add(site);
				}

				sitesAdapter.NotifyDataSetChanged();
			} catch (Exception ex) {
				Insights.Report (ex);
			}
		}
		public override async void ViewDidAppear(bool didAppear) 
		{
			ActivityIndicator.Hidden = false;
			ActivityIndicator.StartAnimating ();

			// Perform any additional setup after loading the view, typically from a nib.
			if (DataLayer.Instance.GetLocalBoxesSync ().Count > 0) {
				var remoteExplorer = new RemoteExplorer ();

				try {
					List<Site> sites = await remoteExplorer.GetSites ();

					foreach (LocalBox box in DataLayer.Instance.GetLocalBoxesSync()) {
						for (int i = 0; i < sites.Count; i++) {
							if (box.BaseUrl == sites [i].Url) {
								sites.RemoveAt (i);
								break;
							}
						}
					}

					ActivityIndicator.StopAnimating ();
					ActivityIndicator.Hidden = true;

					_tableSource = new TableSource (sites);
					TableView.Source = _tableSource;
					TableView.ReloadData ();

					if (sites.Count == 0) {
						GeenSites.Hidden = false;

						if (_introduction) {
							ToevoegenButton.SetTitle("Verder", UIControlState.Normal);
						}
					}
				} catch (Exception ex) {
					Insights.Report (ex);
					DialogHelper.ShowErrorDialog ("Fout", "Er is een fout opgetreden tijdens het ophalen van de sites.");
				}
			}
		}