本文整理汇总了Java中com.easemob.chat.EMContact类的典型用法代码示例。如果您正苦于以下问题:Java EMContact类的具体用法?Java EMContact怎么用?Java EMContact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMContact类属于com.easemob.chat包,在下文中一共展示了EMContact类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onContextItemSelected
import com.easemob.chat.EMContact; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getItemId() == R.id.delete_message) {
EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
boolean isGroup = false;
if(tobeDeleteUser instanceof EMGroup)
isGroup = true;
// 删除此会话
EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(),isGroup);
InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
adapter.remove(tobeDeleteUser);
adapter.notifyDataSetChanged();
// 更新消息未读数
((MainActivity) getActivity()).updateUnreadLabel();
return true;
}
return super.onContextItemSelected(item);
}
开发者ID:macyuan,项目名称:TAG,代码行数:22,代码来源:ChatHistoryFragment.java
示例2: sortUserByLastChatTime
import com.easemob.chat.EMContact; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*
* @param usernames
*/
private void sortUserByLastChatTime(List<EMContact> contactList) {
Collections.sort(contactList, new Comparator<EMContact>() {
@Override
public int compare(final EMContact user1, final EMContact user2) {
EMConversation conversation1 = EMChatManager.getInstance().getConversation(user1.getUsername());
EMConversation conversation2 = EMChatManager.getInstance().getConversation(user2.getUsername());
EMMessage user2LastMessage = conversation2.getLastMessage();
EMMessage user1LastMessage = conversation1.getLastMessage();
if (user2LastMessage.getMsgTime() == user1LastMessage.getMsgTime()) {
return 0;
} else if (user2LastMessage.getMsgTime() > user1LastMessage.getMsgTime()) {
return 1;
} else {
return -1;
}
}
});
}
开发者ID:macyuan,项目名称:TAG,代码行数:26,代码来源:ChatHistoryFragment.java
示例3: asyncGetRobotNamesFromServer
import com.easemob.chat.EMContact; //导入依赖的package包/类
private void asyncGetRobotNamesFromServer(final EMValueCallBack<List<EMContact>> callback) {
new Thread(new Runnable() {
@Override
public void run() {
try {
List<EMContact> mList = EMChatManager.getInstance().getRobotsFromServer();
callback.onSuccess(mList);
} catch (EaseMobException e) {
e.printStackTrace();
callback.onError(e.getErrorCode(), e.toString());
}
}
}).start();
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:16,代码来源:RobotsActivity.java
示例4: asyncGetRobotNamesFromServer
import com.easemob.chat.EMContact; //导入依赖的package包/类
private void asyncGetRobotNamesFromServer(final EMValueCallBack<List<EMContact>> callback) {
new Thread(new Runnable() {
@Override
public void run() {
try {
List<EMContact> mList = EMChatManager.getInstance().getRobotsFromServer();
callback.onSuccess(mList);
} catch (EaseMobException e) {
e.printStackTrace();
callback.onError(e.getErrorCode(), e.toString());
}
}
}).start();
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:16,代码来源:RobotsActivity.java
示例5: ChatHistoryAdapter
import com.easemob.chat.EMContact; //导入依赖的package包/类
public ChatHistoryAdapter(Context context, int textViewResourceId, List<EMContact> objects) {
super(context, textViewResourceId, objects);
inflater = LayoutInflater.from(context);
}
开发者ID:macyuan,项目名称:TAG,代码行数:5,代码来源:ChatHistoryAdapter.java
示例6: getView
import com.easemob.chat.EMContact; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.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_item_layout=(RelativeLayout) convertView.findViewById(R.id.list_item_layout);
convertView.setTag(holder);
}
if(position%2==0)
{
holder.list_item_layout.setBackgroundResource(R.drawable.mm_listitem);
}else{
holder.list_item_layout.setBackgroundResource(R.drawable.mm_listitem_grey);
}
EMContact user = getItem(position);
if(user instanceof EMGroup){
//群聊消息,显示群聊头像
holder.avatar.setImageResource(R.drawable.group_icon);
}else{
holder.avatar.setImageResource(R.drawable.default_avatar);
}
String username = user.getUsername();
// 获取与此用户/群组的会话
EMConversation conversation = EMChatManager.getInstance().getConversation(username);
holder.name.setText(user.getNick() != null ? user.getNick() : username);
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(SmileUtils.getSmiledText(getContext(), 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);
}
}
return convertView;
}
开发者ID:macyuan,项目名称:TAG,代码行数:62,代码来源:ChatHistoryAdapter.java
示例7: getRobotNamesFromServer
import com.easemob.chat.EMContact; //导入依赖的package包/类
private void getRobotNamesFromServer() {
asyncGetRobotNamesFromServer(new EMValueCallBack<List<EMContact>>() {
@Override
public void onSuccess(final List<EMContact> value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setRefreshing(false);
Map<String, RobotUser> mMap = new HashMap<String, RobotUser>();
for (EMContact item : value) {
RobotUser user = new RobotUser(item.getUsername());
user.setNick(item.getNick());
user.setInitialLetter("#");
mMap.put(item.getUsername(), user);
}
robotList.clear();
robotList.addAll(mMap.values());
// 存入内存
DemoHelper.getInstance().setRobotList(mMap);
// 存入db
UserDao dao = new UserDao(RobotsActivity.this);
dao.saveRobotUser(robotList);
adapter.notifyDataSetChanged();
}
});
}
@Override
public void onError(int error, String errorMsg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(false);
progressBar.setVisibility(View.GONE);
}
});
}
});
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:42,代码来源:RobotsActivity.java
示例8: getView
import com.easemob.chat.EMContact; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.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 = (CircleImageView) convertView.findViewById(R.id.avatar);
holder.msgState = convertView.findViewById(R.id.msg_state);
holder.list_item_layout = (RelativeLayout) convertView.findViewById(R.id.list_item_layout);
convertView.setTag(holder);
}
if (position % 2 == 0) {
holder.list_item_layout.setBackgroundResource(R.drawable.mm_listitem);
} else {
holder.list_item_layout.setBackgroundResource(R.drawable.mm_listitem_grey);
}
// 获取与此用户/群组的会话
EMConversation conversation = getItem(position);
// 获取用户username或者群组groupid
String username = conversation.getUserName();
Log.i("tag", "username=="+username);
List<EMGroup> groups = EMGroupManager.getInstance().getAllGroups();
EMContact contact = null;
boolean isGroup = false;
for (EMGroup group : groups) {
if (group.getGroupId().equals(username)) {
isGroup = true;
contact = group;
break;
}
}
if (isGroup) {
// 群聊消息,显示群聊头像
holder.avatar.setImageResource(R.drawable.group_icon);
holder.name.setText(contact.getNick() != null ? contact.getNick() : username);
} else {
// UserUtils.setUserAvatar(getContext(), username, holder.avatar);
// if (username.equals(Constants.GROUP_USERNAME)) {
// holder.name.setText("群聊");
//
// } else if (username.equals(Constants.NEW_FRIENDS_USERNAME)) {
// holder.name.setText("申请与通知");
// }
// holder.name.setText(username);
}
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(SmileUtils.getSmiledText(getContext(), 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);
}
}
return convertView;
}
开发者ID:Owater,项目名称:school_shop,代码行数:78,代码来源:ChatAllHistoryAdapter.java
示例9: getRobotNamesFromServer
import com.easemob.chat.EMContact; //导入依赖的package包/类
private void getRobotNamesFromServer() {
asyncGetRobotNamesFromServer(new EMValueCallBack<List<EMContact>>() {
@Override
public void onSuccess(final List<EMContact> value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setRefreshing(false);
Map<String, RobotUser> mMap = new HashMap<String, RobotUser>();
for (EMContact item : value) {
RobotUser user = new RobotUser();
user.setUsername(item.getUsername());
user.setNick(item.getNick());
user.setHeader("#");
mMap.put(item.getUsername(), user);
}
robotList.clear();
robotList.addAll(mMap.values());
// 存入内存
((DemoHXSDKHelper) HXSDKHelper.getInstance()).setRobotList(mMap);
// 存入db
UserDao dao = new UserDao(RobotsActivity.this);
dao.saveRobotUser(robotList);
adapter.notifyDataSetChanged();
}
});
}
@Override
public void onError(int error, String errorMsg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(false);
progressBar.setVisibility(View.GONE);
}
});
}
});
}
开发者ID:chenjunqian,项目名称:here,代码行数:43,代码来源:RobotsActivity.java
示例10: getRobotNamesFromServer
import com.easemob.chat.EMContact; //导入依赖的package包/类
private void getRobotNamesFromServer() {
asyncGetRobotNamesFromServer(new EMValueCallBack<List<EMContact>>() {
@Override
public void onSuccess(final List<EMContact> value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setRefreshing(false);
Map<String, RobotUser> mMap = new HashMap<String, RobotUser>();
for (EMContact item : value) {
RobotUser user = new RobotUser(item.getUsername());
user.setNick(item.getNick());
user.setInitialLetter("#");
mMap.put(item.getUsername(), user);
}
robotList.clear();
robotList.addAll(mMap.values());
// 存入内存
DemoHelper.getInstance().setRobotList(mMap);
// 存入db
UserDao dao = new UserDao(RobotsActivity.this);
dao.saveRobotUser(robotList);
adapter.notifyDataSetChanged();
}
});
}
@Override
public void onError(int error, String errorMsg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(false);
progressBar.setVisibility(View.GONE);
}
});
}
});
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:42,代码来源:RobotsActivity.java
注:本文中的com.easemob.chat.EMContact类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论