Created
December 6, 2023 06:27
-
-
Save Axrorxoja/3697d6efcead852e6536905c7fad7a8a to your computer and use it in GitHub Desktop.
retrofit wrapper
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
import retrofit2.Retrofit; | |
import retrofit2.converter.gson.GsonConverterFactory; | |
public class RetrofitWrapper { | |
private Retrofit retrofit; | |
private String baseUrl; | |
public RetrofitWrapper(String baseUrl) { | |
this.baseUrl = baseUrl; | |
this.retrofit = new Retrofit.Builder() | |
.baseUrl(baseUrl) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); | |
} | |
public Retrofit getRetrofit() { | |
return retrofit; | |
} | |
public void recreateWithBaseUrl(String newBaseUrl) { | |
this.baseUrl = newBaseUrl; | |
this.retrofit = new Retrofit.Builder() | |
.baseUrl(newBaseUrl) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); | |
} | |
// Add other methods as needed, like for creating service interfaces | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment