mentions
mentions copied to clipboard
how to insert Multiple Mention at a time
I have a list of 5 users I want to insert them into edit text but I am not able to insert them.
mention.setMentionName(user.getFIRSTNAME());
mention.setMentionId(user.getPERSON_ID());
mentions.insertMention(mention);
@amitsharma492 Did you able to resolve this issue ?
@iamshajeer / @amitsharma492 did you find any solution for this issue? Experiencing the same issue here. When I try to insert using by creating mention's object it throws the stackoverflowerror.
val mention = Mention()
mention.mentionName = tagUsers.full_name
mention.mentionId = tagUsers.id
mention.mentionOffset = mentionedPattern.start()
mention.mentionLength = mentionedPattern.end() - mentionedPattern.start()
mentions?.insertMention(mention)
Still I am getting an error with insertMention() method. However, I found other way to achieve the same by adding list of mention using addMentions() method.
var commentStringBuilder = StringBuilder(comment)
if (tagUsersList != null && tagUsersList.isNotEmpty()) {
var listOfMentions = ArrayList<Mention>()
for (tagUsers in tagUsersList) {
val p = Pattern.compile("~<<<" + tagUsers.id + ">>>~")
val mentionedPattern = p.matcher(commentStringBuilder)
if (mentionedPattern.find()) {
val mention = Mention()
mention.mentionName = tagUsers.full_name
mention.mentionId = tagUsers.id
mention.mentionOffset = mentionedPattern.start()
mention.mentionLength = tagUsers.full_name.length
listOfMentions.add(mention)
commentStringBuilder = commentStringBuilder.replace(mentionedPattern.start(), mentionedPattern.end(), tagUsers.full_name)
}
}
mentions?.addMentions(listOfMentions)
Try this way 👍 It will work.
EditText editTextObject = findViewById(R.id.xx);
Mentions mentions = new Mentions.Builder(this, editTextObject)
.suggestionsListener(this)
.queryListener(this)
.build();`
List<UserModel> users;
public void insertMultiple(){
for (int i = 0; i < users.size(); i++) {
editTextObject.append("@");
editTextObject.setSelection(editTextObject.getText().length());
editTextObject.setCursorVisible(true);
editTextObject.requestFocus();
final Mention mention = new Mention();
mention.setMentionName(users.get(i).getFIRSTNAME());
mention.setMentionId(users.get(i).getPERSON_ID());
mentions.insertMention(mention);
}
}