retrofit instance done
This commit is contained in:
31
app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java
Normal file
31
app/src/main/java/com/example/myapp_1/DB/RetrofitClient.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.example.myapp_1.DB;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class RetrofitClient {
|
||||
|
||||
private static Retrofit retrofit;
|
||||
|
||||
//Define the base URL//
|
||||
|
||||
private static final String BASE_URL = "https://localhost:8080";
|
||||
|
||||
//Create the Retrofit instance//
|
||||
|
||||
public static Retrofit getRetrofitInstance() {
|
||||
if (retrofit == null) {
|
||||
retrofit = new retrofit2.Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
|
||||
//Add the converter//
|
||||
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
|
||||
//Build the Retrofit instance//
|
||||
|
||||
.build();
|
||||
}
|
||||
return retrofit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user