mirror of
https://github.com/vernu/textbee.git
synced 2026-05-18 21:35:12 -04:00
chore(android): create an ApiManager class
This commit is contained in:
33
android/app/src/main/java/com/vernu/sms/ApiManager.java
Normal file
33
android/app/src/main/java/com/vernu/sms/ApiManager.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.vernu.sms;
|
||||
|
||||
import com.vernu.sms.services.GatewayApiService;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class ApiManager {
|
||||
private static GatewayApiService apiService;
|
||||
|
||||
public static GatewayApiService getApiService() {
|
||||
if (apiService == null) {
|
||||
apiService = createApiService();
|
||||
}
|
||||
return apiService;
|
||||
}
|
||||
|
||||
private static GatewayApiService createApiService() {
|
||||
// OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
// HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
// loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
// httpClient.addInterceptor(loggingInterceptor);
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(AppConstants.API_BASE_URL)
|
||||
// .client(httpClient.build())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
apiService = retrofit.create(GatewayApiService.class);
|
||||
|
||||
return retrofit.create(GatewayApiService.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user