• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EMConversationType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.easemob.chat.EMConversation.EMConversationType的典型用法代码示例。如果您正苦于以下问题:Java EMConversationType类的具体用法?Java EMConversationType怎么用?Java EMConversationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EMConversationType类属于com.easemob.chat.EMConversation包,在下文中一共展示了EMConversationType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getUnreadMsgCountTotal

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的package包/类
/**
 * 获取未读消息数
 * 
 * @return
 */
public int getUnreadMsgCountTotal() {
	int unreadMsgCountTotal = 0;
	int chatroomUnreadMsgCount = 0;
	unreadMsgCountTotal = EMChatManager.getInstance().getUnreadMsgsCount();
	for(EMConversation conversation:EMChatManager.getInstance().getAllConversations().values()){
		if(conversation.getType() == EMConversationType.ChatRoom)
		chatroomUnreadMsgCount=chatroomUnreadMsgCount+conversation.getUnreadMsgCount();
	}
	return unreadMsgCountTotal-chatroomUnreadMsgCount;
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:16,代码来源:MainActivity.java


示例2: setUpView

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的package包/类
@Override
protected void setUpView() {
    super.setUpView();
    // 注册上下文菜单
    registerForContextMenu(conversationListView);
    conversationListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EMConversation conversation = conversationListView.getItem(position);
            String username = conversation.getUserName();
            if (username.equals(EMChatManager.getInstance().getCurrentUser()))
                Toast.makeText(getActivity(), R.string.Cant_chat_with_yourself, 0).show();
            else {
                // 进入聊天页面
                Intent intent = new Intent(getActivity(), ChatActivity.class);
                if(conversation.isGroup()){
                    if(conversation.getType() == EMConversationType.ChatRoom){
                        // it's group chat
                        intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_CHATROOM);
                    }else{
                        intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_GROUP);
                    }
                    
                }
                // it's single chat
                intent.putExtra(Constant.EXTRA_USER_ID, username);
                startActivity(intent);
            }
        }
    });
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:33,代码来源:ConversationListFragment.java


示例3: getUnreadMsgCountTotal

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的package包/类
/**
 * 获取未读消息数
 *
 * @return
 */
public int getUnreadMsgCountTotal() {
    int unreadMsgCountTotal = 0;
    int chatroomUnreadMsgCount = 0;
    unreadMsgCountTotal = EMChatManager.getInstance().getUnreadMsgsCount();
    for (EMConversation conversation : EMChatManager.getInstance().getAllConversations().values()) {
        if (conversation.getType() == EMConversationType.ChatRoom)
            chatroomUnreadMsgCount = chatroomUnreadMsgCount + conversation.getUnreadMsgCount();
    }
    return unreadMsgCountTotal - chatroomUnreadMsgCount;
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:16,代码来源:MainActivity.java


示例4: setUpView

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的package包/类
@Override
protected void setUpView() {
    super.setUpView();
    // 注册上下文菜单
    registerForContextMenu(conversationListView);
    conversationListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EMConversation conversation = conversationListView.getItem(position);
            String username = conversation.getUserName();
            if (username.equals(EMChatManager.getInstance().getCurrentUser()))
                Toast.makeText(getActivity(), R.string.Cant_chat_with_yourself, 0).show();
            else {
                // 进入聊天页面
                Intent intent = new Intent(getActivity(), ChatActivity.class);
                if (conversation.isGroup()) {
                    if (conversation.getType() == EMConversationType.ChatRoom) {
                        // it's group chat
                        intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_CHATROOM);
                    } else {
                        intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_GROUP);
                    }

                }
                // it's single chat
                intent.putExtra(Constant.EXTRA_USER_ID, username);
                startActivity(intent);
            }
        }
    });
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:33,代码来源:ConversationListFragment.java


示例5: getView

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的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 = EMGroupManager.getInstance().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 = EMChatManager.getInstance().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.getMsgCount() != 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:huijimuhe,项目名称:monolog-android,代码行数:74,代码来源:EaseConversationAdapater.java


示例6: getView

import com.easemob.chat.EMConversation.EMConversationType; //导入依赖的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 = EMGroupManager.getInstance().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 = EMChatManager.getInstance().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.getMsgCount() != 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:nggirl,项目名称:EaseChatDemo,代码行数:74,代码来源:EaseConversationAdapater.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IWorkingCopyManager类代码示例发布时间:2022-05-22
下一篇:
Java SqlPersistenceComponent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap