Пример #1
0
        public App()
        {
            if (config == null)
            {
                config = new Configuration();
                IPlatformInfo platformInfo = DependencyService.Get <IPlatformInfo>();
                CrossLogger.Current.Info("Kala", "Model: " + platformInfo.GetModel());
                CrossLogger.Current.Info("Kala", "Version: " + platformInfo.GetVersion());

                CrossLogger.Current.Debug("Kala", @"URL Settings: '" + Settings.Protocol + "://" + Settings.Server + ":" + Settings.Port.ToString() + "'");
                CrossLogger.Current.Debug("Kala", @"Auth Settings: '" + Settings.Username + " / " + Settings.Password + "'");
                CrossLogger.Current.Debug("Kala", @"Sitemap Settings: '" + Settings.Sitemap + "'");
            }
            ;

            //Initialize FFImageLoading with Authentication
            FFImageLoading.AuthenticatedHttpImageClientHandler.Initialize();

            //TabbedPage setup
            if (tp.Children.Count == 0)
            {
                tp.BackgroundColor    = App.config.BackGroundColor;
                tp.BarBackgroundColor = App.config.BackGroundColor;
                tp.BarTextColor       = App.config.TextColor;

                tp.CurrentPageChanged += (sender, e) =>
                {
                    //Reset screensaver timer
                    App.config.LastActivity = DateTime.Now;
                    CrossLogger.Current.Debug("Kala", "Reset Screensaver timer");
                };

                /**/ //Show a busy signal here as we can't display anything until we have downloaded the sitemap with its items. No async. Pointless..
                sitemaps = Sitemap.GetActiveSitemap(Settings.Sitemap);

                //Selected sitemap was not found, display settings page to make change
                if (sitemaps == null)
                {
                    //Add settings tab
                    MainPage = new Views.Page1();
                }
                else
                {
                    Sitemap sitemap = new Sitemap();
                    sitemap.GetUpdates();
                    sitemap.CreateSitemap(sitemaps);
                    CrossLogger.Current.Debug("Kala", "Got Sitemaps");

                    //Add settings tab last
                    App.tp.Children.Add(new Views.Page1());
                    MainPage = App.tp;
                }
            }
            else
            {
                MainPage = App.tp;
            }
            App.config.Initialized = true;
        }
Пример #2
0
        public App()
        {
            if (Config == null)
            {
                Config = new Configuration();
                IPlatformInfo platformInfo = DependencyService.Get <IPlatformInfo>();
                CrossLogger.Current.Info("Kala", "Model: " + platformInfo.GetModel());
                CrossLogger.Current.Info("Kala", "Version: " + platformInfo.GetVersion());
                CrossLogger.Current.Info("Kala", "Wifi MAC address: " + platformInfo.GetWifiMacAddress());

                CrossLogger.Current.Debug("Kala", @"URL Settings: '" + Settings.Protocol + "://" + Settings.Server + ":" + Settings.Port.ToString() + "'");
                CrossLogger.Current.Debug("Kala", @"Auth Settings: '" + Settings.Username + " / " + Settings.Password + "'");
                CrossLogger.Current.Debug("Kala", @"Sitemap Settings: '" + Settings.Sitemap + "'");
            }

            //Initialize FFImageLoading with Authentication
            FFImageLoading.AuthenticatedHttpImageClientHandler.Initialize();

            //TabbedPage setup
            if (Tp.Children.Count == 0)
            {
                Tp.BackgroundColor    = Config.BackGroundColor;
                Tp.BarBackgroundColor = Config.BackGroundColor;
                Tp.BarTextColor       = Config.TextColor;

                Tp.CurrentPageChanged += (sender, e) =>
                {
                    //Reset screensaver timer
                    Config.LastActivity = DateTime.Now;
                    CrossLogger.Current.Debug("Kala", "Reset Screensaver timer");
                };

                //Auto configured sitemap?
                var WifiMac = DependencyService.Get <IPlatformInfo>().GetWifiMacAddress();
                Sitemaps = Sitemap.GetActiveSitemap(WifiMac);

                if (Sitemaps == null)
                {
                    Sitemaps = Sitemap.GetActiveSitemap(Settings.Sitemap);

                    //Selected sitemap was not found, display settings page to make change
                    if (Sitemaps == null)
                    {
                        //Add settings tab with Wifi Mac as default
                        Settings.Sitemap = WifiMac;
                        MainPage         = new Pages.Settings();
                    }
                }

                if (Sitemaps != null)
                {
                    Sitemap sitemap = new Sitemap();
                    sitemap.GetUpdates();
                    sitemap.CreateSitemap(Sitemaps);
                    CrossLogger.Current.Debug("Kala", "Got Sitemaps");

                    if (Config.Settings)
                    {
                        //Add settings tab last
                        Tp.Children.Add(new Pages.Settings());
                    }
                    MainPage = Tp;
                }
            }
            else
            {
                MainPage = Tp;
            }
            Config.Initialized = true;
        }