public class WeatherDefaultClient extends WeatherClient
WeatherClient.CityEventListener, WeatherClient.ClientBuilder, WeatherClient.ForecastWeatherEventListener, WeatherClient.GenericRequestWeatherEventListener<T>, WeatherClient.HistoricalWeatherEventListener, WeatherClient.HourForecastWeatherEventListener, WeatherClient.WeatherClientListener, WeatherClient.WeatherEventListener, WeatherClient.WeatherImageListener
cityListener, ctx, LOCATION_TIMEOUT, locListener, provider
Constructor and Description |
---|
WeatherDefaultClient() |
Modifier and Type | Method and Description |
---|---|
void |
getCurrentCondition(java.lang.String location,
WeatherClient.WeatherEventListener listener)
|
void |
getCurrentCondition(WeatherRequest wRequest,
WeatherClient.WeatherEventListener listener)
Get the current weather condition.
|
void |
getDefaultProviderImage(java.lang.String icon,
WeatherClient.WeatherImageListener listener)
This is the default image Provider that can be used to get the image provided by the Weather provider
|
void |
getForecastWeather(java.lang.String location,
WeatherClient.ForecastWeatherEventListener listener)
|
void |
getForecastWeather(WeatherRequest wRequest,
WeatherClient.ForecastWeatherEventListener listener)
Get the forecast weather condition.
|
void |
getHistoricalWeather(java.lang.String location,
java.util.Date d1,
java.util.Date d2,
WeatherClient.HistoricalWeatherEventListener listener)
|
void |
getHistoricalWeather(WeatherRequest wRequest,
java.util.Date d1,
java.util.Date d2,
WeatherClient.HistoricalWeatherEventListener listener)
Get the historical weather condition.
|
void |
getHourForecastWeather(java.lang.String location,
WeatherClient.HourForecastWeatherEventListener listener)
|
void |
getHourForecastWeather(WeatherRequest wRequest,
WeatherClient.HourForecastWeatherEventListener listener)
Get the forecast weather condition.
|
void |
getImage(java.lang.String url,
WeatherClient.WeatherImageListener listener)
Get an image at the specified URL and inform the listener when the image is ready
|
<T extends WeatherProviderFeature,S> |
getProviderWeatherFeature(WeatherRequest wRequest,
T extRequest,
GenericResponseParser<S> parser,
WeatherClient.GenericRequestWeatherEventListener<S> listener)
Get a specific weather provider feature not implemented in all weather provider
When the data is ready this method calls the onWeatherRetrieved passing the
HistoricalWeather weather information. |
void |
getWeatherImage(java.lang.String cityId,
Params params,
WeatherClient.WeatherImageListener listener)
This method retrieves the image using the url generated by the weahter provider
IWeatherProvider |
void |
searchCity(double lat,
double lon,
WeatherClient.CityEventListener listener)
Search the city using latitude and longitude.
|
void |
searchCity(java.lang.String pattern,
WeatherClient.CityEventListener listener)
Search the city using a name pattern.
|
void |
searchCityByLocation(Criteria criteria,
WeatherClient.CityEventListener listener)
Search the city using geographic coordinates.
|
protected void |
searchCityByLocation(Location location,
WeatherClient.CityEventListener listener) |
createDefaultCriteria, createProvider, handleLocation, init, setProvider, updateWeatherConfig
public void getCurrentCondition(java.lang.String location, WeatherClient.WeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.getCurrentCondition(com.survivingwithandroid.weather.lib.request.WeatherRequest, com.survivingwithandroid.weather.lib.WeatherClient.WeatherEventListener)
WeatherClient.WeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the current weather information. If there are some errors during the request parsing, it calls onWeatherError passing the exception or onConnectionError if the errors happened during the HTTP connection
getCurrentCondition
in class WeatherClient
location
- a String representing the location idlistener
- WeatherClient.WeatherEventListener
ApiKeyRequiredException
public void searchCity(java.lang.String pattern, WeatherClient.CityEventListener listener) throws ApiKeyRequiredException
WeatherClient.CityEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onCityListRetrieved passing a List
of cities.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
searchCity
in class WeatherClient
pattern
- a String representing the patternlistener
- WeatherClient.CityEventListener
ApiKeyRequiredException
public void searchCity(double lat, double lon, WeatherClient.CityEventListener listener) throws ApiKeyRequiredException
WeatherClient.CityEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onCityListRetrieved passing a List
of cities.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
searchCity
in class WeatherClient
lat
- a double representing the latitudelon
- a double representing the longitudelistener
- WeatherClient.CityEventListener
ApiKeyRequiredException
public void getForecastWeather(java.lang.String location, WeatherClient.ForecastWeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.getForecastWeather(com.survivingwithandroid.weather.lib.request.WeatherRequest, com.survivingwithandroid.weather.lib.WeatherClient.ForecastWeatherEventListener)
WeatherClient.ForecastWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the WeatherForecast
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getForecastWeather
in class WeatherClient
location
- a String representing the location idlistener
- WeatherClient.ForecastWeatherEventListener
ApiKeyRequiredException
public void getHourForecastWeather(java.lang.String location, WeatherClient.HourForecastWeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.getHourForecastWeather(com.survivingwithandroid.weather.lib.request.WeatherRequest, com.survivingwithandroid.weather.lib.WeatherClient.HourForecastWeatherEventListener)
WeatherClient.HourForecastWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the WeatherHourForecast
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getHourForecastWeather
in class WeatherClient
location
- a String representing the location idlistener
- WeatherClient.HourForecastWeatherEventListener
ApiKeyRequiredException
public void getHistoricalWeather(java.lang.String location, java.util.Date d1, java.util.Date d2, WeatherClient.HistoricalWeatherEventListener listener)
WeatherClient.getHistoricalWeather(com.survivingwithandroid.weather.lib.request.WeatherRequest, java.util.Date, java.util.Date, com.survivingwithandroid.weather.lib.WeatherClient.HistoricalWeatherEventListener)
WeatherClient.HistoricalWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the HistoricalWeather
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getHistoricalWeather
in class WeatherClient
location
- a String representing the location idd1
- is the starting dated2
- listener
- WeatherClient.HistoricalWeatherEventListener
@param2 d2 is the end dateApiKeyRequiredException
public void getDefaultProviderImage(java.lang.String icon, WeatherClient.WeatherImageListener listener)
getDefaultProviderImage
in class WeatherClient
icon
- String The icon containing the weather code to retrieve the imagelistener
- WeatherClient.WeatherImageListener
public void searchCityByLocation(Criteria criteria, WeatherClient.CityEventListener listener) throws LocationProviderNotFoundException
WeatherClient.CityEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onCityListRetrieved passing a List
of cities.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
searchCityByLocation
in class WeatherClient
criteria
- android.location.Criteria
listener
- WeatherClient.CityEventListener
ApiKeyRequiredException
LocationProviderNotFoundException
public void getWeatherImage(java.lang.String cityId, Params params, WeatherClient.WeatherImageListener listener)
IWeatherProvider
getWeatherImage
in class WeatherClient
cityId
- String representing the city idparams
- Params
: list of parameters used to create the imagelistener
- WeatherClient.WeatherImageListener
listener that gets notified when the image is ready to useprotected void searchCityByLocation(Location location, WeatherClient.CityEventListener listener) throws ApiKeyRequiredException
searchCityByLocation
in class WeatherClient
ApiKeyRequiredException
public void getCurrentCondition(WeatherRequest wRequest, WeatherClient.WeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.WeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the current weather information. If there are some errors during the request parsing, it calls onWeatherError passing the exception or onConnectionError if the errors happened during the HTTP connection
getCurrentCondition
in class WeatherClient
wRequest
- WeatherRequest
listener
- WeatherClient.WeatherEventListener
ApiKeyRequiredException
public void getForecastWeather(WeatherRequest wRequest, WeatherClient.ForecastWeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.ForecastWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the WeatherForecast
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getForecastWeather
in class WeatherClient
wRequest
- WeatherRequest
listener
- WeatherClient.ForecastWeatherEventListener
ApiKeyRequiredException
public void getHourForecastWeather(WeatherRequest wRequest, WeatherClient.HourForecastWeatherEventListener listener) throws ApiKeyRequiredException
WeatherClient.HourForecastWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the WeatherHourForecast
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getHourForecastWeather
in class WeatherClient
wRequest
- WeatherRequest
listener
- WeatherClient.HourForecastWeatherEventListener
ApiKeyRequiredException
public void getHistoricalWeather(WeatherRequest wRequest, java.util.Date d1, java.util.Date d2, WeatherClient.HistoricalWeatherEventListener listener)
WeatherClient.HistoricalWeatherEventListener
to
get notified when the weather data is ready.
When the data is ready this method calls the onWeatherRetrieved passing the HistoricalWeather
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getHistoricalWeather
in class WeatherClient
wRequest
- WeatherRequest
d1
- is the starting dated2
- listener
- WeatherClient.HistoricalWeatherEventListener
@param2 d2 is the end dateApiKeyRequiredException
public <T extends WeatherProviderFeature,S> void getProviderWeatherFeature(WeatherRequest wRequest, T extRequest, GenericResponseParser<S> parser, WeatherClient.GenericRequestWeatherEventListener<S> listener)
When the data is ready this method calls the onWeatherRetrieved passing the HistoricalWeather
weather information.
If there are some errors during the request parsing, it calls onWeatherError passing the exception or
onConnectionError if the errors happened during the HTTP connection
getProviderWeatherFeature
in class WeatherClient
wRequest
- WeatherRequest
extRequest
- is the extended request as required by the weather providerparser
- is the parser used to parsed the response GenericResponseParser
listener
- WeatherClient.GenericRequestWeatherEventListener
ApiKeyRequiredException
public void getImage(java.lang.String url, WeatherClient.WeatherImageListener listener)
getImage
in class WeatherClient
url
- String representing the urllistener
- WeatherClient.WeatherImageListener