use of com.android.ex.chips.RecipientEntry in project instructure-android by instructure.
the class AddMessageFragment method addRecipients.
private void addRecipients(ArrayList<Recipient> newRecipients) {
List<RecipientEntry> selectedRecipients = mChipsTextView.getSelectedRecipients();
mChipsTextView.setTokenizer(new Rfc822Tokenizer());
if (mChipsAdapter == null) {
mChipsAdapter = new RecipientAdapter(getContext());
}
if (mChipsTextView.getAdapter() == null) {
mChipsTextView.setAdapter(mChipsAdapter);
}
addRecipient: for (Recipient recipient : newRecipients) {
// Skip if this recipient is already added
for (RecipientEntry entry : selectedRecipients) {
if (entry.getDestination().equals(recipient.getStringId())) {
continue addRecipient;
}
}
// Create RecipientEntry from Recipient and add to list
RecipientEntry recipientEntry = new RecipientEntry(recipient.getIdAsLong(), recipient.getName(), recipient.getStringId(), "", recipient.getAvatarURL(), 0, 0, true, recipient.getCommonCourses() != null ? recipient.getCommonCourses().keySet() : null, recipient.getCommonGroups() != null ? recipient.getCommonGroups().keySet() : null);
mChipsTextView.appendRecipientEntry(recipientEntry);
}
}
use of com.android.ex.chips.RecipientEntry in project instructure-android by instructure.
the class AddMessageFragment method getRecipientsFromRecipientEntries.
private ArrayList<Recipient> getRecipientsFromRecipientEntries() {
List<RecipientEntry> selectedRecipients = mChipsTextView.getSelectedRecipients();
ArrayList<Recipient> recipients = new ArrayList<>();
for (RecipientEntry entry : selectedRecipients) {
Recipient recipient = new Recipient();
recipient.setAvatarURL(entry.getAvatarUrl());
recipient.setName(entry.getName());
recipient.setStringId(entry.getDestination());
recipients.add(recipient);
}
return recipients;
}
Aggregations