From bbb47626cedffa588e05d8004ddee1fcf4d31ee6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 30 Jul 2023 11:13:14 +0200 Subject: [PATCH] fix for all calls --- .../android/mastodon/client/entities/nitter/Nitter.java | 2 +- .../android/mastodon/helper/CrossActionHelper.java | 8 +++----- .../android/mastodon/helper/NotificationsHelper.java | 4 ++-- .../android/mastodon/helper/PushNotifications.java | 4 ++-- .../app/fedilab/android/mastodon/jobs/ComposeWorker.java | 4 ++-- .../fedilab/android/mastodon/jobs/FetchHomeWorker.java | 2 +- .../android/mastodon/jobs/ScheduleBoostWorker.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/AccountsVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/AdminVM.java | 8 ++++---- .../mastodon/viewmodel/mastodon/AnnouncementsVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/AppsVM.java | 2 +- .../android/mastodon/viewmodel/mastodon/FiltersVM.java | 2 +- .../android/mastodon/viewmodel/mastodon/InstancesVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/NodeInfoVM.java | 2 +- .../mastodon/viewmodel/mastodon/NotificationsVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/OauthVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/OembedVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/SearchVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/StatusesVM.java | 4 ++-- .../android/mastodon/viewmodel/mastodon/TagVM.java | 2 +- .../android/mastodon/viewmodel/mastodon/TimelinesVM.java | 6 +++--- .../android/mastodon/viewmodel/pleroma/ActionsVM.java | 4 ++-- .../android/peertube/client/RetrofitPeertubeAPI.java | 3 ++- 23 files changed, 44 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/nitter/Nitter.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/nitter/Nitter.java index fbc78ad7..a3465ef1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/nitter/Nitter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/nitter/Nitter.java @@ -69,7 +69,7 @@ public class Nitter implements Serializable { .proxy(Helper.getProxy(context)) .build(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED)) + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null)) .addConverterFactory(SimpleXmlConverterFactory.create()) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java index 49a4f1df..8196b197 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java @@ -259,14 +259,14 @@ public class CrossActionHelper { } - private static MastodonSearchService init(Context context, @NonNull String instance) { + private static MastodonSearchService init(Context context, String instance) { final OkHttpClient okHttpClient = new OkHttpClient.Builder() .readTimeout(60, TimeUnit.SECONDS) .connectTimeout(60, TimeUnit.SECONDS) .proxy(Helper.getProxy(context)) .build(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); @@ -493,9 +493,7 @@ public class CrossActionHelper { * Fetch and federate the remote status */ public static void fetchAccountInRemoteInstance(@NonNull Context context, String acct, String instance, Callback callback) { - if (instance == null) { - return; - } + MastodonSearchService mastodonSearchService = init(context, instance); new Thread(() -> { Call resultsCall = mastodonSearchService.search(null, acct, null, "accounts", null, null, null, null, null, null, 1); diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java index 9855c663..7147758f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java @@ -135,7 +135,7 @@ public class NotificationsHelper { } - private static MastodonNotificationsService init(Context context, @NonNull String instance) { + private static MastodonNotificationsService init(Context context, String instance) { final OkHttpClient okHttpClient = new OkHttpClient.Builder() .readTimeout(60, TimeUnit.SECONDS) @@ -143,7 +143,7 @@ public class NotificationsHelper { .proxy(Helper.getProxy(context)) .build(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java b/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java index a9902ce5..1f997a40 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java @@ -131,14 +131,14 @@ public class PushNotifications { slug + "/unifiedpush.connector", null); } - private static MastodonNotificationsService init(@NonNull Context context, @NonNull String instance) { + private static MastodonNotificationsService init(@NonNull Context context, String instance) { final OkHttpClient okHttpClient = new OkHttpClient.Builder() .readTimeout(60, TimeUnit.SECONDS) .connectTimeout(60, TimeUnit.SECONDS) .proxy(Helper.getProxy(context.getApplicationContext())) .build(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java index d07a31e0..b0e055df 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java @@ -97,9 +97,9 @@ public class ComposeWorker extends Worker { .build(); } - private static MastodonStatusesService init(Context context, @NonNull String instance) { + private static MastodonStatusesService init(Context context, String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(getOkHttpClient(context)) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java index 76e13a59..dae01c5b 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java @@ -252,7 +252,7 @@ public class FetchHomeWorker extends Worker { private MastodonTimelinesService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleBoostWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleBoostWorker.java index 3d36df42..add0a8b4 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleBoostWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleBoostWorker.java @@ -109,9 +109,9 @@ public class ScheduleBoostWorker extends Worker { .build(); } - private MastodonStatusesService init(@NonNull String instance) { + private MastodonStatusesService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create()) .client(getOkHttpClient()) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java index a018695a..7deb0e73 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java @@ -106,7 +106,7 @@ public class AccountsVM extends AndroidViewModel { private MastodonAccountsService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); @@ -115,7 +115,7 @@ public class AccountsVM extends AndroidViewModel { private MastodonAccountsService initv2(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AdminVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AdminVM.java index f0a705d0..c3a08155 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AdminVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AdminVM.java @@ -63,18 +63,18 @@ public class AdminVM extends AndroidViewModel { super(application); } - private MastodonAdminService init(@NonNull String instance) { + private MastodonAdminService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); return retrofit.create(MastodonAdminService.class); } - private MastodonAdminService initv2(@NonNull String instance) { + private MastodonAdminService initv2(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AnnouncementsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AnnouncementsVM.java index 3287499a..235e44e6 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AnnouncementsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AnnouncementsVM.java @@ -51,9 +51,9 @@ public class AnnouncementsVM extends AndroidViewModel { super(application); } - private MastodonAnnouncementsService init(@NonNull String instance) { + private MastodonAnnouncementsService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AppsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AppsVM.java index 9ef5f65f..3e472e7e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AppsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AppsVM.java @@ -61,7 +61,7 @@ public class AppsVM extends AndroidViewModel { 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://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/FiltersVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/FiltersVM.java index edb8cf03..a063616f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/FiltersVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/FiltersVM.java @@ -58,7 +58,7 @@ public class FiltersVM extends AndroidViewModel { private MastodonFiltersService initV2(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/") // .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/InstancesVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/InstancesVM.java index 1843df80..643c0b80 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/InstancesVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/InstancesVM.java @@ -61,10 +61,10 @@ public class InstancesVM extends AndroidViewModel { super(application); } - private MastodonInstanceService init(@NonNull String instance) { + private MastodonInstanceService init(String instance) { Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NodeInfoVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NodeInfoVM.java index f2a77a70..f62811b3 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NodeInfoVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NodeInfoVM.java @@ -53,7 +53,7 @@ public class NodeInfoVM extends AndroidViewModel { private NodeInfoService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/") .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java index 5fb42ffd..765d9493 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java @@ -93,9 +93,9 @@ public class NotificationsVM extends AndroidViewModel { } } - private MastodonNotificationsService init(@NonNull String instance) { + private MastodonNotificationsService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OauthVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OauthVM.java index c8c985b1..e976e991 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OauthVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OauthVM.java @@ -59,10 +59,10 @@ public class OauthVM extends AndroidViewModel { super(application); } - private MastodonAppsService init(@NonNull String instance) { + private MastodonAppsService init(String instance) { Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OembedVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OembedVM.java index 173a48a5..c9c41720 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OembedVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/OembedVM.java @@ -41,9 +41,9 @@ public class OembedVM extends AndroidViewModel { super(application); } - private MastodonOembedService init(@NonNull String instance) { + private MastodonOembedService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/SearchVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/SearchVM.java index 491fd0ae..b5f92bb1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/SearchVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/SearchVM.java @@ -57,10 +57,10 @@ public class SearchVM extends AndroidViewModel { super(application); } - private MastodonSearchService init(@NonNull String instance) { + private MastodonSearchService init(String instance) { Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/StatusesVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/StatusesVM.java index b601c47e..77f13ecc 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/StatusesVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/StatusesVM.java @@ -91,9 +91,9 @@ public class StatusesVM extends AndroidViewModel { .build(); } - private MastodonStatusesService init(@NonNull String instance) { + private MastodonStatusesService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(getOkHttpClient()) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TagVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TagVM.java index e6779dbc..faa71e2d 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TagVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TagVM.java @@ -64,7 +64,7 @@ public class TagVM extends AndroidViewModel { private MastodonTagService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java index 11bd77d6..ea607168 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java @@ -158,7 +158,7 @@ public class TimelinesVM extends AndroidViewModel { private MastodonTimelinesService initInstanceOnly(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED)) + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null)) .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); @@ -167,7 +167,7 @@ public class TimelinesVM extends AndroidViewModel { private MastodonTimelinesService initInstanceXMLOnly(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED)) + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null)) .addConverterFactory(SimpleXmlConverterFactory.create()) .client(okHttpClient) .build(); @@ -176,7 +176,7 @@ public class TimelinesVM extends AndroidViewModel { private MastodonTimelinesService init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/pleroma/ActionsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/pleroma/ActionsVM.java index 2081edb1..564cd79d 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/pleroma/ActionsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/pleroma/ActionsVM.java @@ -47,9 +47,9 @@ public class ActionsVM extends AndroidViewModel { super(application); } - private PleromaAPI init(@NonNull String instance) { + private PleromaAPI init(String instance) { Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/") + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/") .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder())) .client(okHttpClient) .build(); diff --git a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java index e21def8e..6e1934ec 100644 --- a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java +++ b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java @@ -44,6 +44,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.net.IDN; import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; @@ -253,7 +254,7 @@ public class RetrofitPeertubeAPI { .proxy(app.fedilab.android.mastodon.helper.Helper.getProxy(_context.getApplicationContext())) .build(); Retrofit retrofit = new Retrofit.Builder() - .baseUrl("https://" + instance) + .baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null)) .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build();