aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
diff options
context:
space:
mode:
authorNicolai Ehemann <en@enlightened.de>2013-09-27 11:18:44 +0200
committerDvTonder <david.vantonder@gmail.com>2013-09-29 07:35:16 -0400
commit568f7b8152871a5874bc4d780fdf0b84d7c5b1c5 (patch)
tree90b22bcd83a174af1c3fc3c5b228718d7f932997 /src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
parentea94f1a1c9e081a09d75b1e6a71767aa48f41657 (diff)
downloadandroid_packages_apps_LockClock-568f7b8152871a5874bc4d780fdf0b84d7c5b1c5.tar.gz
android_packages_apps_LockClock-568f7b8152871a5874bc4d780fdf0b84d7c5b1c5.tar.bz2
android_packages_apps_LockClock-568f7b8152871a5874bc4d780fdf0b84d7c5b1c5.zip
cLock: update weather info when gps is disabled (using cached location)
Change-Id: If073a583cdc824ecace5595f0766dd20d8368a1b
Diffstat (limited to 'src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java')
-rwxr-xr-xsrc/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
index fced9fd..720d904 100755
--- a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
+++ b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
@@ -168,6 +168,13 @@ public class WeatherUpdateService extends Service {
return location;
}
+ private String getCachedLocation() {
+ WeatherInfo weatherInfo = Preferences.getCachedWeatherInfo(mContext);
+ String location = (weatherInfo != null) ? weatherInfo.getCity() : null;
+ if (D) Log.v(TAG, "Last known, cached location is " + location);
+ return location;
+ }
+
private Document getDocument(String woeid) {
boolean celcius = Preferences.useMetricUnits(mContext);
String urlWithUnit = URL_YAHOO_API_WEATHER + (celcius ? "c" : "f");
@@ -196,6 +203,11 @@ public class WeatherUpdateService extends Service {
if (location != null) {
woeid = getWoeidForCurrentLocation(location);
} else {
+ // work with cached location from last request for now
+ customLocation = getCachedLocation();
+ if (customLocation != null) {
+ woeid = getWoeidForCustomLocation(customLocation);
+ }
// If lastKnownLocation is not present because none of the apps in the
// device has requested the current location to the system yet,
// then try to get the current location use an non-accuracy/network provider.