I got it working with custom \'@\' tokenizer. But it fails for the first autocompletion. My code works as a comma tokenizer where I get suggestion for any character and next
If you want to do mention query with the character '@', you can do query onTextChanged as below:
@Override
public void onTextChanged(CharSequence s, int start, int before, final int count) {
if (s.length() > 0) {
// Todo: query mentions
Matcher mentionMatcher = Pattern.compile("@([A-Za-z0-9_-]+)").matcher(s.toString());
// while matching
while (mentionMatcher.find()) {
yourSearchText = s.toString().substring(mentionMatcher.start() + 1, mentionMatcher.end());
// do query with yourSearchText below
}
}
}
Note: you also can do hashTag query with the character '#' by replace it in
"@([A-Za-z0-9_-]+)"
https://github.com/linkedin/Spyglass check this out , having all the use cases for mentions