From b08cd1eb4bddf0aa6df37525e972292811c2b74b Mon Sep 17 00:00:00 2001 From: Grishka Date: Mon, 4 Dec 2023 06:22:21 +0300 Subject: [PATCH] Crash fixes --- .../org/joinmastodon/android/fragments/ComposeFragment.java | 2 ++ .../ui/viewcontrollers/ComposeAutocompleteViewController.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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 919e68349..f7a0a2225 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -1077,6 +1077,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr Editable e=mainEditText.getText(); int start=e.getSpanStart(currentAutocompleteSpan); int end=e.getSpanEnd(currentAutocompleteSpan); + if(start==-1 || end==-1) + return; e.replace(start, end, text+" "); finishAutocomplete(); InputConnection conn=mainEditText.getCurrentInputConnection(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java index b65730fe9..52fa556ba 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java @@ -278,7 +278,7 @@ public class ComposeAutocompleteViewController{ @Override public void onSuccess(SearchResults result){ currentRequest=null; - if(result.hashtags.isEmpty() || (result.hashtags.size()==1 && result.hashtags.get(0).name.equals(lastText.substring(1)))) + if(result.hashtags.isEmpty() || (result.hashtags.size()==1 && result.hashtags.get(0).name.equals(lastText.substring(1))) || mode!=Mode.HASHTAGS) return; List oldList=hashtags; hashtags=result.hashtags;