Search in sources :

Example 1 with RecipientsAdapter

use of org.thoughtcrime.securesms.contacts.RecipientsAdapter in project Signal-Android by signalapp.

the class PushRecipientsPanel method initRecipientsEditor.

private void initRecipientsEditor() {
    this.recipientsText = (RecipientsEditor) findViewById(R.id.recipients_text);
    List<Recipient> recipients = getRecipients();
    for (Recipient recipient : recipients) {
        recipient.addListener(this);
    }
    recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
    recipientsText.populate(recipients);
    recipientsText.setOnFocusChangeListener(new FocusChangedListener());
    recipientsText.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (panelChangeListener != null) {
                panelChangeListener.onRecipientsPanelUpdate(getRecipients());
            }
            recipientsText.setText("");
        }
    });
}
Also used : Recipient(org.thoughtcrime.securesms.recipients.Recipient) AdapterView(android.widget.AdapterView) RecipientsAdapter(org.thoughtcrime.securesms.contacts.RecipientsAdapter) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 2 with RecipientsAdapter

use of org.thoughtcrime.securesms.contacts.RecipientsAdapter in project Signal-Android by WhisperSystems.

the class SingleRecipientPanel method initRecipientsEditor.

private void initRecipientsEditor() {
    Recipients recipients;
    recipientsText = (RecipientsEditor) findViewById(R.id.recipients_text);
    try {
        recipients = getRecipients();
    } catch (RecipientFormattingException e) {
        recipients = RecipientFactory.getRecipientsFor(getContext(), new LinkedList<Recipient>(), true);
    }
    recipients.addListener(this);
    recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
    recipientsText.populate(recipients);
    recipientsText.setOnFocusChangeListener(new FocusChangedListener());
    recipientsText.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (panelChangeListener != null) {
                try {
                    panelChangeListener.onRecipientsPanelUpdate(getRecipients());
                } catch (RecipientFormattingException rfe) {
                    panelChangeListener.onRecipientsPanelUpdate(null);
                }
            }
            recipientsText.setText("");
        }
    });
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) Recipient(org.thoughtcrime.securesms.recipients.Recipient) View(android.view.View) AdapterView(android.widget.AdapterView) AdapterView(android.widget.AdapterView) RecipientsAdapter(org.thoughtcrime.securesms.contacts.RecipientsAdapter) RecipientFormattingException(org.thoughtcrime.securesms.recipients.RecipientFormattingException)

Example 3 with RecipientsAdapter

use of org.thoughtcrime.securesms.contacts.RecipientsAdapter in project Signal-Android by WhisperSystems.

the class PushRecipientsPanel method initRecipientsEditor.

private void initRecipientsEditor() {
    this.recipientsText = (RecipientsEditor) findViewById(R.id.recipients_text);
    List<Recipient> recipients = getRecipients();
    Stream.of(recipients).map(Recipient::live).forEach(r -> r.observeForever(this));
    recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
    recipientsText.populate(recipients);
    recipientsText.setOnFocusChangeListener(new FocusChangedListener());
    recipientsText.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (panelChangeListener != null) {
                panelChangeListener.onRecipientsPanelUpdate(getRecipients());
            }
            recipientsText.setText("");
        }
    });
}
Also used : Recipient(org.thoughtcrime.securesms.recipients.Recipient) AdapterView(android.widget.AdapterView) RecipientsAdapter(org.thoughtcrime.securesms.contacts.RecipientsAdapter) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

View (android.view.View)3 AdapterView (android.widget.AdapterView)3 RecipientsAdapter (org.thoughtcrime.securesms.contacts.RecipientsAdapter)3 Recipient (org.thoughtcrime.securesms.recipients.Recipient)3 RecipientFormattingException (org.thoughtcrime.securesms.recipients.RecipientFormattingException)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1