@Override public void bindView(View view, Context context, Cursor cursor) { final DataHolder contactData = (DataHolder) view.getTag(R.id.contact_info_tag); final ViewHolder holder = (ViewHolder) view.getTag(R.id.holder_tag); if (holder == null) { Log.w(TAG, "ViewHolder was null. This should not happen."); return; } if (contactData == null) { Log.w(TAG, "DataHolder was null. This should not happen."); return; } if (ID_COLUMN < 0) { populateColumnIndices(cursor); } contactData.type = cursor.getInt(TYPE_COLUMN); contactData.name = cursor.getString(NAME_COLUMN); contactData.number = cursor.getString(NUMBER_COLUMN); contactData.numberType = cursor.getInt(NUMBER_TYPE_COLUMN); contactData.id = cursor.getLong(ID_COLUMN); if (contactData.type != ContactsDatabase.PUSH_TYPE) { holder.name.setTextColor(drawables.getColor(1, 0xff000000)); holder.number.setTextColor(drawables.getColor(1, 0xff000000)); } else { holder.name.setTextColor(drawables.getColor(0, 0xa0000000)); holder.number.setTextColor(drawables.getColor(0, 0xa0000000)); } if (selectedContacts.containsKey(contactData.id)) { holder.checkBox.setChecked(true); } else { holder.checkBox.setChecked(false); } holder.name.setText(contactData.name); if (contactData.number == null || contactData.number.isEmpty()) { holder.name.setEnabled(false); holder.number.setText(""); } else if (contactData.type == ContactsDatabase.PUSH_TYPE) { holder.number.setText(contactData.number); } else { final CharSequence label = ContactsContract.CommonDataKinds.Phone.getTypeLabel( context.getResources(), contactData.numberType, ""); final CharSequence numberWithLabel = contactData.number + " " + label; final Spannable numberLabelSpan = new SpannableString(numberWithLabel); numberLabelSpan.setSpan( new ForegroundColorSpan(drawables.getColor(2, 0xff444444)), contactData.number.length(), numberWithLabel.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); holder.number.setText(numberLabelSpan); } holder.contactPhoto.setImageBitmap(defaultCroppedPhoto); loadBitmap(contactData.number, holder.contactPhoto); }
public CharSequence getPhoneTypeLabel(Integer value) { if (value == null) { return StringUtil.EMPTY; } Context context = ContextHolder.get(); return ContactsContract.CommonDataKinds.Phone.getTypeLabel( context.getResources(), value, StringUtil.EMPTY); }
@Override public void bindView(View view, Context context, Cursor cursor) { long id = cursor.getLong(cursor.getColumnIndexOrThrow(ContactsDatabase.ID_COLUMN)); int type = cursor.getInt(cursor.getColumnIndexOrThrow(ContactsDatabase.TYPE_COLUMN)); String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NAME_COLUMN)); String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_COLUMN)); int numberType = cursor.getInt(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_TYPE_COLUMN)); String label = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.LABEL_COLUMN)); String labelText = ContactsContract.CommonDataKinds.Phone.getTypeLabel( context.getResources(), numberType, label) .toString(); int color = (type == ContactsDatabase.PUSH_TYPE) ? drawables.getColor(0, 0xa0000000) : drawables.getColor(1, 0xff000000); ((ContactSelectionListItem) view).unbind(); ((ContactSelectionListItem) view).set(id, type, name, number, labelText, color, multiSelect); ((ContactSelectionListItem) view).setChecked(selectedContacts.containsKey(id)); }
public CharSequence getTypeString(Resources r) { return ContactsContract.CommonDataKinds.Phone.getTypeLabel(r, category, label); }
@Override public String getTypeString(Resources resources) { return ContactsContract.CommonDataKinds.Phone.getTypeLabel(resources, getType(), getLabel()) .toString(); }