public async void NavigateToAdd(string classification, string adId) { var vc = Window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } LoadingOverlay loadingIndicator = new LoadingOverlay(vc.View.Frame, "Loading ...", false); if (vc is MainTabBarController) { vc.View.AddSubview(loadingIndicator); //remove cache //Ad.DeleteAdsByClassification(classification); //Retrieve highlighted ad var adsByClassification = await Ad.GetAdsByClassificationAsync(classification); var highlightedAd = adsByClassification.Where(row => row.ID == adId).First(); var maintTabBarController = vc as MainTabBarController; var magNavVC = maintTabBarController.ViewControllers.FirstOrDefault(row => row is MagazineNavigationViewController); if (magNavVC != null) { maintTabBarController.SelectedIndex = 0; var chooseClassVC = (magNavVC as MagazineNavigationViewController).ViewControllers.FirstOrDefault(row => row is ChooseClassificationCollectionViewController); if (chooseClassVC != null) { var chooseClassificationViewController = chooseClassVC as ChooseClassificationCollectionViewController; var storyboard = UIStoryboard.FromName("Main_ipad", NSBundle.MainBundle); MagazineFlipBoardViewController flipboardVC = storyboard.InstantiateViewController("MagazineFlipBoardViewController") as MagazineFlipBoardViewController; flipboardVC.Title = classification; flipboardVC.SelectedClassification = classification; flipboardVC.NavigateDirectlyToAdId = adId; chooseClassificationViewController.NavigationController.PopToRootViewController(false); chooseClassificationViewController.ShowViewController(flipboardVC, this); } } } loadingIndicator.Hide(); }
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { var classification = classifications[(int)indexPath.Item]; LoadingOverlay loadingIndicator = new LoadingOverlay(this.View.Frame, "Loading Aircraft..."); this.View.AddSubview(loadingIndicator); //Clay Martin 1/1/18: Change app name to BuyPlane string magazineTitle = "GlobalAir.com BuyPlane (" + classification.Name + ")"; NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back to BuyPlane", UIBarButtonItemStyle.Plain, null); Task.Run(async() => { List <Ad> ads; if (!Settings.IsRegistered) { ads = (await Ad.GetAdsByClassificationAsync(classification.Name)).OrderByDescending(r => r.IsFeatured).ToList(); } else { IEnumerable <Ad> adListEnumerable = await Ad.GetAdsByClassificationAsync(classification.Name); switch (Settings.SortOptions) { case "No Preference": { ads = adListEnumerable.OrderByDescending(r => r.IsFeatured).ToList(); break; } case "Recently Updated": { ads = adListEnumerable.OrderByDescending(row => DateTime.Parse(row.LastUpdated)).ThenByDescending(r => r.IsFeatured).ToList(); break; } case "Price": { ads = adListEnumerable.OrderBy(row => row.Price == null || row.Price == string.Empty || row.Price == "N/A" ? 999999999 : double.Parse(row.Price, NumberStyles.Currency)).ThenByDescending(r => r.IsFeatured).ToList(); break; } case "Total Time": { ads = adListEnumerable.OrderBy(row => double.Parse(row.TotalTime)).ThenByDescending(r => r.IsFeatured).ToList(); break; } default: { ads = adListEnumerable.OrderByDescending(r => r.IsFeatured).ToList(); break; } } } var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; await appDelegate.PerformBackgroundDataFetchFromBuyplaneAPI(() => Console.WriteLine("Background Fetch for ads chosen from ChooseClassificationCollention complete"), ads); //AppDelegate.PerformBackgroundDataFetchFromBuyplaneAPI((obj) => Console.WriteLine("Background Fetch for ads chosen from ChooseClassificationCollention complete", ads); }).ContinueWith((task) => { InvokeOnMainThread(() => { loadingIndicator.Hide(); MagazineFlipBoardViewController flipboardVC = this.Storyboard.InstantiateViewController("MagazineFlipBoardViewController") as MagazineFlipBoardViewController; flipboardVC.Title = magazineTitle; flipboardVC.SelectedClassification = classification.Name; //flipboardVC.TabBarController.HidesBottomBarWhenPushed = true; this.ShowViewController(flipboardVC, this); //NavigationController.PushViewController(flipboardVC, true); }); }); }