当前位置: 首页>>代码示例>>Java>>正文


Java EaseUserUtils.setUserNick方法代码示例

本文整理汇总了Java中com.hyphenate.easeui.utils.EaseUserUtils.setUserNick方法的典型用法代码示例。如果您正苦于以下问题:Java EaseUserUtils.setUserNick方法的具体用法?Java EaseUserUtils.setUserNick怎么用?Java EaseUserUtils.setUserNick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hyphenate.easeui.utils.EaseUserUtils的用法示例。


在下文中一共展示了EaseUserUtils.setUserNick方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.em_row_search_message, parent, false);
    }
    ViewHolder holder = (ViewHolder) convertView.getTag();
    if (holder == null) {
        holder = new ViewHolder();
        holder.name = (TextView) convertView.findViewById(R.id.name);
        holder.message = (TextView) convertView.findViewById(R.id.message);
        holder.time = (TextView) convertView.findViewById(R.id.time);
        holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
        convertView.setTag(holder);
    }
    
    EMMessage message = getItem(position);
    EaseUserUtils.setUserNick(message.getFrom(), holder.name);
    EaseUserUtils.setUserAvatar(getContext(), message.getFrom(), holder.avatar);
    holder.time.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
    holder.message.setText(((EMTextMessageBody)message.getBody()).getMessage());
    
    
    return convertView;
}
 
开发者ID:laoduDYM,项目名称:ChatDemoUI3.0,代码行数:25,代码来源:GroupSearchMessageActivity.java

示例2: initListener

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
private void initListener() {
	Intent intent = getIntent();
	String username = intent.getStringExtra("username");
	boolean enableUpdate = intent.getBooleanExtra("setting", false);
	if (enableUpdate) {
		headPhotoUpdate.setVisibility(View.VISIBLE);
		iconRightArrow.setVisibility(View.VISIBLE);
		rlNickName.setOnClickListener(this);
		headAvatar.setOnClickListener(this);
	} else {
		headPhotoUpdate.setVisibility(View.GONE);
		iconRightArrow.setVisibility(View.INVISIBLE);
	}
	if(username != null){
   		if (username.equals(EMClient.getInstance().getCurrentUser())) {
   			tvUsername.setText(EMClient.getInstance().getCurrentUser());
   			EaseUserUtils.setUserNick(username, tvNickName);
               EaseUserUtils.setUserAvatar(this, username, headAvatar);
   		} else {
   			tvUsername.setText(username);
   			EaseUserUtils.setUserNick(username, tvNickName);
   			EaseUserUtils.setUserAvatar(this, username, headAvatar);
   			asyncFetchUserInfo(username);
   		}
	}
}
 
开发者ID:laoduDYM,项目名称:ChatDemoUI3.0,代码行数:27,代码来源:UserProfileActivity.java

示例3: getView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = View.inflate(getContext(), R.layout.ease_row_contact, null);
	}
	String username = getItem(position);
	TextView name = (TextView) convertView.findViewById(R.id.name);
	ImageView avatar = (ImageView) convertView.findViewById(R.id.avatar);
	
	EaseUserUtils.setUserAvatar(getContext(), username, avatar);
	EaseUserUtils.setUserNick(username, name);
	
	return convertView;
}
 
开发者ID:laoduDYM,项目名称:ChatDemoUI3.0,代码行数:15,代码来源:BlacklistActivity.java

