Skip to content

Instantly share code, notes, and snippets.

@manijshrestha
Created March 26, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manijshrestha/b18b120afe244dded9e4 to your computer and use it in GitHub Desktop.
Save manijshrestha/b18b120afe244dded9e4 to your computer and use it in GitHub Desktop.
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