summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-09-11 11:02:55 +0200
committerThomas <tschneider.ac@gmail.com>2023-09-11 11:02:55 +0200
commitb6659de48367910ebc92193dcdf55b8de457b6c5 (patch)
treecf74630f93a879a7b776fc7988577aca9869da08
parente735947362ec490f1fad6da5a825b9c68242e4ac (diff)
Fix a crash
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java16
1 files changed, 10 insertions, 6 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 9117e71c5..09e5bebc7 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
@@ -1647,9 +1647,11 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
lenght += ("#" + tag + " ").length();
}
holder.binding.content.setText(statusDraft.text);
- statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3;
- statusDraft.setCursorToEnd = false;
- holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3);
+ if (statusDraft.text.length() - lenght - 3 >= 0) {
+ statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3;
+ statusDraft.setCursorToEnd = false;
+ holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3);
+ }
}
} else if (forwardTag && position > 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;
@@ -1677,9 +1679,11 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
for (String tag : camelCaseTags) {
lenght += ("#" + tag + " ").length();
}
- statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3;
- statusDraft.setCursorToEnd = false;
- holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3);
+ if (statusDraft.text.length() - lenght - 3 >= 0) {
+ statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3;
+ statusDraft.setCursorToEnd = false;
+ holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3);
+ }
}
}