Exemplo n.º 1
0
        /// <summary>
        /// Sets up references to UI components, controls and settings.
        /// </summary>
        void SetupActivity()
        {
            try
            {
                txtInstance      = FindViewById <TextView>(Resource.Id.txtMobuInstance);
                txtServiceStatus = FindViewById <TextView>(Resource.Id.txtMobuWebStatus);
                linAppList       = FindViewById <LinearLayout>(Resource.Id.linAppList);
                linAppList.RemoveAllViewsInLayout();

                settingsControl = new SettingsControl();


                if (!settingsControl.SettingsProfilesExist() || !settingsControl.CurrentSettingsExist())
                {
                    settingsControl.GenerateDefaultSettings();
                }

                ProcessOldSettings();

                if (!settingsControl.CurrentSettingsExist())
                {
                    var profiles = settingsControl.GetSettingsProfiles();
                    settings = profiles.First();
                    settingsControl.SaveCurrentSettings(settings);
                }
                else
                {
                    settings = settingsControl.GetCurrentSettings();
                }

                webServiceControl = new WebServiceControl(settings);

                if (settings.IsTestInstance)
                {
                    txtInstance.SetBackgroundResource(Resource.Drawable.ContainerBackgroundRed);
                    txtInstance.Text = "Instance: Test";
                }
                else
                {
                    txtInstance.SetBackgroundResource(Resource.Drawable.ContainerBackground);
                    txtInstance.Text = "Instance: Production";
                }

                busy = false;
                serviceIsReachable = false;
                serviceStatus      = "Status: Waiting";
                statusIndicator    = ".";
                packages           = new List <PackageDetails>();

                RunUiIndicator();
                RunUpdateServiceStatus();
                RunUpdateStatus();
                RunAutomaticRefresh();

                AccuirePermissions();
            }
            catch (Exception e)
            {
                Log.Info("MobuAndroid", "Error while setting up main activity.", e.Message);
                FinishAndRemoveTask();
            }
        }