public void Load()
        {
            Task.Factory.StartNew(async() => {
                IoCManager.RegisterType <IDataAccess, RealmDataAccess>();
                IoCManager.RegisterType <IDataLoader, EmbeddedResourceDataLoader>();
                IoCManager.RegisterInstance(typeof(ApplicationResourcesProvider), new ApplicationResourcesProvider(Application.Current.Resources));

                IoCManager.RegisterInstance(typeof(INearbyExhibitManager), new NearbyExhibitManager());
                IoCManager.RegisterInstance(typeof(INearbyRouteManager), new NearbyRouteManager());

                // show text, progress bar and image when db is initialized, otherwise just the indicator is shown
                if (!DbManager.IsDatabaseUpToDate())
                {
                    IsExtendedViewsVisible = true;
                }
                DbManager.UpdateDatabase(this);

                // force the db to load the exhibitset into cache
                ExhibitManager.GetExhibitSets();
                LoadingProgress = 0.9;
                await Task.Delay(100);

                // if the app is not sleeping open the main menu, otherwise wait for it to wake up
                startupAction = async() => {
                    var vm          = new MainPageViewModel();
                    LoadingProgress = 1;
                    await Task.Delay(100);

                    MessagingCenter.Unsubscribe <App> (this, AppSharedData.WillSleepMessage);
                    MessagingCenter.Unsubscribe <App> (this, AppSharedData.WillWakeUpMessage);
                    Navigation.StartNewNavigationStack(vm);
                };
                if (!isSleeping)
                {
                    Device.BeginInvokeOnMainThread(startupAction);
                }
            });
        }
 public MainPageViewModel() : this(ExhibitManager.GetExhibitSets().FirstOrDefault())
 {
 }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //it crashes on versions below 21
            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            }

            // Check if we have the necessary permissions and request them if we don't
            // Note that the app will still fail on first launch and needs to be restarted
            SetUpPermissions();

            InitializeExtendedLocationListener();


            geoLocation = new GeoLocation
            {
                Latitude  = extendedLocationListener.Latitude,
                Longitude = extendedLocationListener.Longitude
            };

            exhibitSet = ExhibitManager.GetExhibitSets().First();

            //Permissions
            SetUpPermissions();

            // Navigation Drawer
            SetUpNavigationDrawer();

            //FeedbackManager.Register(this);
            FeedbackManager.Register(this, KeyManager.Instance.GetKey("hockeyapp.android"), new HipFeedbackListener());

            if (savedInstanceState == null)
            {
                // Set overview fragment
                exhibitsOverviewFragment = new ExhibitsOverviewFragment
                {
                    ExhibitSet  = exhibitSet,
                    GeoLocation = geoLocation
                };

                if (FindViewById(Resource.Id.main_fragment_container) != null)
                {
                    var transaction = SupportFragmentManager.BeginTransaction();
                    transaction.Replace(Resource.Id.main_fragment_container, exhibitsOverviewFragment);
                    transaction.Commit();
                }
            }
            else
            {
                askForUpdates            = savedInstanceState.GetBoolean(UpdateKey);
                exhibitsOverviewFragment = (ExhibitsOverviewFragment)SupportFragmentManager.GetFragment(savedInstanceState, ExhibitsOverviewFragString);
            }


            // hockeyapp code
            if (askForUpdates)
            {
                CheckForUpdates();
            }
        }