Praeclarum.UI.DocumentsViewController.ViewDidLoad C# (CSharp) Method

ViewDidLoad() public method

public ViewDidLoad ( ) : void
return void
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			//
			// Create the refresh control
			//
			try {
				refresh = new UIRefreshControl {
					TintColor = UIColor.FromWhiteAlpha (59 / 255.0f, 1),
				};
				refresh.ValueChanged += async (sim, e) => {
					try {
						var fs = FileSystemManager.Shared.ActiveFileSystem;
						await fs.Sync (SyncTimeout);
						if (fs.IsSyncing)
							ShowSyncError ();
						else
							await LoadDocs ();
					} catch (Exception ex) {
						Debug.WriteLine (ex);					
					} finally {
						refresh.EndRefreshing ();
					}
				};
			} catch (Exception ex) {
				Log.Error (ex);				
			}

			//
			// Create our view
			//
			try {
				SwitchToMode (false);
				((UIView)docsView).AddSubview (refresh);				
			} catch (Exception ex) {
				Log.Error (ex);				
			}

			//
			// Set the add button
			//
			try {
				SetNormalNavItems (false);
			} catch (Exception ex) {
				Log.Error (ex);				
			}

			//
			// Load the documents
			//
			try {
				LoadDocs ().ContinueWith (t => {
					if (t.IsFaulted)
						Log.Error (t.Exception);

					BeginInvokeOnMainThread(() => {
						//
						// Do delayed actions
						//
						try {
							viewLoaded = true;
							foreach (var a in viewLoadedActions) {
								a();
							}
							viewLoadedActions.Clear();
						} catch (Exception ex) {
							Log.Error (ex);
						}
					});
				});
			} catch (Exception ex) {
				Log.Error (ex);				
			}

		}