Search in sources :

Example 6 with RoundedAvatarDrawable

use of org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable in project Zom-Android by zom.

the class MessageListItem method showAvatar.

private void showAvatar(String address, String nickname, boolean isLeft, int presenceStatus) {
    if (mHolder.mAvatar == null)
        return;
    mHolder.mAvatar.setVisibility(View.GONE);
    if (address != null && isLeft) {
        RoundedAvatarDrawable avatar = null;
        try {
            avatar = (RoundedAvatarDrawable) DatabaseUtils.getAvatarFromAddress(this.getContext().getContentResolver(), XmppAddress.stripResource(address), ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
        } catch (Exception e) {
        }
        if (avatar != null) {
            mHolder.mAvatar.setVisibility(View.VISIBLE);
            mHolder.mAvatar.setImageDrawable(avatar);
        // setAvatarBorder(presenceStatus, avatar);
        } else {
            // int color = getAvatarBorder(presenceStatus);
            int padding = 24;
            if (nickname.length() > 0) {
                LetterAvatar lavatar = new LetterAvatar(getContext(), nickname, padding);
                mHolder.mAvatar.setVisibility(View.VISIBLE);
                mHolder.mAvatar.setImageDrawable(lavatar);
            }
        }
    }
}
Also used : LetterAvatar(org.awesomeapp.messenger.ui.widgets.LetterAvatar) RoundedAvatarDrawable(org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable) RemoteException(android.os.RemoteException) IOException(java.io.IOException) SuppressLint(android.annotation.SuppressLint)

Aggregations

RoundedAvatarDrawable (org.awesomeapp.messenger.ui.widgets.RoundedAvatarDrawable)6 RemoteException (android.os.RemoteException)3 IOException (java.io.IOException)3 LetterAvatar (org.awesomeapp.messenger.ui.widgets.LetterAvatar)3 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 SpannableString (android.text.SpannableString)2 UnderlineSpan (android.text.style.UnderlineSpan)2 SuppressLint (android.annotation.SuppressLint)1 AssetFileDescriptor (android.content.res.AssetFileDescriptor)1 Cursor (android.database.Cursor)1 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 View (android.view.View)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Date (java.util.Date)1 ImApp (org.awesomeapp.messenger.ImApp)1 GroupAvatar (org.awesomeapp.messenger.ui.widgets.GroupAvatar)1