-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRetrofit
More file actions
39 lines (27 loc) · 912 Bytes
/
Retrofit
File metadata and controls
39 lines (27 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//API Service
public interface ApiService {
@POST("apiName.php")
Call<ResponseBody> uploadImage(@Body RequestBody file,
@Query("user_id") String user_id,
@Query("number") String number);
}
//Base URL
public class ApiUtilities {
//Live
// public static final String baseurl = "BASE URL";
public static ApiService getApiservice() {
return RetrofitClient.getClient(baseurl).create(ApiService.class);
}
}
//Intercepter
public class RetrofitClient {
public static Retrofit retrofit = null;
public static Retrofit getClient(String baseurl) {
if (retrofit == null) {
retrofit = new Retrofit.Builder().baseUrl(baseurl)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}