aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorToha <tohenk@yahoo.com>2014-06-07 17:03:51 +0700
committerToha <tohenk@yahoo.com>2014-06-07 17:03:51 +0700
commit38b27f853154d892e44cd262314c5d80d7fe4ce8 (patch)
tree88cc7f92b58c81c79e87e2ed87ff73b0602959f5 /src
parent34220d3053c5a49c324e1fa4f810181b9d409fb9 (diff)
downloadandroid_packages_apps_LockClock-38b27f853154d892e44cd262314c5d80d7fe4ce8.tar.gz
android_packages_apps_LockClock-38b27f853154d892e44cd262314c5d80d7fe4ce8.tar.bz2
android_packages_apps_LockClock-38b27f853154d892e44cd262314c5d80d7fe4ce8.zip
Fix Yahoo placefinder api call.
Some location query returns both empty city and neighborhood, use county instead. Change-Id: I71bae6236f0ae458c40567f681b0783e86030ff0
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/cyanogenmod/lockclock/ClockWidgetService.java2
-rw-r--r--src/com/cyanogenmod/lockclock/weather/YahooWeatherProvider.java22
2 files changed, 19 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/lockclock/ClockWidgetService.java b/src/com/cyanogenmod/lockclock/ClockWidgetService.java
index ea5da49..31a7837 100755
--- a/src/com/cyanogenmod/lockclock/ClockWidgetService.java
+++ b/src/com/cyanogenmod/lockclock/ClockWidgetService.java
@@ -120,7 +120,7 @@ public class ClockWidgetService extends IntentService {
int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
}
- if (D) Log.d("TAG", "For Widget id " + id + " isKeyguard is set to " + isKeyguard);
+ if (D) Log.d(TAG, "For Widget id " + id + " isKeyguard is set to " + isKeyguard);
// Determine which layout to use
boolean smallWidget = showWeather && showWeatherWhenMinimized
diff --git a/src/com/cyanogenmod/lockclock/weather/YahooWeatherProvider.java b/src/com/cyanogenmod/lockclock/weather/YahooWeatherProvider.java
index 5abe35d..7e4b66d 100644
--- a/src/com/cyanogenmod/lockclock/weather/YahooWeatherProvider.java
+++ b/src/com/cyanogenmod/lockclock/weather/YahooWeatherProvider.java
@@ -57,11 +57,15 @@ public class YahooWeatherProvider implements WeatherProvider {
"or placetype = 10 or placetype = 11 or placetype = 20) and text =");
private static final String URL_PLACEFINDER =
"http://query.yahooapis.com/v1/public/yql?format=json&q=" +
- Uri.encode("select woeid, city from geo.placefinder where gflags=\"R\" and text =");
+ Uri.encode("select woeid, city, neighborhood, county from geo.placefinder where " +
+ "gflags=\"R\" and text =");
private static final String[] LOCALITY_NAMES = new String[] {
"locality1", "locality2", "admin3", "admin2", "admin1"
};
+ private static final String[] PLACE_NAMES = new String[] {
+ "city", "neigborhood", "county"
+ };
private Context mContext;
@@ -219,15 +223,25 @@ public class YahooWeatherProvider implements WeatherProvider {
try {
JSONObject result = results.getJSONObject("Result");
String woeid = result.getString("woeid");
- String city = result.getString("city");
- if (city == null) {
- city = result.getString("neighborhood");
+ String city = null;
+ for (String name : PLACE_NAMES) {
+ if (!result.isNull(name)) {
+ city = result.getString(name);
+ if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ Log.v(TAG, String.format(Locale.US, "Placefinder for location %f %f " +
+ "matched %s using %s", location.getLatitude(),
+ location.getLongitude(), city, name));
+ }
+ break;
+ }
}
// The city name in the placefinder result is HTML encoded :-(
if (city != null) {
city = Html.fromHtml(city).toString();
+ } else {
+ Log.w(TAG, "Can not resolve place name for " + location);
}
Log.d(TAG, "Resolved location " + location + " to " + city + " (" + woeid + ")");