本文整理汇总了Java中com.hyphenate.chat.EMTextMessageBody.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java EMTextMessageBody.getMessage方法的具体用法?Java EMTextMessageBody.getMessage怎么用?Java EMTextMessageBody.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hyphenate.chat.EMTextMessageBody
的用法示例。
在下文中一共展示了EMTextMessageBody.getMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import com.hyphenate.chat.EMTextMessageBody; //导入方法依赖的package包/类
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
Holder holder;
if(view ==null){
view = LayoutInflater.from(getActivity()).inflate(R.layout.item_msg,viewGroup,false);
holder = new Holder(view);
view.setTag(holder);
}else{
holder = (Holder) view.getTag();
}
EMConversation conversation = EMClient.getInstance().chatManager().getConversation(list.get(i));
EMMessage message = conversation.getLastMessage();
String msg = "";
if (message.getType().name().equals("TXT")) {
EMTextMessageBody body = (EMTextMessageBody) message.getBody();
msg = body.getMessage();
}
int count = conversation.getUnreadMsgCount();
if(count == 0){
holder.tvCount.setVisibility(View.GONE);
}else{
holder.tvCount.setVisibility(View.VISIBLE);
holder.tvCount.setText(count+"");
}
holder.tvName.setText(list.get(i));
holder.tvMsg.setText(msg);
holder.tvTime.setText(T.getTime(message.getMsgTime()));
return view;
}
示例2: getMessageDigest
import com.hyphenate.chat.EMTextMessageBody; //导入方法依赖的package包/类
/**
* Get digest according message type and content
*
* @param message
* @param context
* @return
*/
public static String getMessageDigest(EMMessage message, Context context) {
String digest = "";
switch (message.getType()) {
case LOCATION:
if (message.direct() == EMMessage.Direct.RECEIVE) {
digest = getString(context, R.string.location_recv);
digest = String.format(digest, message.getFrom());
return digest;
} else {
digest = getString(context, R.string.location_prefix);
}
break;
case IMAGE:
digest = getString(context, R.string.picture);
break;
case VOICE:
digest = getString(context, R.string.voice_prefix);
break;
case VIDEO:
digest = getString(context, R.string.video);
break;
case TXT:
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){
digest = getString(context, R.string.voice_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){
digest = getString(context, R.string.video_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
if(!TextUtils.isEmpty(txtBody.getMessage())){
digest = txtBody.getMessage();
}else{
digest = getString(context, R.string.dynamic_expression);
}
}else{
digest = txtBody.getMessage();
}
break;
case FILE:
digest = getString(context, R.string.file);
break;
default:
EMLog.e(TAG, "error, unknow type");
return "";
}
return digest;
}
示例3: getMessageDigest
import com.hyphenate.chat.EMTextMessageBody; //导入方法依赖的package包/类
/**
* 根据消息内容和消息类型获取消息内容提示
*
* @param message
* @param context
* @return
*/
public static String getMessageDigest(EMMessage message, Context context) {
String digest = "";
switch (message.getType()) {
case LOCATION: // 位置消息
if (message.direct() == EMMessage.Direct.RECEIVE) {
//从sdk中提到了ui中,使用更简单不犯错的获取string方法
// digest = EasyUtils.getAppResourceString(context, "location_recv");
digest = getString(context, R.string.location_recv);
digest = String.format(digest, message.getFrom());
return digest;
} else {
// digest = EasyUtils.getAppResourceString(context, "location_prefix");
digest = getString(context, R.string.location_prefix);
}
break;
case IMAGE: // 图片消息
digest = getString(context, R.string.picture);
break;
case VOICE:// 语音消息
digest = getString(context, R.string.voice_prefix);
break;
case VIDEO: // 视频消息
digest = getString(context, R.string.video);
break;
case TXT: // 文本消息
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
/*if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message)){
digest = ((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotMenuMessageDigest(message);
}else */if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){
digest = getString(context, R.string.voice_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){
digest = getString(context, R.string.video_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
if(!TextUtils.isEmpty(txtBody.getMessage())){
digest = txtBody.getMessage();
}else{
digest = getString(context, R.string.dynamic_expression);
}
}else{
digest = txtBody.getMessage();
}
break;
case FILE: //普通文件消息
digest = getString(context, R.string.file);
break;
default:
EMLog.e(TAG, "error, unknow type");
return "";
}
return digest;
}
示例4: getMessageDigest
import com.hyphenate.chat.EMTextMessageBody; //导入方法依赖的package包/类
/**
* 根据消息内容和消息类型获取消息内容提示
*
* @param message
* @param context
* @return
*/
public static String getMessageDigest(EMMessage message, Context context) {
String digest = "";
switch (message.getType()) {
case LOCATION: // 位置消息
if (message.direct() == EMMessage.Direct.RECEIVE) {
//从sdk中提到了ui中,使用更简单不犯错的获取string方法
// digest = EasyUtils.getAppResourceString(context, "location_recv");
digest = getString(context, R.string.location_recv);
digest = String.format(digest, message.getFrom());
return digest;
} else {
// digest = EasyUtils.getAppResourceString(context, "location_prefix");
digest = getString(context, R.string.location_prefix);
}
break;
case IMAGE: // 图片消息
digest = getString(context, R.string.picture);
break;
case VOICE:// 语音消息
digest = getString(context, R.string.voice_prefix);
break;
case VIDEO: // 视频消息
digest = getString(context, R.string.video);
break;
case TXT: // 文本消息
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
/*if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message)){
digest = ((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotMenuMessageDigest(message);
}else */if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){
digest = getString(context, R.string.voice_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
if(!TextUtils.isEmpty(txtBody.getMessage())){
digest = txtBody.getMessage();
}else{
digest = getString(context, R.string.dynamic_expression);
}
}else{
digest = txtBody.getMessage();
}
break;
case FILE: //普通文件消息
digest = getString(context, R.string.file);
break;
default:
EMLog.e(TAG, "error, unknow type");
return "";
}
return digest;
}