Fix a crash when writing an unsupported domain

This commit is contained in:
Thomas 2022-11-21 11:11:14 +01:00
parent e8018a6560
commit 495bc70ffb
1 changed files with 8 additions and 2 deletions

View File

@ -57,7 +57,7 @@ public class AppsVM extends AndroidViewModel {
super(application);
}
private MastodonAppsService init(String instance) {
private MastodonAppsService init(String instance) throws IllegalArgumentException {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
@ -81,7 +81,13 @@ public class AppsVM extends AndroidViewModel {
String scopes,
String website) {
appMutableLiveData = new MutableLiveData<>();
MastodonAppsService mastodonAppsService = init(instance);
MastodonAppsService mastodonAppsService;
try {
mastodonAppsService = init(instance);
} catch (IllegalArgumentException e) {
appMutableLiveData.setValue(null);
return appMutableLiveData;
}
new Thread(() -> {
App app = null;
Call<App> appCall = mastodonAppsService.createApp(client_name, redirect_uris, scopes, website);