Fix a crash

This commit is contained in:
Thomas 2023-09-11 11:02:55 +02:00
parent e735947362
commit b6659de483
1 changed files with 10 additions and 6 deletions

View File

@ -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);
}
}
}