From 93fbc52f6ac16a10c06d1dc61bbe224a041c0d1c Mon Sep 17 00:00:00 2001 From: Grishka Date: Fri, 29 Apr 2022 03:37:18 +0300 Subject: [PATCH] More crash fixes --- mastodon/build.gradle | 2 +- .../joinmastodon/android/api/MastodonAPIRequest.java | 11 ++++++++--- .../android/fragments/ComposeFragment.java | 2 +- .../org/joinmastodon/android/ui/utils/UiUtils.java | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 2e55b8a29..2bcc4692a 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -58,7 +58,7 @@ dependencies { implementation 'me.grishka.litex:dynamicanimation:1.1.0-alpha03' implementation 'me.grishka.litex:viewpager:1.0.0' implementation 'me.grishka.litex:viewpager2:1.0.0' - implementation 'me.grishka.appkit:appkit:1.2.2' + implementation 'me.grishka.appkit:appkit:1.2.3' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.14.3' implementation 'com.squareup:otto:1.3.8' diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonAPIRequest.java b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonAPIRequest.java index 8f38d138f..0dc12ea97 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonAPIRequest.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonAPIRequest.java @@ -75,9 +75,14 @@ public abstract class MastodonAPIRequest extends APIRequest{ } public MastodonAPIRequest exec(String accountID){ - account=AccountSessionManager.getInstance().getAccount(accountID); - domain=account.domain; - account.getApiController().submitRequest(this); + try{ + account=AccountSessionManager.getInstance().getAccount(accountID); + domain=account.domain; + account.getApiController().submitRequest(this); + }catch(Exception x){ + Log.e(TAG, "exec: this shouldn't happen, but it still did", x); + invokeErrorCallback(new MastodonErrorResponse(x.getLocalizedMessage(), -1)); + } return this; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 6b26ac44f..394a653be 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -1096,7 +1096,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr @Override public String[] onGetAllowedMediaMimeTypes(){ - if(instance.configuration!=null && instance.configuration.mediaAttachments!=null && instance.configuration.mediaAttachments.supportedMimeTypes!=null) + if(instance!=null && instance.configuration!=null && instance.configuration.mediaAttachments!=null && instance.configuration.mediaAttachments.supportedMimeTypes!=null) return instance.configuration.mediaAttachments.supportedMimeTypes.toArray(new String[0]); return new String[]{"image/jpeg", "image/gif", "image/png", "video/mp4"}; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index a6b0dbe22..b442e8d77 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -182,7 +182,7 @@ public class UiUtils{ String name=cursor.getString(0); if(name!=null) return name; - } + }catch(Throwable ignore){} } return uri.getLastPathSegment(); }