protected void OnWillRotate(NSNotification notification) { if (!IsViewLoaded) { return; } if (notification == null) { return; } var o1 = notification.UserInfo.ValueForKey(new NSString("UIApplicationStatusBarOrientationUserInfoKey")); int o2 = Convert.ToInt32(o1.ToString()); UIInterfaceOrientation toOrientation = (UIInterfaceOrientation)o2; var notModal = !(TabBarController.ModalViewController == null); var isSelectedTab = (TabBarController.SelectedViewController == this); //ConsoleD.WriteLine ("toOrientation:"+toOrientation); //ConsoleD.WriteLine ("isSelectedTab:"+isSelectedTab); var duration = UIApplication.SharedApplication.StatusBarOrientationAnimationDuration; if (!isSelectedTab || !notModal) { base.WillRotate(toOrientation, duration); UIViewController master = ViewControllers[0]; var theDelegate = Delegate; //YOU_DONT_FEEL_QUEAZY_ABOUT_THIS_BECAUSE_IT_PASSES_THE_APP_STORE UIBarButtonItem button = base.ValueForKey(new NSString("_barButtonItem")) as UIBarButtonItem; if (toOrientation == UIInterfaceOrientation.Portrait || toOrientation == UIInterfaceOrientation.PortraitUpsideDown) { if (theDelegate != null && ((NSObject)theDelegate).RespondsToSelector(new Selector("splitViewController:willHideViewController:withBarButtonItem:forPopoverController:"))) { try { UIPopoverController popover = base.ValueForKey(new NSString("_hiddenPopoverController")) as UIPopoverController; theDelegate.WillHideViewController(this, master, button, popover); } catch (Exception e) { ConsoleD.WriteLine("There was a nasty error while notifyng splitviewcontrollers of a portrait orientation change: " + e.Message); } } } else { if (theDelegate != null && ((NSObject)theDelegate).RespondsToSelector(new Selector("splitViewController:willShowViewController:invalidatingBarButtonItem:"))) { try { theDelegate.WillShowViewController(this, master, button); } catch (Exception e) { ConsoleD.WriteLine("There was a nasty error while notifyng splitviewcontrollers of a landscape orientation change: " + e.Message); } } } } }
public override void RowSelected(UITableView tableView, Foundation.NSIndexPath indexPath) { var session = sessions[indexPath.Row]; ConsoleD.WriteLine("SessionsTableSource.RowSelected"); view.SelectSession(session); if (AppDelegate.IsPhone) { tableView.DeselectRow(indexPath, true); } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); BL.Managers.UpdateManager.UpdateFinished += HandleFinishedUpdate; //NOTE: this is a quick response to Apple's disapproval of the sqlite living in the /Documents/ folder // in the previous versions of the app. A quick way to preserve the favorites when the sqlite is moved // to /Library/ //HACK: not a good idea in the FinishedLaunching method, but it will do for now... //HACK: we need to do this before triggering the static ctor on MwcDatabase! var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string oldDBLocation = Path.Combine(docsPath, "MwcDB.db3"); // in Document string newDBLocation = oldDBLocation.Replace("Documents/MwcDB.db3", "Library/MwcDB.db3"); try { ConsoleD.WriteLine("oldDbLocation=" + oldDBLocation); if (File.Exists(oldDBLocation)) // won't normally be there in new installs { File.Delete(newDBLocation); // static ctor will have created it File.Move(oldDBLocation, newDBLocation); ConsoleD.WriteLine("Moved " + oldDBLocation + " to " + newDBLocation); } else { ConsoleD.WriteLine("oldDBLocation didn't exist?"); } } catch (Exception ex) { ConsoleD.WriteLine("Well, we tried! Couldn't save the old favorites..." + ex.Message); File.Delete(oldDBLocation); } // start updating all data in the background // by calling this asynchronously, we must check to see if it's finished // everytime we want to use/display data. new Thread(new ThreadStart(() => { var prefs = NSUserDefaults.StandardUserDefaults; bool hasSeedData = BL.Managers.UpdateManager.HasDataAlready; ConsoleD.WriteLine("hasSeedData=" + hasSeedData); if (!hasSeedData) { // only happens when the database is empty (or wasn't there); use local file update ConsoleD.WriteLine("Load seed data"); var appdir = NSBundle.MainBundle.ResourcePath; var seedDataFile = appdir + "/Images/SeedData.xml"; string xml = System.IO.File.ReadAllText(seedDataFile); BL.Managers.UpdateManager.UpdateFromFile(xml); ConsoleD.WriteLine("Database lives at: " + MWC.DL.MwcDatabase.DatabaseFilePath); // We SHOULDN'T skip backup because we are saving the Favorites in the same sqlite // database as the sessions are stored. A more iCloud-friendly design would be // to keep the user-data separate from the server-generated data... NSFileManager.SetSkipBackupAttribute(MWC.DL.MwcDatabase.DatabaseFilePath, true); } else { // if there's already data in the database, do/attempt server update //ConsoleD.WriteLine("SkipBackup: "+NSFileManager.GetSkipBackupAttribute (MWC.DL.MwcDatabase.DatabaseFilePath)); var earliestUpdateString = prefs.StringForKey(PrefsEarliestUpdate); DateTime earliestUpdateTime = DateTime.MinValue; if (!String.IsNullOrEmpty(earliestUpdateString)) { CultureInfo provider = CultureInfo.InvariantCulture; if (DateTime.TryParse(earliestUpdateString , provider , System.Globalization.DateTimeStyles.None , out earliestUpdateTime)) { ConsoleD.WriteLine("Earliest update time: " + earliestUpdateTime); } } if (earliestUpdateTime < DateTime.Now) { // we're past the earliest update time, so update! if (Reachability.IsHostReachable(Constants.ConferenceDataBaseUrl)) { ConsoleD.WriteLine("Reachability okay, update conference from server"); BL.Managers.UpdateManager.UpdateConference(); } else { // no network ConsoleD.WriteLine("No network, can't update data for now"); } } else { ConsoleD.WriteLine("Too soon to update " + DateTime.Now); } } })).Start(); tabBar = new Screens.Common.TabBarController(); // couldn't do RespondsToSelector() on static 'Appearance' property) var majorVersionString = UIDevice.CurrentDevice.SystemVersion.Substring(0, 1); var majorVersion = Convert.ToInt16(majorVersionString); if (majorVersion >= 5) // gotta love Appearance in iOS5 { UINavigationBar.Appearance.TintColor = ColorNavBarTint; } window.RootViewController = tabBar; window.MakeKeyAndVisible(); return(true); }
/// <summary> /// When we receive a memory warning, clear the MT.D image cache /// </summary> public override void ReceiveMemoryWarning(UIApplication application) { ConsoleD.WriteLine("==== Received Memory Warning ===="); MonoTouch.Dialog.Utilities.ImageLoader.Purge(); }