public class WeatherClientDefault extends WeatherClient
Usually you need only one instance of this class in your app so that the class implements the Singleton pattern To get the reference to this class you have to use getInstance method:
WeatherClient client = WeatherClient.getInstance();
soon after you the the reference and before you make any requests you have to pass the Context
to this class.
WeatherClient.CityEventListener, WeatherClient.ClientBuilder, WeatherClient.ForecastWeatherEventListener, WeatherClient.GenericRequestWeatherEventListener<T>, WeatherClient.HistoricalWeatherEventListener, WeatherClient.HourForecastWeatherEventListener, WeatherClient.WeatherClientListener, WeatherClient.WeatherEventListener, WeatherClient.WeatherImageListenerctx, LOCATION_TIMEOUT, locListener, provider| Constructor and Description |
|---|
WeatherClientDefault() |
| 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 startDate,
java.util.Date endDate,
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
|
static WeatherClientDefault |
getInstance()
Deprecated.
Release 1.4 repleaced by
WeatherClient.ClientBuilder |
<T extends WeatherProviderFeature,S> |
getProviderWeatherFeature(WeatherRequest request,
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 |
init(Context ctx)
This method has to be called before any HTTP request
|
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) |
protected void |
searchCityByLocation(Location location,
WeatherClient.CityEventListener listener) |
void |
setProvider(IWeatherProvider provider)
This method is used to set the Weather provider.
|
void |
updateWeatherConfig(WeatherConfig config)
This method update the current provider configuration
|
createDefaultCriteria, createProvider, handleLocationpublic static WeatherClientDefault getInstance()
WeatherClient.ClientBuilderpublic void init(Context ctx)
WeatherClientinit in class WeatherClientctx - Reference to the Contextpublic void updateWeatherConfig(WeatherConfig config)
updateWeatherConfig in class WeatherClientconfig - WeatherConfig infoWeatherConfigpublic 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 WeatherClientlocation - a String representing the location idlistener - WeatherClient.WeatherEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientpattern - a String representing the patternlistener - WeatherClient.CityEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientlat - a double representing the latitudelon - a double representing the longitudelistener - WeatherClient.CityEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientlocation - a String representing the location idlistener - WeatherClient.ForecastWeatherEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientlocation - a String representing the location idlistener - WeatherClient.HourForecastWeatherEventListenerApiKeyRequiredExceptionpublic void getHistoricalWeather(java.lang.String location,
java.util.Date startDate,
java.util.Date endDate,
WeatherClient.HistoricalWeatherEventListener listener)
throws ApiKeyRequiredException
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 WeatherClientlocation - a String representing the location idlistener - WeatherClient.HistoricalWeatherEventListenerstartDate - is the starting dateendDate - is the end dateApiKeyRequiredExceptionpublic void getDefaultProviderImage(java.lang.String icon,
WeatherClient.WeatherImageListener listener)
getDefaultProviderImage in class WeatherClienticon - String The icon containing the weather code to retrieve the imagelistener - WeatherClient.WeatherImageListenerpublic void searchCityByLocation(Criteria criteria,
WeatherClient.CityEventListener listener)
throws LocationProviderNotFoundException
searchCityByLocation in class WeatherClientLocationProviderNotFoundExceptionpublic void setProvider(IWeatherProvider provider)
IWeatherProvider
interface. This method has to be called before making any HTTP request otherwise the client doesn't know how
to parse the requestsetProvider in class WeatherClientprovider - IWeatherProvidercom.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider},
com.survivingwithandroid.weather.lib.provider.yahooweather.YahooWeatherProvider}public void getWeatherImage(java.lang.String cityId,
Params params,
WeatherClient.WeatherImageListener listener)
IWeatherProvidergetWeatherImage in class WeatherClientcityId - 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 WeatherClientApiKeyRequiredExceptionpublic 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 WeatherClientwRequest - WeatherRequestlistener - WeatherClient.WeatherEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientwRequest - WeatherRequestlistener - WeatherClient.ForecastWeatherEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientwRequest - WeatherRequestlistener - WeatherClient.HourForecastWeatherEventListenerApiKeyRequiredExceptionpublic 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 WeatherClientwRequest - WeatherRequestd1 - is the starting dated2 - listener - WeatherClient.HistoricalWeatherEventListener @param2 d2 is the end dateApiKeyRequiredExceptionpublic <T extends WeatherProviderFeature,S> void getProviderWeatherFeature(WeatherRequest request, 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 WeatherClientrequest - WeatherRequestextRequest - is the extended request as required by the weather providerparser - is the parser used to parsed the response GenericResponseParserlistener - WeatherClient.GenericRequestWeatherEventListenerApiKeyRequiredExceptionpublic void getImage(java.lang.String url,
WeatherClient.WeatherImageListener listener)
getImage in class WeatherClienturl - String representing the urllistener - WeatherClient.WeatherImageListener