Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit db066ac

Browse files
Sam1301timabbott
authored andcommitted
Fix crashes when using @-mentions.
Fixes #233.
1 parent f6c2258 commit db066ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,9 @@ public CharSequence convertToString(Cursor cursor) {
497497
int index = cursor.getColumnIndex(Emoji.NAME_FIELD);
498498
String name = cursor.getString(index);
499499
String currText = messageEt.getText().toString();
500-
int last = (cursor.getColumnIndex(Emoji.NAME_FIELD) == 6) ? currText.lastIndexOf("@") : currText.lastIndexOf(":");
501-
return TextUtils.substring(currText, 0, last) + ((cursor.getColumnIndex(Emoji.NAME_FIELD) == 6) ? "@**" + name + "**" : ":" + name.replace(".png", "") + ":");
500+
int numberOfColumns = cursor.getColumnCount();
501+
int last = (numberOfColumns > 2) ? currText.lastIndexOf("@") : currText.lastIndexOf(":");
502+
return TextUtils.substring(currText, 0, last) + ((numberOfColumns > 2) ? "@**" + name + "**" : ":" + name.replace(".png", "") + ":");
502503
}
503504
});
504505
combinedAdapter.setFilterQueryProvider(new FilterQueryProvider() {

0 commit comments

Comments
 (0)