Commit 81ef4d99 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #411 from RocketChat/fix/composer-crashing

Fix message composer crashes
parents 1aaf8924 ea31aeef
...@@ -220,6 +220,9 @@ public class AutocompleteManager { ...@@ -220,6 +220,9 @@ public class AutocompleteManager {
} }
private void replaceSelected(String autocompleteSuggestion) { private void replaceSelected(String autocompleteSuggestion) {
if (text == null) {
return;
}
final String preText = text.substring(0, fromIndex); final String preText = text.substring(0, fromIndex);
final String postText = text.substring(toIndex); final String postText = text.substring(toIndex);
......
...@@ -12,7 +12,7 @@ public abstract class AutocompleteSource<A extends AutocompleteAdapter, I extend ...@@ -12,7 +12,7 @@ public abstract class AutocompleteSource<A extends AutocompleteAdapter, I extend
new AutocompleteViewHolder.OnClickListener<I>() { new AutocompleteViewHolder.OnClickListener<I>() {
@Override @Override
public void onClick(I autocompleteItem) { public void onClick(I autocompleteItem) {
if (autocompleteSelected != null) { if (autocompleteSelected != null && autocompleteItem != null) {
autocompleteSelected.onSelected(getAutocompleteSuggestion(autocompleteItem)); autocompleteSelected.onSelected(getAutocompleteSuggestion(autocompleteItem));
} }
} }
......
...@@ -99,7 +99,7 @@ public class UserSource extends AutocompleteSource<UserAdapter, UserItem> { ...@@ -99,7 +99,7 @@ public class UserSource extends AutocompleteSource<UserAdapter, UserItem> {
@Override @Override
protected String getAutocompleteSuggestion(UserItem autocompleteItem) { protected String getAutocompleteSuggestion(UserItem autocompleteItem) {
return getTrigger() + autocompleteItem.getSuggestion(); return getTrigger() + (autocompleteItem == null ? "" : autocompleteItem.getSuggestion());
} }
private List<UserItem> toUserItemList(List<SpotlightUser> users) { private List<UserItem> toUserItemList(List<SpotlightUser> users) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment