Created
October 18, 2015 02:43
-
-
Save Sottti/fc2cfa8ff672d5cd2915 to your computer and use it in GitHub Desktop.
Retrofit set up
This file contains hidden or 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 ApiCalls | |
{ | |
public static Call<DummyObject> getDummyObjectCall() | |
{ | |
return ApiServices | |
.getDummyService() | |
.getDummyObject(); | |
} | |
public static Call<List<DummyObject>> getDummyObjectListCall() | |
{ | |
return ApiServices | |
.getDummyService() | |
.getDummyObjectList(); | |
} | |
} |
This file contains hidden or 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 ApiClients | |
{ | |
private static Retrofit mClient; | |
public static Retrofit getApiClient() | |
{ | |
if (mClient == null) | |
{ | |
mClient = new Retrofit | |
.Builder() | |
.baseUrl(BuildConfig.apiDomainName) | |
.addConverterFactory(MoshiConverterFactory.create()) | |
.build(); | |
} | |
return mClient; | |
} | |
} |
This file contains hidden or 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 ApiServices | |
{ | |
private static DummyService mDummyService; | |
public interface DummyService | |
{ | |
@GET("/v2/55973508b0e9e4a71a02f05f") | |
Call<DummyObject> getDummyObject(); | |
@GET ("/v2/5597d86a6344715505576725") | |
Call<List<DummyObject>> getDummyObjectList(); | |
} | |
public static DummyService getDummyService() | |
{ | |
if (mDummyService == null) | |
{ | |
mDummyService = ApiClients | |
.getApiClient() | |
.create(DummyService.class); | |
} | |
return mDummyService; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment