From 88da62b8e8e5c605c1545340dd8897d5e99d018d Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 May 2023 12:14:20 +0200 Subject: [PATCH] Fix a crash when forwarding tags --- .../mastodon/ui/drawer/ComposeAdapter.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 257adf8e..8a1c40b4 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -1646,14 +1646,16 @@ public class ComposeAdapter extends RecyclerView.Adapter 0 && statusDraft.text != null && statusDraft.text.contains("#") && !statusList.get(position).tagAdded) { Status status = statusList.get(position - 1).reblog == null ? statusList.get(position - 1) : statusList.get(position - 1).reblog; - statusList.get(position).tagAdded = true; - int lenght = 0; - for (Tag tag : status.tags) { - lenght += ("#" + tag.name + " ").length(); + if (status.tags != null && status.tags.size() > 0) { + statusList.get(position).tagAdded = true; + int lenght = 0; + for (Tag tag : status.tags) { + lenght += ("#" + tag.name + " ").length(); + } + statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3; + statusDraft.setCursorToEnd = false; + holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3); } - statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3; - statusDraft.setCursorToEnd = false; - holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3); } if (statusDraft.spoiler_text != null) {