Skip to content

Instantly share code, notes, and snippets.

@0x5d
Created September 26, 2015 17:47
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 0x5d/491fd8f020abc7c92199 to your computer and use it in GitHub Desktop.
Save 0x5d/491fd8f020abc7c92199 to your computer and use it in GitHub Desktop.
package com.mycompany.myfirstapp.service;
import com.mycompany.myfirstapp.api.WeatherInfoApi;
import java.io.IOException;
import retrofit.Callback;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
public class WeatherInfoService {
private WeatherInfoApi weatherInfoApi;
public WeatherInfoService() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.openweathermap.org")
.addConverterFactory(GsonConverterFactory.create())
.build();
weatherInfoApi = retrofit.create(WeatherInfoApi.class);
}
public void getWeatherForName(String name, Callback callback) throws IOException {
weatherInfoApi.getWeatherForName(name).enqueue(callback);
}
public void getWeatherForCoords(double lat, double lon, Callback callback) throws IOException {
weatherInfoApi.getWeatherForCoords(lat, lon).enqueue(callback);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment