aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java
diff options
context:
space:
mode:
authorLuis Vidal <lvidal@cyngn.com>2016-04-06 15:39:49 -0700
committerLuis Vidal <lvidal@cyngn.com>2016-04-07 22:42:43 -0700
commit343245f4e6331b1059240150e62e0c9a9d8d3a54 (patch)
tree2a8901d3268646f2576033895e95be7a7aed4410 /sdk/src/java/cyanogenmod/weather/CMWeatherManager.java
parent2eddb5f7c706d37004e06ecd5c39d0f3ab724f55 (diff)
downloadvendor_cmsdk-343245f4e6331b1059240150e62e0c9a9d8d3a54.zip
vendor_cmsdk-343245f4e6331b1059240150e62e0c9a9d8d3a54.tar.gz
vendor_cmsdk-343245f4e6331b1059240150e62e0c9a9d8d3a54.tar.bz2
Add API to cancel an active weather request
Add new API cancelRequest to CMWeatherManager. This will allow clients to cancel a request that was previuosly submitted to the weather service. As part of this change, requestWeatherUpdate(weatherLocation), requestWeatherUpdate(Location) and lookupCity(cityName) will now return the RequestInfo object created if the request was successfully submitted to the weather manager service TICKET: CYNGNOS-2383 TICKET: CYNGNOS-2385 Change-Id: Ic122f91e0ea8a24d81dbed48741ef1e33567b56c
Diffstat (limited to 'sdk/src/java/cyanogenmod/weather/CMWeatherManager.java')
-rw-r--r--sdk/src/java/cyanogenmod/weather/CMWeatherManager.java45
1 files changed, 39 insertions, 6 deletions
diff --git a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java
index 32eab52..3ab510e 100644
--- a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java
+++ b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java
@@ -131,11 +131,14 @@ public class CMWeatherManager {
* @param listener {@link WeatherUpdateRequestListener} To be notified once the active weather
* service provider has finished
* processing your request
+ * @return A {@link RequestInfo} identifying the request submitted to the weather service.
+ * Note that this method might return null if an error occurred while trying to submit
+ * the request.
*/
- public void requestWeatherUpdate(@NonNull Location location,
+ public RequestInfo requestWeatherUpdate(@NonNull Location location,
@NonNull WeatherUpdateRequestListener listener) {
if (sWeatherManagerService == null) {
- return;
+ return null;
}
try {
@@ -145,7 +148,9 @@ public class CMWeatherManager {
.build();
if (listener != null) mWeatherUpdateRequestListeners.put(info, listener);
sWeatherManagerService.updateWeather(info);
+ return info;
} catch (RemoteException e) {
+ return null;
}
}
@@ -159,11 +164,14 @@ public class CMWeatherManager {
* @param listener {@link WeatherUpdateRequestListener} To be notified once the active weather
* service provider has finished
* processing your request
+ * @return A {@link RequestInfo} identifying the request submitted to the weather service.
+ * Note that this method might return null if an error occurred while trying to submit
+ * the request.
*/
- public void requestWeatherUpdate(@NonNull WeatherLocation weatherLocation,
+ public RequestInfo requestWeatherUpdate(@NonNull WeatherLocation weatherLocation,
@NonNull WeatherUpdateRequestListener listener) {
if (sWeatherManagerService == null) {
- return;
+ return null;
}
try {
@@ -173,7 +181,9 @@ public class CMWeatherManager {
.build();
if (listener != null) mWeatherUpdateRequestListeners.put(info, listener);
sWeatherManagerService.updateWeather(info);
+ return info;
} catch (RemoteException e) {
+ return null;
}
}
@@ -185,10 +195,13 @@ public class CMWeatherManager {
* completed. Upon success, a list of
* {@link cyanogenmod.weather.WeatherLocation}
* will be provided
+ * @return A {@link RequestInfo} identifying the request submitted to the weather service.
+ * Note that this method might return null if an error occurred while trying to submit
+ * the request.
*/
- public void lookupCity(@NonNull String city, @NonNull LookupCityRequestListener listener) {
+ public RequestInfo lookupCity(@NonNull String city, @NonNull LookupCityRequestListener listener) {
if (sWeatherManagerService == null) {
- return;
+ return null;
}
try {
RequestInfo info = new RequestInfo
@@ -197,7 +210,27 @@ public class CMWeatherManager {
.build();
if (listener != null) mLookupNameRequestListeners.put(info, listener);
sWeatherManagerService.lookupCity(info);
+ return info;
} catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Cancels a request that was previously submitted to the weather service.
+ * @param info The {@link RequestInfo} that you received when the request was submitted
+ */
+ public void cancelRequest(RequestInfo info) {
+ if (sWeatherManagerService == null) {
+ return;
+ }
+ if (info == null) {
+ return;
+ }
+
+ try {
+ sWeatherManagerService.cancelRequest(info);
+ }catch (RemoteException e){
}
}