示例4: setUpBaseView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
private void setUpBaseView() {
	// set nickname, avatar and background of bubble
    TextView timestamp = (TextView) findViewById(R.id.timestamp);
    if (timestamp != null) {
        if (position == 0) {
            timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
            timestamp.setVisibility(View.VISIBLE);
        } else {
        	// show time stamp if interval with last message is > 30 seconds
            EMMessage prevMessage = (EMMessage) adapter.getItem(position - 1);
            if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) {
                timestamp.setVisibility(View.GONE);
            } else {
                timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
                timestamp.setVisibility(View.VISIBLE);
            }
        }
    }
    //set nickname and avatar
    if(message.direct() == Direct.SEND){
        EaseUserUtils.setUserAvatar(context, EMClient.getInstance().getCurrentUser(), userAvatarView);
    }else{
        EaseUserUtils.setUserAvatar(context, message.getFrom(), userAvatarView);
        EaseUserUtils.setUserNick(message.getFrom(), usernickView);
    }
    
    if(deliveredView != null){
        if (message.isDelivered()) {
            deliveredView.setVisibility(View.VISIBLE);
        } else {
            deliveredView.setVisibility(View.INVISIBLE);
        }
    }
    
    if(ackedView != null){
        if (message.isAcked()) {
            if (deliveredView != null) {
                deliveredView.setVisibility(View.INVISIBLE);
            }
            ackedView.setVisibility(View.VISIBLE);
        } else {
            ackedView.setVisibility(View.INVISIBLE);
        }
    }
    

    if (adapter instanceof EaseMessageAdapter) {
        if (((EaseMessageAdapter) adapter).isShowAvatar())
            userAvatarView.setVisibility(View.VISIBLE);
        else
            userAvatarView.setVisibility(View.GONE);
        if (usernickView != null) {
            if (((EaseMessageAdapter) adapter).isShowUserNick())
                usernickView.setVisibility(View.VISIBLE);
            else
                usernickView.setVisibility(View.GONE);
        }
        if (message.direct() == Direct.SEND) {
            if (((EaseMessageAdapter) adapter).getMyBubbleBg() != null) {
                bubbleLayout.setBackgroundDrawable(((EaseMessageAdapter) adapter).getMyBubbleBg());
            }
        } else if (message.direct() == Direct.RECEIVE) {
            if (((EaseMessageAdapter) adapter).getOtherBuddleBg() != null) {
                bubbleLayout.setBackgroundDrawable(((EaseMessageAdapter) adapter).getOtherBuddleBg());
            }
        }
    }
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:69,代码来源:EaseChatRow.java

示例5: getView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if(convertView == null){
        holder = new ViewHolder();
        if(res == 0)
            convertView = layoutInflater.inflate(R.layout.ease_row_contact, null);
        else
            convertView = layoutInflater.inflate(res, null);
        holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
        holder.nameView = (TextView) convertView.findViewById(R.id.name);
        holder.headerView = (TextView) convertView.findViewById(R.id.header);
        convertView.setTag(holder);
    }else{
        holder = (ViewHolder) convertView.getTag();
    }
    
    EaseUser user = getItem(position);
    if(user == null)
        Log.d("ContactAdapter", position + "");
    String username = user.getUsername();
    String header = user.getInitialLetter();
    
    if (position == 0 || header != null && !header.equals(getItem(position - 1).getInitialLetter())) {
        if (TextUtils.isEmpty(header)) {
            holder.headerView.setVisibility(View.GONE);
        } else {
            holder.headerView.setVisibility(View.VISIBLE);
            holder.headerView.setText(header);
        }
    } else {
        holder.headerView.setVisibility(View.GONE);
    }
    //设置头像
    EaseUserUtils.setUserNick(username, holder.nameView);
    //设置头像
    EaseUserUtils.setUserAvatar(getContext(), username, holder.avatar);
    
   
    if(primaryColor != 0)
        holder.nameView.setTextColor(primaryColor);
    if(primarySize != 0)
        holder.nameView.setTextSize(TypedValue.COMPLEX_UNIT_PX, primarySize);
    if(initialLetterBg != null)
        holder.headerView.setBackgroundDrawable(initialLetterBg);
    if(initialLetterColor != 0)
        holder.headerView.setTextColor(initialLetterColor);
    
    return convertView;
}
 
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:51,代码来源:EaseContactAdapter.java

