Example usage for android.widget QuickContactBadge assignContactUri

List of usage examples for android.widget QuickContactBadge assignContactUri

Introduction

In this page you can find the example usage for android.widget QuickContactBadge assignContactUri.

Prototype

public void assignContactUri(Uri contactUri) 

Source Link

Document

Assign the contact uri that this QuickContactBadge should be associated with.

Usage

From source file:com.android.mms.quickmessage.QuickMessage.java

private void updateContactBadge(QuickContactBadge badge, String addr, boolean isSelf) {
    Drawable avatarDrawable;/*from w w w.j  a  va 2s.  com*/
    if (isSelf || !TextUtils.isEmpty(addr)) {
        Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr, false);
        avatarDrawable = contact.getAvatar(mContext, mDefaultContactImage);

        if (isSelf) {
            badge.assignContactUri(Profile.CONTENT_URI);
        } else {
            if (contact.existsInDatabase()) {
                badge.assignContactUri(contact.getUri());
            } else {
                badge.assignContactFromPhone(contact.getNumber(), true);
            }
        }
    } else {
        avatarDrawable = mDefaultContactImage;
    }
    badge.setImageDrawable(avatarDrawable);
}

From source file:com.android.mms.quickmessage.QuickMessagePopup.java

/**
 * Show the appropriate image for the QuickContact badge
 *
 * @param badge//from www .  j a  va 2s. com
 * @param addr
 * @param isSelf
 */
private void updateContactBadge(QuickContactBadge badge, String addr, boolean isSelf) {
    Drawable avatarDrawable;
    if (isSelf || !TextUtils.isEmpty(addr)) {
        Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr, false);
        avatarDrawable = contact.getAvatar(mContext, mDefaultContactImage);

        if (isSelf) {
            badge.assignContactUri(Profile.CONTENT_URI);
        } else {
            if (contact.existsInDatabase()) {
                badge.assignContactUri(contact.getUri());
            } else {
                badge.assignContactFromPhone(contact.getNumber(), true);
            }
        }
    } else {
        avatarDrawable = mDefaultContactImage;
    }
    badge.setImageDrawable(avatarDrawable);
}