本文整理汇总了Java中com.hyphenate.chat.EMClient类的典型用法代码示例。如果您正苦于以下问题:Java EMClient类的具体用法?Java EMClient怎么用?Java EMClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMClient类属于com.hyphenate.chat包,在下文中一共展示了EMClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: destroyChatRoom
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* exit group
*
* @param
*/
private void destroyChatRoom() {
new Thread(new Runnable() {
public void run() {
try {
EMClient.getInstance().chatroomManager().destroyChatRoom(roomId);
runOnUiThread(new Runnable() {
public void run() {
progressDialog.dismiss();
setResult(RESULT_OK);
finish();
if (ChatActivity.activityInstance != null)
ChatActivity.activityInstance.finish();
}
});
} catch (final Exception e) {
runOnUiThread(new Runnable() {
public void run() {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "Failed to quit group: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
}).start();
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:31,代码来源:ChatRoomDetailsActivity.java
示例2: isAtMeMsg
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
public boolean isAtMeMsg(EMMessage message){
EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
if(user != null){
try {
JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
for(int i = 0; i < jsonArray.length(); i++){
String username = jsonArray.getString(i);
if(username.equals(EMClient.getInstance().getCurrentUser())){
return true;
}
}
} catch (Exception e) {
//perhaps is a @ all message
String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
if(atUsername != null){
if(atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
return true;
}
}
return false;
}
}
return false;
}
开发者ID:turoDog,项目名称:KTalk,代码行数:27,代码来源:EaseAtMessageHelper.java
示例3: onEnterToChatDetails
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
public void onEnterToChatDetails() {
if (chatType == Constant.CHATTYPE_GROUP) {
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if (group == null) {
Toast.makeText(getActivity(), R.string.gorup_not_found, Toast.LENGTH_SHORT).show();
return;
}
startActivityForResult(
(new Intent(getActivity(), GroupDetailsActivity.class).putExtra("groupId", toChatUsername)),
REQUEST_CODE_GROUP_DETAIL
);
} else if (chatType == Constant.CHATTYPE_CHATROOM) {
startActivityForResult(new Intent(getActivity(), ChatRoomDetailsActivity.class).putExtra("roomId", toChatUsername), REQUEST_CODE_GROUP_DETAIL);
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:17,代码来源:ChatFragment.java
示例4: onDestroy
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
if (groupListener != null) {
EMClient.getInstance().groupManager().removeGroupChangeListener(groupListener);
}
if (chatRoomListener != null) {
EMClient.getInstance().chatroomManager().removeChatRoomListener(chatRoomListener);
}
if(chatType == EaseConstant.CHATTYPE_CHATROOM){
EMClient.getInstance().chatroomManager().leaveChatRoom(toChatUsername);
}
}
开发者ID:turoDog,项目名称:KTalk,代码行数:17,代码来源:EaseChatFragment.java
示例5: inputAtUsername
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* input @
* @param username
*/
protected void inputAtUsername(String username, boolean autoAddAtSymbol){
if(EMClient.getInstance().getCurrentUser().equals(username) ||
chatType != EaseConstant.CHATTYPE_GROUP){
return;
}
EaseAtMessageHelper.get().addAtUser(username);
EaseUser user = EaseUserUtils.getUserInfo(username);
if (user != null){
username = user.getNick();
}
if(autoAddAtSymbol)
inputMenu.insertText("@" + username + " ");
else
inputMenu.insertText(username + " ");
}
开发者ID:turoDog,项目名称:KTalk,代码行数:20,代码来源:EaseChatFragment.java
示例6: sendAtMessage
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* send @ message, only support group chat message
* @param content
*/
@SuppressWarnings("ConstantConditions")
private void sendAtMessage(String content){
if(chatType != EaseConstant.CHATTYPE_GROUP){
EMLog.e(TAG, "only support group chat message");
return;
}
EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if(EMClient.getInstance().getCurrentUser().equals(group.getOwner()) && EaseAtMessageHelper.get().containsAtAll(content)){
message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL);
}else {
message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG,
EaseAtMessageHelper.get().atListToJsonArray(EaseAtMessageHelper.get().getAtMessageUsernames(content)));
}
sendMessage(message);
}
开发者ID:turoDog,项目名称:KTalk,代码行数:22,代码来源:EaseChatFragment.java
示例7: sendMessage
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
protected void sendMessage(EMMessage message){
if (message == null) {
return;
}
if(chatFragmentHelper != null){
//set extension
chatFragmentHelper.onSetMessageAttributes(message);
}
if (chatType == EaseConstant.CHATTYPE_GROUP){
message.setChatType(ChatType.GroupChat);
}else if(chatType == EaseConstant.CHATTYPE_CHATROOM){
message.setChatType(ChatType.ChatRoom);
}
//send message
EMClient.getInstance().chatManager().sendMessage(message);
//refresh ui
if(isMessageListInited) {
messageList.refreshSelectLast();
}
}
开发者ID:turoDog,项目名称:KTalk,代码行数:21,代码来源:EaseChatFragment.java
示例8: onSetUpView
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
protected void onSetUpView() {
String currentUser = EMClient.getInstance().getCurrentUser();
String fromUser = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_NAME, "");//红包发送者
String toUser = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_RECEIVER_NAME, "");//红包接收者
String senderId;
if (message.direct() == EMMessage.Direct.SEND) {
if (message.getChatType().equals(EMMessage.ChatType.GroupChat)) {
senderId = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_ID, "");
if (senderId.equals(currentUser)) {
mTvMessage.setText(R.string.msg_take_red_packet);
} else {
mTvMessage.setText(String.format(getResources().getString(R.string.msg_take_someone_red_packet), fromUser));
}
} else {
mTvMessage.setText(String.format(getResources().getString(R.string.msg_take_someone_red_packet), fromUser));
}
} else {
mTvMessage.setText(String.format(getResources().getString(R.string.msg_someone_take_red_packet), toUser));
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:22,代码来源:ChatRowRedPacketAck.java
示例9: onBubbleClick
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
String filePath = fileMessageBody.getLocalUrl();
File file = new File(filePath);
if (file.exists()) {
// open files if it exist
FileUtils.openFile(file, (Activity) context);
} else {
// download the file
context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msg", message));
}
if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (HyphenateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:22,代码来源:EaseChatRowFile.java
示例10: init
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
protected void init() {
super.init();
mChatPresenter = new ChatPresenterImpl(this);
mBack.setVisibility(View.VISIBLE);
mUserName = getIntent().getStringExtra(Constant.Extra.USER_NAME);
String title = String.format(getString(R.string.chat_with), mUserName);
mTitle.setText(title);
mEdit.setOnEditorActionListener(mOnEditorActionListener);
mEdit.addTextChangedListener(mTextWatcher);
initRecyclerView();
//当新消息来临监听
EMClient.getInstance().chatManager().addMessageListener(mEMMessageListener);
mChatPresenter.loadMessages(mUserName);
dialog = createLoadingDialog(this);
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:18,代码来源:ChatActivity.java
示例11: startGetContactList
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* 获取联系人列表数据
* @throws HyphenateException
*/
private void startGetContactList() throws HyphenateException {
List<String> contacts = EMClient.getInstance().contactManager().getAllContactsFromServer();
DatabaseManager.getInstance().deleteAllContacts();
if (!contacts.isEmpty()) {
for (int i = 0; i < contacts.size(); i++) {
ContactListItem item = new ContactListItem();
item.userName = contacts.get(i);
if (itemInSameGroup(i, item)) {
item.showFirstLetter = false;
}
mContactListItems.add(item);
saveContactToDatabase(item.userName);
}
}
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:20,代码来源:ContactPresenterImpl.java
示例12: searchMessages
import com.hyphenate.chat.EMClient; //导入依赖的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();
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:20,代码来源:GroupSearchMessageActivity.java
示例13: init
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* init widget
* @param toChatUsername
* @param chatType
* @param customChatRowProvider
*/
public void init(String toChatUsername, int chatType, EaseCustomChatRowProvider customChatRowProvider) {
this.chatType = chatType;
this.toChatUsername = toChatUsername;
conversation = EMClient.getInstance().chatManager().getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true);
messageAdapter = new EaseMessageAdapter(context, toChatUsername, chatType, listView);
messageAdapter.setShowAvatar(showAvatar);
messageAdapter.setShowUserNick(showUserNick);
messageAdapter.setMyBubbleBg(myBubbleBg);
messageAdapter.setOtherBuddleBg(otherBuddleBg);
messageAdapter.setCustomChatRowProvider(customChatRowProvider);
// set message adapter
listView.setAdapter(messageAdapter);
refreshSelectLast();
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:23,代码来源:EaseChatMessageList.java
示例14: toGroupDetails
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* open group detail
*/
protected void toGroupDetails() {
if (chatType == EaseConstant.CHATTYPE_GROUP) {
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if (group == null) {
Toast.makeText(getActivity(), R.string.gorup_not_found, Toast.LENGTH_SHORT).show();
return;
}
if (chatFragmentHelper != null) {
chatFragmentHelper.onEnterToChatDetails();
}
} else if (chatType == EaseConstant.CHATTYPE_CHATROOM) {
if (chatFragmentHelper != null) {
chatFragmentHelper.onEnterToChatDetails();
}
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:20,代码来源:EaseChatFragment.java
示例15: inputAtUsername
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* input @
*
* @param username
*/
protected void inputAtUsername(String username, boolean autoAddAtSymbol) {
if (EMClient.getInstance().getCurrentUser().equals(username) ||
chatType != EaseConstant.CHATTYPE_GROUP) {
return;
}
EaseAtMessageHelper.get().addAtUser(username);
EaseUser user = EaseUserUtils.getUserInfo(username);
if (user != null) {
username = user.getNick();
}
if (autoAddAtSymbol)
inputMenu.insertText("@" + username + " ");
else
inputMenu.insertText(username + " ");
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:21,代码来源:EaseChatFragment.java
示例16: refresh
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* refresh ui
*/
public void refresh() {
if (!handler.hasMessages(MSG_REFRESH)) {
handler.sendEmptyMessage(MSG_REFRESH);
}
if (inviteMessgeDao == null) {
inviteMessgeDao = new InviteMessgeDao(getActivity());
}
if (null != applicationItem) {
if (inviteMessgeDao.getUnreadMessagesCount() > 0) {
applicationItem.showUnreadMsgView();
} else {
applicationItem.hideUnreadMsgView();
}
}
try {
int count = EMClient.getInstance().chatManager().getUnreadMsgsCount();
((MainActivity) getActivity()).showNoReadCount(count);
} catch (Exception e) {
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:27,代码来源:EaseConversationListFragment.java
示例17: toGroupDetails
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
/**
* open group detail
*
*/
protected void toGroupDetails() {
if (chatType == EaseConstant.CHATTYPE_GROUP) {
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if (group == null) {
Toast.makeText(getActivity(), R.string.gorup_not_found, Toast.LENGTH_SHORT).show();
return;
}
if(chatFragmentHelper != null){
chatFragmentHelper.onEnterToChatDetails();
}
}else if(chatType == EaseConstant.CHATTYPE_CHATROOM){
if(chatFragmentHelper != null){
chatFragmentHelper.onEnterToChatDetails();
}
}
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:21,代码来源:EaseChatFragment.java
示例18: showAnnouncementDialog
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
private void showAnnouncementDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.group_announcement);
if (room.getOwner().equals(EMClient.getInstance().getCurrentUser()) ||
room.getAdminList().contains(EMClient.getInstance().getCurrentUser())) {
final EditText et = new EditText(ChatRoomDetailsActivity.this);
et.setText(room.getAnnouncement());
builder.setView(et);
builder.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String text = et.getText().toString();
if (!text.equals(room.getAnnouncement())) {
dialog.dismiss();
updateAnnouncement(text);
}
}
});
} else {
builder.setMessage(room.getAnnouncement());
builder.setPositiveButton(R.string.ok, null);
}
builder.show();
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:26,代码来源:ChatRoomDetailsActivity.java
示例19: onConversationInit
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
protected void onConversationInit() {
conversation = EMClient.getInstance().chatManager().getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true);
conversation.markAllMessagesAsRead();
// the number of messages loaded into conversation is getChatOptions().getNumberOfMessagesLoaded
// you can change this number
final List<EMMessage> msgs = conversation.getAllMessages();
int msgCount = msgs != null ? msgs.size() : 0;
if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) {
String msgId = null;
if (msgs != null && msgs.size() > 0) {
msgId = msgs.get(0).getMsgId();
}
conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount);
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:17,代码来源:EaseChatFragment.java
示例20: onBubbleClick
import com.hyphenate.chat.EMClient; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
EMLog.d(TAG, "video view is on click");
Intent intent = new Intent(context, EaseShowVideoActivity.class);
intent.putExtra("msg", message);
if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked()
&& message.getChatType() == ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (Exception e) {
e.printStackTrace();
}
}
activity.startActivity(intent);
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:17,代码来源:EaseChatRowVideo.java
注:本文中的com.hyphenate.chat.EMClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论