-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBaseApplication.java
More file actions
43 lines (35 loc) · 1.2 KB
/
BaseApplication.java
File metadata and controls
43 lines (35 loc) · 1.2 KB
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
40
41
42
43
package ai.elimu.content_provider;
import android.app.Application;
import android.util.Log;
import ai.elimu.content_provider.util.SharedPreferencesHelper;
import ai.elimu.content_provider.util.VersionHelper;
import ai.elimu.model.v2.enums.Language;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class BaseApplication extends Application {
@Override
public void onCreate() {
Log.i(getClass().getName(), "onCreate");
super.onCreate();
VersionHelper.updateAppVersion(getApplicationContext());
}
public Retrofit getRetrofit() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(getRestUrl() + "/")
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
/**
* E.g. "https://eng.elimu.ai" or "https://hin.elimu.ai"
*/
public String getBaseUrl() {
Language language = SharedPreferencesHelper.getLanguage(getApplicationContext());
String url = "http://" + language.getIsoCode();
url += ".elimu.ai";
return url;
}
public String getRestUrl() {
return getBaseUrl() + "/rest/v2";
}
}