Skip to content

Instantly share code, notes, and snippets.

@juanxodj
Created October 19, 2016 05:23
Show Gist options
  • Save juanxodj/a9816924a730dad72703294f45fad7b2 to your computer and use it in GitHub Desktop.
Save juanxodj/a9816924a730dad72703294f45fad7b2 to your computer and use it in GitHub Desktop.
package com.lctics.retrofit2.dataPokemon.remote;
import com.lctics.retrofit2.dataPokemon.model.PokemonFeed;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;
public interface PokemonAPI {
String BASE_URL = "http://pokeapi.co/api/v1/";
@GET("pokemon/" + pokemonID + "/")
Call<PokemonFeed> getPokemon();
class Factory{
private static PokemonAPI service;
public static PokemonAPI getInstance(){
if(service == null){
Retrofit retrofit = new Retrofit.Builder().addConverterFactory(GsonConverterFactory.create()).baseUrl(BASE_URL).build();
service = retrofit.create(PokemonAPI.class);
return service;
} else{
return service;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment