本文整理汇总了Java中com.hyphenate.chat.EMConversation类的典型用法代码示例。如果您正苦于以下问题:Java EMConversation类的具体用法?Java EMConversation怎么用?Java EMConversation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMConversation类属于com.hyphenate.chat包,在下文中一共展示了EMConversation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* sort conversations according time stamp of last message
*
* @param conversationList
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first.equals(con2.first)) {
return 0;
} else if (con2.first.longValue() > con1.first.longValue()) {
return 1;
} else {
return -1;
}
}
});
}
示例2: getAllUnReadMessageNum
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
private void getAllUnReadMessageNum(){
int total = 0;
if(mConversationList != null){
for (int i = 0; i < mConversationList.size(); i++) {
EMConversation conversation = mConversationList.get(i);
int unreadMsgCount = conversation.getUnreadMsgCount();
total = total + unreadMsgCount;
}
}
UserSharedPreferences.putUnReadMessage(getContext(),total);
Intent unreadIntent = new Intent();
unreadIntent.setAction(ACTION_REFRESH_UNREAD_MSG);
getContext().sendBroadcast(unreadIntent);
}
示例3: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first.equals(con2.first)) {
return 0;
} else if (con2.first.longValue() > con1.first.longValue()) {
return 1;
} else {
return -1;
}
}
});
}
示例4: loadAllConversations
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
public void loadAllConversations() {
ThreadUtils.runOnBackgroundThread(new Runnable() {
@Override
public void run() {
Map<String, EMConversation> conversations = EMClient.getInstance().chatManager().getAllConversations();
mEMConversations.clear();
mEMConversations.addAll(conversations.values());
//根据最后一条消息的时间进行排序
Collections.sort(mEMConversations, new Comparator<EMConversation>() {
@Override
public int compare(EMConversation o1, EMConversation o2) {
return (int) (o2.getLastMessage().getMsgTime() - o1.getLastMessage().getMsgTime());
}
});
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
mConversationView.onAllConversationsLoaded();
}
});
}
});
}
示例5: loadMessages
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
public void loadMessages(final String userName) {
ThreadUtils.runOnBackgroundThread(new Runnable() {
@Override
public void run() {
EMConversation conversation = EMClient.getInstance().chatManager().getConversation(userName);
if (conversation != null) {
//获取此会话的所有消息
List<EMMessage> messages = conversation.getAllMessages();
mEMMessageList.addAll(messages);
//指定会话消息未读数清零
conversation.markAllMessagesAsRead();
}
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
mChatView.onMessagesLoaded();
}
});
}
});
}
示例6: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* sort conversations according time stamp of last message
*
* @param conversationList
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first.equals(con2.first)) {
return 0;
} else if (con2.first.longValue() > con1.first.longValue()) {
return 1;
} else {
return -1;
}
}
});
}
示例7: searchMessages
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
private void searchMessages(){
pd = new ProgressDialog(this);
pd.setMessage(getString(R.string.searching));
pd.setCanceledOnTouchOutside(false);
pd.show();
new Thread(new Runnable() {
public void run() {
EMConversation conversation = EMClient.getInstance().chatManager().getConversation(groupId);
List<EMMessage> resultList = conversation.searchMsgFromDB(query.getText().toString(), System.currentTimeMillis(), 50, null, EMSearchDirection.UP);
if(messageList == null){
messageList = resultList;
}else{
messageList.clear();
messageList.addAll(resultList);
}
onSearchResulted();
}
}).start();
}
示例8: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*
* @param usernames
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first == con2.first) {
return 0;
} else if (con2.first > con1.first) {
return 1;
} else {
return -1;
}
}
});
}
示例9: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* sort conversations according time stamp of last message
*
* @param conversationList
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first == con2.first) {
return 0;
} else if (con2.first > con1.first) {
return 1;
} else {
return -1;
}
}
});
}
示例10: onContextItemSelected
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
boolean deleteMessage = false;
if (item.getItemId() == R.id.delete_message) {
deleteMessage = true;
} else if (item.getItemId() == R.id.delete_conversation) {
deleteMessage = false;
}
EMConversation tobeDeleteCons = conversationListView.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
if (tobeDeleteCons == null) {
return true;
}
try {
// delete conversation
EMClient.getInstance().chatManager().deleteConversation(tobeDeleteCons.getUserName(), deleteMessage);
InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
inviteMessgeDao.deleteMessage(tobeDeleteCons.getUserName());
} catch (Exception e) {
e.printStackTrace();
}
refresh();
// update unread count
((MainActivity) getActivity()).updateUnreadLabel();
return true;
}
示例11: sortConversationByLastChatTime
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*
* @param
*/
private void sortConversationByLastChatTime(List<Pair<Long, EMConversation>> conversationList) {
Collections.sort(conversationList, new Comparator<Pair<Long, EMConversation>>() {
@Override
public int compare(final Pair<Long, EMConversation> con1, final Pair<Long, EMConversation> con2) {
if (con1.first == con2.first) {
return 0;
} else if (con2.first > con1.first) {
return 1;
} else {
return -1;
}
}
});
}
示例12: onCreate
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.activity_main);
unreadLabel = (TextView) findViewById(R.id.unread_msg_number);
mTabs = new Button[3];
mTabs[0] = (Button) findViewById(R.id.btn_conversation);
mTabs[1] = (Button) findViewById(R.id.btn_address_list);
mTabs[2] = (Button) findViewById(R.id.btn_setting);
// set first tab as selected
mTabs[0].setSelected(true);
conversationListFragment = new EaseConversationListFragment();
contactListFragment = new EaseContactListFragment();
settingFragment = new SettingsFragment();
contactListFragment.setContactsMap(getContacts());
conversationListFragment.setConversationListItemClickListener(new EaseConversationListItemClickListener() {
@Override
public void onListItemClicked(EMConversation conversation) {
startActivity(new Intent(MainActivity.this, ChatActivity.class).putExtra(EaseConstant.EXTRA_USER_ID, conversation.getUserName()));
}
});
contactListFragment.setContactListItemClickListener(new EaseContactListItemClickListener() {
@Override
public void onListItemClicked(EaseUser user) {
startActivity(new Intent(MainActivity.this, ChatActivity.class).putExtra(EaseConstant.EXTRA_USER_ID, user.getUsername()));
}
});
fragments = new Fragment[] { conversationListFragment, contactListFragment, settingFragment };
// add and show first fragment
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, conversationListFragment)
.add(R.id.fragment_container, contactListFragment).hide(contactListFragment).show(conversationListFragment)
.commit();
}
示例13: EaseConversationAdapter
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
public EaseConversationAdapter(Context context, int resource,
List<EMConversation> objects) {
super(context, resource, objects);
conversationList = objects;
copyConversationList = new ArrayList<EMConversation>();
copyConversationList.addAll(objects);
}
示例14: getItem
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
public EMConversation getItem(int arg0) {
if (arg0 < conversationList.size()) {
return conversationList.get(arg0);
}
return null;
}
示例15: publishResults
import com.hyphenate.chat.EMConversation; //导入依赖的package包/类
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
conversationList.clear();
if (results.values != null) {
conversationList.addAll((List<EMConversation>) results.values);
}
if (results.count > 0) {
notiyfyByFilter = true;
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}