Created
September 26, 2015 17:47
-
-
Save 0x5d/491fd8f020abc7c92199 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
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