Created
March 26, 2015 16:10
-
-
Save manijshrestha/b18b120afe244dded9e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WeatherService { | |
private WeatherListener mListener; | |
public WeatherService(WeatherListener listener) { | |
this.mListener = listener; | |
} | |
public void getWeather(String cityName) { | |
RestAdapter adapter = new RestAdapter.Builder().setEndpoint("http://api.openweathermap.org").build(); | |
OpenWeatherService openWeatherService = adapter.create(OpenWeatherService.class); | |
openWeatherService.getWeatherData(cityName, "imperial", new Callback<WeatherData>() { | |
@Override | |
public void success(WeatherData weatherData, Response response) { | |
mListener.onWeatherData(weatherData); | |
} | |
@Override | |
public void failure(RetrofitError error) { | |
mListener.onNoWeatherData(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment