本文整理汇总了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;未经允许,请勿转载。 |
请发表评论