diff options
Diffstat (limited to 'sdk/src/java/cyanogenmod/weather/CMWeatherManager.java')
-rw-r--r-- | sdk/src/java/cyanogenmod/weather/CMWeatherManager.java | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java index 545c3ce..8292b58 100644 --- a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java +++ b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java @@ -53,40 +53,32 @@ public class CMWeatherManager { private static final String TAG = CMWeatherManager.class.getSimpleName(); - /** - * Weather update request state: Successfully completed - */ - public static final int WEATHER_REQUEST_COMPLETED = 1; - - /** - * Weather update request state: You need to wait a bit longer before requesting an update - * again. - * <p>Please bear in mind that the weather does not change very often. A threshold of 10 minutes - * is enforced by the system</p> - */ - public static final int WEATHER_REQUEST_SUBMITTED_TOO_SOON = -1; - - /** - * Weather update request state: An error occurred while trying to update the weather. You - * should wait before trying again, or your request will be rejected with - * {@link #WEATHER_REQUEST_SUBMITTED_TOO_SOON} - */ - public static final int WEATHER_REQUEST_FAILED = -2; /** - * Weather update request state: Only one update request can be processed at a given time. + * The different request statuses */ - public static final int WEATHER_REQUEST_ALREADY_IN_PROGRESS = -3; - - /** @hide */ - public static final int LOOKUP_REQUEST_COMPLETED = 100; - - /** @hide */ - public static final int LOOKUP_REQUEST_FAILED = -100; - - /** @hide */ - public static final int LOOKUP_REQUEST_NO_MATCH_FOUND = -101; - + public static class RequestStatus { + /** + * Request Successfully completed + */ + public static final int COMPLETED = 1; + /** + * An error occurred while trying to honor the request. + */ + public static final int FAILED = -1; + /** + * The request can't be processed at this time + */ + public static final int SUBMITTED_TOO_SOON = -2; + /** + * Another request in already in progress + */ + public static final int ALREADY_IN_PROGRESS = -3; + /** + * No match found for the query + */ + public static final int NO_MATCH_FOUND = -4; + } private CMWeatherManager(Context context) { Context appContext = context.getApplicationContext(); @@ -330,7 +322,7 @@ public class CMWeatherManager { private final IRequestInfoListener mRequestInfoListener = new IRequestInfoListener.Stub() { @Override - public void onWeatherRequestCompleted(final RequestInfo requestInfo, final int state, + public void onWeatherRequestCompleted(final RequestInfo requestInfo, final int status, final WeatherInfo weatherInfo) { final WeatherUpdateRequestListener listener = mWeatherUpdateRequestListeners.remove(requestInfo); @@ -338,14 +330,14 @@ public class CMWeatherManager { mHandler.post(new Runnable() { @Override public void run() { - listener.onWeatherRequestCompleted(state, weatherInfo); + listener.onWeatherRequestCompleted(status, weatherInfo); } }); } } @Override - public void onLookupCityRequestCompleted(RequestInfo requestInfo, + public void onLookupCityRequestCompleted(RequestInfo requestInfo, final int status, final List<WeatherLocation> weatherLocations) { final LookupCityRequestListener listener @@ -354,7 +346,7 @@ public class CMWeatherManager { mHandler.post(new Runnable() { @Override public void run() { - listener.onLookupCityRequestCompleted(weatherLocations); + listener.onLookupCityRequestCompleted(status, weatherLocations); } }); } @@ -369,16 +361,12 @@ public class CMWeatherManager { * This method will be called when the weather service provider has finished processing the * request * - * @param state Any of the following values - * {@link #WEATHER_REQUEST_COMPLETED} - * {@link #WEATHER_REQUEST_ALREADY_IN_PROGRESS} - * {@link #WEATHER_REQUEST_SUBMITTED_TOO_SOON} - * {@link #WEATHER_REQUEST_FAILED} + * @param status See {@link RequestStatus} * * @param weatherInfo A fully populated {@link WeatherInfo} if state is - * {@link #WEATHER_REQUEST_COMPLETED}, null otherwise + * {@link RequestStatus#COMPLETED}, null otherwise */ - void onWeatherRequestCompleted(int state, WeatherInfo weatherInfo); + void onWeatherRequestCompleted(int status, WeatherInfo weatherInfo); } /** @@ -387,11 +375,14 @@ public class CMWeatherManager { public interface LookupCityRequestListener { /** * This method will be called when the weather service provider has finished processing the - * request. The argument can be null if the provider couldn't find a match + * request. + * + * @param status See {@link RequestStatus} * - * @param locations + * @param locations A list of {@link WeatherLocation} if the status is + * {@link RequestStatus#COMPLETED}, null otherwise */ - void onLookupCityRequestCompleted(List<WeatherLocation> locations); + void onLookupCityRequestCompleted(int status, List<WeatherLocation> locations); } /** |