示例6: getView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.ease_row_chat_history, parent, false);
    }
    ViewHolder holder = (ViewHolder) convertView.getTag();
    if (holder == null) {
        holder = new ViewHolder();
        holder.name = (TextView) convertView.findViewById(R.id.name);
        holder.unreadLabel = (TextView) convertView.findViewById(R.id.unread_msg_number);
        holder.message = (TextView) convertView.findViewById(R.id.message);
        holder.time = (TextView) convertView.findViewById(R.id.time);
        holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
        holder.msgState = convertView.findViewById(R.id.msg_state);
        holder.list_itease_layout = (RelativeLayout) convertView.findViewById(R.id.list_itease_layout);
        convertView.setTag(holder);
    }
    holder.list_itease_layout.setBackgroundResource(R.drawable.ease_mm_listitem);

    // 获取与此用户/群组的会话
    EMConversation conversation = getItem(position);
    // 获取用户username或者群组groupid
    String username = conversation.getUserName();
    
    if (conversation.getType() == EMConversationType.GroupChat) {
        // 群聊消息,显示群聊头像
        holder.avatar.setImageResource(R.drawable.ease_group_icon);
        EMGroup group = EMClient.getInstance().groupManager().getGroup(username);
        holder.name.setText(group != null ? group.getGroupName() : username);
    } else if(conversation.getType() == EMConversationType.ChatRoom){
        holder.avatar.setImageResource(R.drawable.ease_group_icon);
        EMChatRoom room = EMClient.getInstance().chatroomManager().getChatRoom(username);
        holder.name.setText(room != null && !TextUtils.isEmpty(room.getName()) ? room.getName() : username);
    }else {
        EaseUserUtils.setUserAvatar(getContext(), username, holder.avatar);
        EaseUserUtils.setUserNick(username, holder.name);
    }

    if (conversation.getUnreadMsgCount() > 0) {
        // 显示与此用户的消息未读数
        holder.unreadLabel.setText(String.valueOf(conversation.getUnreadMsgCount()));
        holder.unreadLabel.setVisibility(View.VISIBLE);
    } else {
        holder.unreadLabel.setVisibility(View.INVISIBLE);
    }

    if (conversation.getAllMsgCount() != 0) {
        // 把最后一条消息的内容作为item的message内容
        EMMessage lastMessage = conversation.getLastMessage();
        holder.message.setText(EaseSmileUtils.getSmiledText(getContext(), EaseCommonUtils.getMessageDigest(lastMessage, (this.getContext()))),
                BufferType.SPANNABLE);

        holder.time.setText(DateUtils.getTimestampString(new Date(lastMessage.getMsgTime())));
        if (lastMessage.direct() == EMMessage.Direct.SEND && lastMessage.status() == EMMessage.Status.FAIL) {
            holder.msgState.setVisibility(View.VISIBLE);
        } else {
            holder.msgState.setVisibility(View.GONE);
        }
    }
    
    //设置自定义属性
    holder.name.setTextColor(primaryColor);
    holder.message.setTextColor(secondaryColor);
    holder.time.setTextColor(timeColor);
    if(primarySize != 0)
        holder.name.setTextSize(TypedValue.COMPLEX_UNIT_PX, primarySize);
    if(secondarySize != 0)
        holder.message.setTextSize(TypedValue.COMPLEX_UNIT_PX, secondarySize);
    if(timeSize != 0)
        holder.time.setTextSize(TypedValue.COMPLEX_UNIT_PX, timeSize);

    return convertView;
}
 
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:74,代码来源:EaseConversationAdapater.java

