private void initRecipientsEditor() { Recipients recipients; recipientsText = (RecipientsEditor) findViewById(R.id.recipients_text); try { recipients = getRecipients(); } catch (RecipientFormattingException e) { recipients = new Recipients(new LinkedList<Recipient>()); } 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(""); } }); }
public Recipients getRecipients() throws RecipientFormattingException { String rawText = recipientsText.getText().toString(); Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, false); if (recipients.isEmpty()) throw new RecipientFormattingException("Recipient List Is Empty!"); return recipients; }
public void addRecipient(String name, String number) { Log.i(TAG, "addRecipient for " + name + "/" + number); if (name != null) recipientsText.append(name + "< " + number + ">, "); else recipientsText.append(number + ", "); }
public void clear() { recipientsText.setText(""); }