Example usage for android.widget QuickContactBadge setImageDrawable

List of usage examples for android.widget QuickContactBadge setImageDrawable

Introduction

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

Prototype

public void setImageDrawable(@Nullable Drawable drawable) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

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

private void updateContactBadge(QuickContactBadge badge, String addr, boolean isSelf) {
    Drawable avatarDrawable;//w w  w  .j av  a2  s . co m
    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   w w  w  .j a va 2 s. c o m
 * @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);
}