use of im.actor.sdk.controllers.conversation.view.MentionSpan in project actor-platform by actorapp.
the class ChatListProcessor method fixLinkifyCustomLinks.
private boolean fixLinkifyCustomLinks(Spannable spannable, Pattern p, boolean isMention) {
Matcher m = p.matcher(spannable.toString());
boolean res = false;
while (m.find()) {
boolean found = false;
String nick = "";
UserVM user;
int userId = 0;
if (isGroup) {
for (GroupMember member : group.getMembers().get()) {
user = users().get(member.getUid());
nick = user.getNick().get();
if (nick != null && !nick.isEmpty() && nick.equals(m.group().substring(1, m.group().length()))) {
userId = user.getId();
found = true;
break;
}
}
}
if (isMention && !found) {
return false;
}
URLSpan span = (isMention && isGroup && found) ? new MentionSpan(nick, userId, false) : new BaseUrlSpan(m.group(), false);
spannable.setSpan(span, m.start(), m.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
res = true;
}
return res;
}
Aggregations