Search in sources :

Example 6 with RecipientEntry

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);
    }
}
Also used : Rfc822Tokenizer(android.text.util.Rfc822Tokenizer) RecipientAdapter(com.instructure.teacher.adapters.RecipientAdapter) Recipient(com.instructure.canvasapi2.models.Recipient) RecipientEntry(com.android.ex.chips.RecipientEntry)

Example 7 with 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;
}
Also used : ArrayList(java.util.ArrayList) Recipient(com.instructure.canvasapi2.models.Recipient) RecipientEntry(com.android.ex.chips.RecipientEntry)

Aggregations

RecipientEntry (com.android.ex.chips.RecipientEntry)7 ArrayList (java.util.ArrayList)3 Recipient (com.instructure.canvasapi2.models.Recipient)2 HashMap (java.util.HashMap)2 Rfc822Tokenizer (android.text.util.Rfc822Tokenizer)1 RecipientAdapter (com.instructure.teacher.adapters.RecipientAdapter)1