use of com.applozic.mobicomkit.api.conversation.MentionMetadataModel in project Applozic-Android-SDK by AppLozic.
the class MentionAutoCompleteTextView method recreateMentionsSpanAndData.
private void recreateMentionsSpanAndData(Spannable spannable, Pattern pattern) {
try {
final Matcher matcher = pattern.matcher(spannable);
while (matcher.find()) {
// the character index after mention token start char (i.e. '@')
final int start = matcher.start() + 1;
final int end = matcher.end();
String possibleMention = matcher.group(1);
for (Mention mention : mentionAdapter.getMentions()) {
if (mention.getMentionIdentifier().equals(possibleMention)) {
MentionMetadataModel mentionMetadataModel = new MentionMetadataModel();
mentionMetadataModel.userId = mention.getUserId().toString();
if (mention.getDisplayName() != null && !mention.getDisplayName().equals(Utils.EMPTY_STRING)) {
mentionMetadataModel.displayName = mention.getDisplayName().toString();
}
int[] indices = new int[2];
// for sorting
indices[0] = start;
mentionMetadataModel.indices = indices;
mentionMetadataModels.add(mentionMetadataModel);
final MentionClickableSpan span = new MentionClickableSpan();
spannable.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (span instanceof MentionClickableSpan) {
span.userId = mention.getUserId();
}
}
}
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
Aggregations