public final void bind(Context context, final MultiDeleteListItemData ch) { setMultiDeleteHeader(ch); // Date mDateView.setText(ch.getDate()); // From. mFromView.setText(formatMessage(ch)); // Register for updates in changes of any of the contacts in this conversation. ContactList contacts = ch.getContacts(); Contact.addListener(this); // Subject mSubjectView.setText(ch.getSubject()); mSubjectView.setSingleLine(true); mSubjectView.setEllipsize(TextUtils.TruncateAt.END); updateAvatarView(); mCheckbox.setChecked(ch.isSelected()); }
private void updateAvatarView() { MultiDeleteListItemData ch = mMultiDeleteThreadData; Drawable avatarDrawable; if (ch.getContacts().size() == 1) { Contact contact = ch.getContacts().get(0); avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage); if (contact.existsInDatabase()) { mAvatarView.assignContactUri(contact.getUri()); } else { mAvatarView.assignContactFromPhone(contact.getNumber(), true); } } else { // TODO get a multiple recipients asset (or do something else) avatarDrawable = sDefaultContactImage; mAvatarView.assignContactUri(null); } mAvatarView.setImageDrawable(avatarDrawable); }
private CharSequence formatMessage(MultiDeleteListItemData ch) { final int size = android.R.style.TextAppearance_Small; final int color = android.R.styleable.Theme_textColorSecondary; String from = ch.getFrom(); SpannableStringBuilder buf = new SpannableStringBuilder(from); if (ch.hasDraft() && ch.getMessageCount() == 0) { // only draft } else { if (ch.getUnreadMessageCount() > 0) { buf.append(" (" + ch.getUnreadMessageCount() + "/"); } else { buf.append(" (" + "0/"); } // if (ch.getMessageCount() > 1) { buf.append(ch.getMessageCount() + ") "); // } } /* if (ch.getMessageCount() > 1) { buf.append(" (" + ch.getMessageCount() + ") "); } */ return buf; }
private void updateFromView() { MultiDeleteListItemData ch = mMultiDeleteThreadData; ch.updateRecipients(); mFromView.setText(formatMessage(ch)); updateAvatarView(); }