public override Result DoWork() { if (AwakeHelper.GetAwakeStatus() == AwakeStatus.Sleeping || AwakeHelper.GetAwakeStatus() == AwakeStatus.SleepingWithDeviceMotionEnabled) { return(Result.InvokeSuccess()); //We want to keep the job running but don't do the job itself while Awake is sleeping. } ConfigurationManager configurationManager = new ConfigurationManager(AppPreferences.Weather); string city = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCity, "New York"); string country = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCountryCode, "us"); string unit = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherTemperatureMeasureUnit, "metric"); var result = OpenWeatherMapClient.GetWeather(city, country, unit); if (result != null) { Log.Info("LiveDisplay", "Job Result Sucess"); WeatherUpdated?.Invoke(null, true); return(Result.InvokeSuccess()); } else { Log.Info("LiveDisplay", "Job Result Not Sucess"); WeatherUpdated?.Invoke(null, false); return(Result.InvokeRetry()); } }
protected override void OnResume() { base.OnResume(); AddFlags(); watchDog.Elapsed += WatchdogInterval_Elapsed; watchDog.Stop(); watchDog.Start(); ActivityLifecycleHelper.GetInstance().NotifyActivityStateChange(typeof(LockScreenActivity), ActivityStates.Resumed); if (configurationManager.RetrieveAValue(ConfigurationParameters.TutorialRead) == false) { welcome = FindViewById <TextView>(Resource.Id.welcomeoverlay); welcome.Text = Resources.GetString(Resource.String.tutorialtext); welcome.Visibility = ViewStates.Visible; welcome.Touch += Welcome_Touch; } //Check if Awake is enabled. //Refactor switch (AwakeHelper.GetAwakeStatus()) { case AwakeStatus.None: livedisplayinfo.Text = Resources.GetString(Resource.String.idk); break; case AwakeStatus.CompletelyDisabled: livedisplayinfo.Text = "Completely disabled"; break; case AwakeStatus.Up: livedisplayinfo.Text = "Awake is active"; break; case AwakeStatus.Sleeping: livedisplayinfo.Text = "Awake is Sleeping"; break; case AwakeStatus.UpWithDeviceMotionDisabled: livedisplayinfo.Text = "Awake is active but not listening orientation changes"; break; case AwakeStatus.SleepingWithDeviceMotionEnabled: livedisplayinfo.Text = "Awake is sleeping but listening orientation changes"; break; case AwakeStatus.DisabledbyUser: livedisplayinfo.Text = "Awake is disabled by the user."; break; default: break; } }