本文整理汇总了Java中com.hyphenate.chat.EMTextMessageBody类的典型用法代码示例。如果您正苦于以下问题:Java EMTextMessageBody类的具体用法?Java EMTextMessageBody怎么用?Java EMTextMessageBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMTextMessageBody类属于com.hyphenate.chat包,在下文中一共展示了EMTextMessageBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showNotification
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
private void showNotification(EMMessage emMessage) {
String contentText = "";
if (emMessage.getBody() instanceof EMTextMessageBody) {
contentText = ((EMTextMessageBody) emMessage.getBody()).getMessage();
}
Intent chat = new Intent(this, ChatActivity.class);
chat.putExtra(Constant.Extra.USER_NAME, emMessage.getUserName());
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, chat, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification.Builder(this)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.avatar1))
.setSmallIcon(R.mipmap.ic_contact_selected_2)
.setContentTitle(getString(R.string.receive_new_message))
.setContentText(contentText)
.setPriority(Notification.PRIORITY_MAX)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build();
notificationManager.notify(1, notification);
}
示例2: onBubbleClick
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
// TODO Auto-generated method stub
if (null != mBack) {
if (!StringUtils.isNotEmpty(message.getStringAttribute("groupRedPacket", null))) {
if (message.direct() == EMMessage.Direct.SEND) {
return;
}
}
// mBack.back(message.getIntAttribute("redPacketID",0),false,message);
mBack.back(message.getIntAttribute("redPacketID", 0), true, message.getStringAttribute("transfer", ""), ((EMTextMessageBody) message.getBody()).getMessage(),
message.getStringAttribute("name", ""), message.getFrom()
);
}
}
示例3: onRequestToJoinAccepted
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public void onRequestToJoinAccepted(String groupId, String groupName, String accepter) {
String st4 = appContext.getString(R.string.Agreed_to_your_group_chat_application);
// your application was accepted
EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
msg.setChatType(ChatType.GroupChat);
msg.setFrom(accepter);
msg.setTo(groupId);
msg.setMsgId(UUID.randomUUID().toString());
msg.addBody(new EMTextMessageBody(accepter + " " + st4));
msg.setStatus(Status.SUCCESS);
// save accept message
EMClient.getInstance().chatManager().saveMessage(msg);
// notify the accept message
getNotifier().vibrateAndPlayTone(msg);
broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
示例4: onAutoAcceptInvitationFromGroup
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public void onAutoAcceptInvitationFromGroup(String groupId, String inviter, String inviteMessage) {
// got an invitation
String st3 = appContext.getString(R.string.Invite_you_to_join_a_group_chat);
EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
msg.setChatType(ChatType.GroupChat);
msg.setFrom(inviter);
msg.setTo(groupId);
msg.setMsgId(UUID.randomUUID().toString());
msg.addBody(new EMTextMessageBody(inviter + " " + st3));
msg.setStatus(EMMessage.Status.SUCCESS);
// save invitation as messages
EMClient.getInstance().chatManager().saveMessage(msg);
// notify invitation message
getNotifier().vibrateAndPlayTone(msg);
EMLog.d(TAG, "onAutoAcceptInvitationFromGroup groupId:" + groupId);
broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
示例5: onApplicationAccept
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {
String st4 = appContext.getString(R.string.Agreed_to_your_group_chat_application);
// your application was accepted
EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
msg.setChatType(ChatType.GroupChat);
msg.setFrom(accepter);
msg.setTo(groupId);
msg.setMsgId(UUID.randomUUID().toString());
msg.addBody(new EMTextMessageBody(accepter + " " +st4));
msg.setStatus(Status.SUCCESS);
// save accept message
EMClient.getInstance().chatManager().saveMessage(msg);
// notify the accept message
getNotifier().vibrateAndPlayTone(msg);
broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
示例6: onAutoAcceptInvitationFromGroup
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public void onAutoAcceptInvitationFromGroup(String groupId, String inviter, String inviteMessage) {
// got an invitation
String st3 = appContext.getString(R.string.Invite_you_to_join_a_group_chat);
EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
msg.setChatType(ChatType.GroupChat);
msg.setFrom(inviter);
msg.setTo(groupId);
msg.setMsgId(UUID.randomUUID().toString());
msg.addBody(new EMTextMessageBody(inviter + " " +st3));
msg.setStatus(EMMessage.Status.SUCCESS);
// save invitation as messages
EMClient.getInstance().chatManager().saveMessage(msg);
// notify invitation message
getNotifier().vibrateAndPlayTone(msg);
EMLog.d(TAG, "onAutoAcceptInvitationFromGroup groupId:" + groupId);
broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
示例7: getView
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.em_row_search_message, parent, false);
}
ViewHolder holder = (ViewHolder) convertView.getTag();
if (holder == null) {
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.name);
holder.message = (TextView) convertView.findViewById(R.id.message);
holder.time = (TextView) convertView.findViewById(R.id.time);
holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
convertView.setTag(holder);
}
EMMessage message = getItem(position);
EaseUserUtils.setUserNick(message.getFrom(), holder.name);
EaseUserUtils.setUserAvatar(getContext(), message.getFrom(), holder.avatar);
holder.time.setText(DateUtils.getTimestampString(new Date(message.getMsgTime())));
holder.message.setText(((EMTextMessageBody)message.getBody()).getMessage());
return convertView;
}
示例8: forwardMessage
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例9: onSetUpView
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
@Override
public void onSetUpView() {
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
// 设置内容
contentView.setText(span, BufferType.SPANNABLE);
handleTextMessage();
}
示例10: forwardMessage
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例11: forwardMessage
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例12: updateMessageBody
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
private void updateMessageBody(EMMessage emMessage) {
EMMessageBody body = emMessage.getBody();
if (body instanceof EMTextMessageBody) {
mSendMessage.setText(((EMTextMessageBody) body).getMessage());
} else {
mSendMessage.setText(getContext().getString(R.string.no_text_message));
}
}
示例13: updateLastMessage
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
private void updateLastMessage(EMConversation emConversation) {
EMMessage emMessage = emConversation.getLastMessage();
if (emMessage.getBody() instanceof EMTextMessageBody) {
mLastMessage.setText(((EMTextMessageBody) emMessage.getBody()).getMessage());
} else {
mLastMessage.setText(getContext().getString(R.string.no_text_message));
}
mTimestamp.setText(DateUtils.getTimestampString(new Date(emMessage.getMsgTime())));
}
示例14: updateMessageBody
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
private void updateMessageBody(EMMessage emMessage) {
EMMessageBody body = emMessage.getBody();
if (body instanceof EMTextMessageBody) {
mReceiveMessage.setText(((EMTextMessageBody) body).getMessage());
} else {
mReceiveMessage.setText(getContext().getString(R.string.no_text_message));
}
}
示例15: forwardMessage
import com.hyphenate.chat.EMTextMessageBody; //导入依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if (forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
} else {
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if (forward_msg.getChatType() == ChatType.ChatRoom) {
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}