示例7: setUpBaseView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
private void setUpBaseView() {
        // 设置用户昵称头像,bubble背景等
        TextView timestamp = (TextView) findViewById(R.id.timestamp);
        if (timestamp != null) {
            if (position == 0) {
                timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
                timestamp.setVisibility(View.VISIBLE);
            } else {
                // 两条消息时间离得如果稍长,显示时间
                EMMessage prevMessage = (EMMessage) adapter.getItem(position - 1);
                if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) {
                    timestamp.setVisibility(View.GONE);
                } else {
                    timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
                    timestamp.setVisibility(View.VISIBLE);
                }
            }
        }
        //设置头像和nick
        if(message.direct() == Direct.SEND){
            EaseUserUtils.setUserAvatar(context, EMClient.getInstance().getCurrentUser(), userAvatarView);
            //发送方不显示nick
//            UserUtils.setUserNick(EMChatManager.getInstance().getCurrentUser(), usernickView);
        }else{
            EaseUserUtils.setUserAvatar(context, message.getFrom(), userAvatarView);
            EaseUserUtils.setUserNick(message.getFrom(), usernickView);
        }
        
        if(deliveredView != null){
            if (message.isDelivered()) {
                deliveredView.setVisibility(View.VISIBLE);
            } else {
                deliveredView.setVisibility(View.INVISIBLE);
            }
        }
        
        if(ackedView != null){
            if (message.isAcked()) {
                if (deliveredView != null) {
                    deliveredView.setVisibility(View.INVISIBLE);
                }
                ackedView.setVisibility(View.VISIBLE);
            } else {
                ackedView.setVisibility(View.INVISIBLE);
            }
        }
        

        if (adapter instanceof EaseMessageAdapter) {
            if (((EaseMessageAdapter) adapter).isShowAvatar())
                userAvatarView.setVisibility(View.VISIBLE);
            else
                userAvatarView.setVisibility(View.GONE);
            if (usernickView != null) {
                if (((EaseMessageAdapter) adapter).isShowUserNick())
                    usernickView.setVisibility(View.VISIBLE);
                else
                    usernickView.setVisibility(View.GONE);
            }
            if (message.direct() == Direct.SEND) {
                if (((EaseMessageAdapter) adapter).getMyBubbleBg() != null)
                    bubbleLayout.setBackgroundDrawable(((EaseMessageAdapter) adapter).getMyBubbleBg());
                // else
                // bubbleLayout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.chatto_bg));
            } else if (message.direct() == Direct.RECEIVE) {
                if (((EaseMessageAdapter) adapter).getOtherBuddleBg() != null)
                    bubbleLayout.setBackgroundDrawable(((EaseMessageAdapter) adapter).getOtherBuddleBg());
//                else
//                    bubbleLayout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.ease_chatfrom_bg));
            }
        }
    }
 
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:73,代码来源:EaseChatRow.java

示例8: getView

import com.hyphenate.easeui.utils.EaseUserUtils; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if(convertView == null){
        holder = new ViewHolder();
        if(res == 0)
            convertView = layoutInflater.inflate(R.layout.ease_row_contact, null);
        else
            convertView = layoutInflater.inflate(res, null);
        holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
        holder.nameView = (TextView) convertView.findViewById(R.id.name);
        holder.headerView = (TextView) convertView.findViewById(R.id.header);
        convertView.setTag(holder);
    }else{
        holder = (ViewHolder) convertView.getTag();
    }
    
    EaseUser user = getItem(position);
    if(user == null)
        Log.d("ContactAdapter", position + "");
    String username = user.getUsername();
    String header = user.getInitialLetter();
    
    if (position == 0 || header != null && !header.equals(getItem(position - 1).getInitialLetter())) {
        if (TextUtils.isEmpty(header)) {
            holder.headerView.setVisibility(View.GONE);
        } else {
            holder.headerView.setVisibility(View.VISIBLE);
            holder.headerView.setText(header);
        }
    } else {
        holder.headerView.setVisibility(View.GONE);
    }

    EaseUserUtils.setUserNick(username, holder.nameView);
    EaseUserUtils.setUserAvatar(getContext(), username, holder.avatar);
    
   
    if(primaryColor != 0)
        holder.nameView.setTextColor(primaryColor);
    if(primarySize != 0)
        holder.nameView.setTextSize(TypedValue.COMPLEX_UNIT_PX, primarySize);
    if(initialLetterBg != null)
        holder.headerView.setBackgroundDrawable(initialLetterBg);
    if(initialLetterColor != 0)
        holder.headerView.setTextColor(initialLetterColor);
    
    return convertView;
}
 
开发者ID:HyphenateInc,项目名称:Hyphenate-EaseUI-Android,代码行数:50,代码来源:EaseContactAdapter.java


注:本文中的com.hyphenate.easeui.utils.EaseUserUtils.setUserNick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。