• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.easemob.chat.EMMessage.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Type类属于com.easemob.chat.EMMessage包,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onApplicationAccept

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {
	//加群申请被同意
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(accepter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(accepter + "同意了你的群聊申请"));
	// 保存同意消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity_0903.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:MainActivity_0903.java


示例2: onApplicationAccept

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {
	//加群申请被同意
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(accepter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(accepter + "同意了你的群聊申请"));
	// 保存同意消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:MainActivity.java


示例3: onApplicationAccept

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {

    String st4 = appContext.getString(R.string.Agreed_to_your_group_chat_application);
    // 加群申请被同意
    EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
    msg.setChatType(ChatType.GroupChat);
    msg.setFrom(accepter);
    msg.setTo(groupId);
    msg.setMsgId(UUID.randomUUID().toString());
    msg.addBody(new TextMessageBody(accepter + " " +st4));
    // 保存同意消息
    EMChatManager.getInstance().saveMessage(msg);
    // 提醒新消息
    getNotifier().viberateAndPlayTone(msg);
    broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:18,代码来源:DemoHelper.java


示例4: onApplicationAccept

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {

    String st4 = appContext.getString(R.string.Agreed_to_your_group_chat_application);
    // 加群申请被同意
    EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
    msg.setChatType(ChatType.GroupChat);
    msg.setFrom(accepter);
    msg.setTo(groupId);
    msg.setMsgId(UUID.randomUUID().toString());
    msg.addBody(new TextMessageBody(accepter + " " + st4));
    // 保存同意消息
    EMChatManager.getInstance().saveMessage(msg);
    // 提醒新消息
    getNotifier().viberateAndPlayTone(msg);
    broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:18,代码来源:DemoHelper.java


示例5: getItemViewType

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
public int getItemViewType(int position) {
	EMMessage message = conversation.getMessage(position);
	//String attr = message.getStringAttribute("attr",null);//获取扩展属性
	if (message.getType() == EMMessage.Type.TXT) {
		/*if(!CommonUtils.isNullOrEmpty(attr)){//判断扩展属性是否为空
			if(attr.equals("card")){//判断扩展属性是否是名片
				return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
			}
		}*/
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
	}
	if (message.getType() == EMMessage.Type.IMAGE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;

	}
	if (message.getType() == EMMessage.Type.LOCATION) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
	}
	if (message.getType() == EMMessage.Type.VOICE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
	}
	if (message.getType() == EMMessage.Type.VIDEO) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
	}
	if (message.getType() == EMMessage.Type.FILE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
	}

	return -1;// invalid
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:31,代码来源:MessageAdapter.java


示例6: handleTextMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage());
	holder.tv.setText(span, BufferType.SPANNABLE);
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});
	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: //发送中
			holder.pb.setVisibility(View.VISIBLE);
			break;
		default:
			sendMsgInBackground(message, holder);
		}
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:39,代码来源:MessageAdapter.java


示例7: handleLocationMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 处理位置消息
 * 
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) {
	TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location));
	LocationMessageBody locBody = (LocationMessageBody) message.getBody();
	locationView.setText(locBody.getAddress());
	LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
	locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
	locationView.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return false;
		}
	});

	if (message.direct == EMMessage.Direct.RECEIVE) {
		return;
	}
	// deal with send message
	switch (message.status) {
	case SUCCESS:
		holder.pb.setVisibility(View.GONE);
		holder.staus_iv.setVisibility(View.GONE);
		break;
	case FAIL:
		holder.pb.setVisibility(View.GONE);
		holder.staus_iv.setVisibility(View.VISIBLE);
		break;
	case INPROGRESS:
		holder.pb.setVisibility(View.VISIBLE);
		break;
	default:
		sendMsgInBackground(message, holder);
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:45,代码来源:MessageAdapter.java


示例8: updateSendedView

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 更新ui上消息发送状态
 * 
 * @param message
 * @param holder
 */
private void updateSendedView(final EMMessage message, final ViewHolder holder) {
	activity.runOnUiThread(new Runnable() {
		@Override
		public void run() {
			// send success
			if (message.getType() == EMMessage.Type.VIDEO) {
				holder.tv.setVisibility(View.GONE);
			}
			if (message.status == EMMessage.Status.SUCCESS) {
				if (message.getType() == EMMessage.Type.FILE) {
					holder.pb.setVisibility(View.INVISIBLE);
					holder.staus_iv.setVisibility(View.INVISIBLE);
				} else {
					holder.pb.setVisibility(View.GONE);
					holder.staus_iv.setVisibility(View.GONE);
				}

			} else if (message.status == EMMessage.Status.FAIL) {
				if (message.getType() == EMMessage.Type.FILE) {
					holder.pb.setVisibility(View.INVISIBLE);
				} else {
					holder.pb.setVisibility(View.GONE);
				}
				holder.staus_iv.setVisibility(View.VISIBLE);
				Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0)
						.show();
			}
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:37,代码来源:MessageAdapter.java


示例9: onInvitationReceived

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onInvitationReceived(String groupId, String groupName, String inviter, String reason) {
	boolean hasGroup = false;
	for(EMGroup group : EMGroupManager.getInstance().getAllGroups()){
		if(group.getGroupId().equals(groupId)){
			hasGroup = true;
			break;
		}
	}
	if(!hasGroup)
		return;

	// 被邀请
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(inviter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(inviter + "邀请你加入了群聊"));
	// 保存邀请消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity_0903.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});

}
 
开发者ID:macyuan,项目名称:TAG,代码行数:38,代码来源:MainActivity_0903.java


示例10: onInvitationReceived

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onInvitationReceived(String groupId, String groupName, String inviter, String reason) {
	boolean hasGroup = false;
	for(EMGroup group : EMGroupManager.getInstance().getAllGroups()){
		if(group.getGroupId().equals(groupId)){
			hasGroup = true;
			break;
		}
	}
	if(!hasGroup)
		return;

	// 被邀请
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(inviter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(inviter + "邀请你加入了群聊"));
	// 保存邀请消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});

}
 
开发者ID:macyuan,项目名称:TAG,代码行数:38,代码来源:MainActivity.java


示例11: getItemViewType

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 获取item类型
 */
public int getItemViewType(int position) {
	EMMessage message = getItem(position); 
	if (message == null) {
		return -1;
	}
	if (message.getType() == EMMessage.Type.TXT) {
		if (message.getBooleanAttribute(HXConstant.MESSAGE_ATTR_IS_VOICE_CALL, false))
		    return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE_CALL : MESSAGE_TYPE_SENT_VOICE_CALL;
		else if (message.getBooleanAttribute(HXConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false))
		    return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO_CALL : MESSAGE_TYPE_SENT_VIDEO_CALL;
		else if(HXUtil.isRobotMenuMessage(message))
			return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_ROBOT_MENU : MESSAGE_TYPE_SENT_ROBOT_MENU;
		else
			return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
	}
	if (message.getType() == EMMessage.Type.IMAGE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;

	}
	if (message.getType() == EMMessage.Type.LOCATION) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
	}
	if (message.getType() == EMMessage.Type.VOICE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
	}
	if (message.getType() == EMMessage.Type.VIDEO) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
	}
	if (message.getType() == EMMessage.Type.FILE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
	}

	return -1;// invalid
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:38,代码来源:MessageAdapter.java


示例12: handleTextMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = HXSmileUtils.getSmiledText(context, txtBody.getMessage());
	// 设置内容
	holder.tv.setText(span, BufferType.SPANNABLE);
	// 设置长按事件监听
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});

	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS: // 发送成功
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL: // 发送失败
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: // 发送中
			holder.pb.setVisibility(View.VISIBLE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		default:
			// 发送消息
			sendMsgInBackground(message, holder);
		}
	}
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:44,代码来源:MessageAdapter.java


示例13: handleLocationMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
	 * 处理位置消息
	 * 
	 * @param message
	 * @param holder
	 * @param position
	 * @param convertView
	 */
	private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) {
		TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location));
		LocationMessageBody locBody = (LocationMessageBody) message.getBody();
		locationView.setText(locBody.getAddress());
		LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
//		locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
		locationView.setOnLongClickListener(new OnLongClickListener() {
			@Override
			public boolean onLongClick(View v) {
				activity.startActivityForResult(
						(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
								EMMessage.Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
				return false;
			}
		});

		if (message.direct == EMMessage.Direct.RECEIVE) {
			return;
		}
		// deal with send message
		switch (message.status) {
		case SUCCESS:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS:
			holder.pb.setVisibility(View.VISIBLE);
			break;
		default:
			sendMsgInBackground(message, holder);
		}
	}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:45,代码来源:MessageAdapter.java


示例14: onInvitationReceived

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
@Override
public void onInvitationReceived(String groupId, String groupName, String inviter, String reason) {
    
    boolean hasGroup = false;
    for (EMGroup group : EMGroupManager.getInstance().getAllGroups()) {
        if (group.getGroupId().equals(groupId)) {
            hasGroup = true;
            break;
        }
    }
    if (!hasGroup)
        return;

    // 被邀请
    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 TextMessageBody(inviter + " " +st3));
    // 保存邀请消息
    EMChatManager.getInstance().saveMessage(msg);
    // 提醒新消息
    getNotifier().viberateAndPlayTone(msg);
    //发送local广播
    broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:29,代码来源:DemoHelper.java


示例15: receiveRevokeMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 收到撤回消息,这里需要和发送方协商定义,通过一个透传,并加上扩展去实现消息的撤回
 *
 * @param revokeMsg 收到的透传消息,包含需要撤回的消息的 msgId
 * @return 返回撤回结果是否成功
 */
public static boolean receiveRevokeMessage(Context context, EMMessage revokeMsg) {
	EMConversation conversation = EMChatManager.getInstance().getConversation(revokeMsg.getFrom());
    boolean result = false;
    // 从cmd扩展中获取要撤回消息的id
    String msgId = revokeMsg.getStringAttribute(EaseConstant.EASE_ATTR_REVOKE_MSG_ID, null);
    if (msgId == null) {
        return result;
    }
    // 根据得到的msgId 去本地查找这条消息,如果本地已经没有这条消息了,就不用撤回
    // 这里为了防止消息没有加载到内存中,使用Conversation的loadMessage方法加载消息
    EMMessage message = EMChatManager.getInstance().getMessage(msgId);
    if (message == null) {
        message = conversation.loadMessage(msgId);
    }
    // 更改要撤销的消息的内容,替换为消息已经撤销的提示内容
    TextMessageBody body = new TextMessageBody(String.format(context.getString(R.string.revoke_message_by_user), message.getFrom()));
    message.addBody(body);
    // 这里需要把消息类型改为 TXT 类型
    message.setType(EMMessage.Type.TXT);
    // 设置扩展为撤回消息类型,是为了区分消息的显示
    message.setAttribute(EaseConstant.EASE_ATTR_REVOKE, true);
    // 返回修改消息结果
    result = EMChatManager.getInstance().updateMessageBody(message);
    // 因为Android这边没有修改消息未读数的方法,这里只能通过conversation的getMessage方法来实现未读数减一
    conversation.getMessage(msgId);
    message.isAcked = true;
    return result;
}
 
开发者ID:easemob,项目名称:easeui,代码行数:35,代码来源:EaseCommonUtils.java


示例16: forwardMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 转发消息
 * 
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
    final EMMessage forward_msg = EMChatManager.getInstance().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(((TextMessageBody) forward_msg.getBody()).getMessage(),
                    forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
        }else{
            // 获取消息内容,发送消息
            String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
            sendTextMessage(content);
        }
        break;
    case IMAGE:
        // 发送图片
        String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
        if (filePath != null) {
            File file = new File(filePath);
            if (!file.exists()) {
                // 不存在大图发送缩略图
                filePath = EaseImageUtils.getThumbnailImagePath(filePath);
            }
            sendImageMessage(filePath);
        }
        break;
    default:
        break;
    }
    
    if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
        EMChatManager.getInstance().leaveChatRoom(forward_msg.getTo());
    }
}
 
开发者ID:easemob,项目名称:easeui,代码行数:40,代码来源:EaseChatFragment.java


示例17: getItemViewType

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 获取item类型
 */
public int getItemViewType(int position) {
	EMMessage message = getItem(position); 
	if (message == null) {
		return -1;
	}
	if (message.getType() == EMMessage.Type.TXT) {
		if (message.getBooleanAttribute(Constants.MESSAGE_ATTR_IS_VOICE_CALL, false))
		    return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE_CALL : MESSAGE_TYPE_SENT_VOICE_CALL;
		else if (message.getBooleanAttribute(Constants.MESSAGE_ATTR_IS_VIDEO_CALL, false))
		    return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO_CALL : MESSAGE_TYPE_SENT_VIDEO_CALL;
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
	}
	if (message.getType() == EMMessage.Type.IMAGE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;

	}
	if (message.getType() == EMMessage.Type.LOCATION) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
	}
	if (message.getType() == EMMessage.Type.VOICE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
	}
	if (message.getType() == EMMessage.Type.VIDEO) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
	}
	if (message.getType() == EMMessage.Type.FILE) {
		return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
	}

	return -1;// invalid
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:35,代码来源:MessageAdapter.java


示例18: handleTextMessage

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage());
	// 设置内容
	holder.tv.setText(span, BufferType.SPANNABLE);
	// 设置长按事件监听
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});

	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS: // 发送成功
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL: // 发送失败
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: // 发送中
			holder.pb.setVisibility(View.VISIBLE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		default:
			// 发送消息
			sendMsgInBackground(message, holder);
		}
	}
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:44,代码来源:MessageAdapter.java


示例19: updateSendedView

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 更新ui上消息发送状态
 * 
 * @param message
 * @param holder
 */
private void updateSendedView(final EMMessage message, final ViewHolder holder) {
	activity.runOnUiThread(new Runnable() {
		@Override
		public void run() {
			// send success
			if (message.getType() == EMMessage.Type.VIDEO) {
				holder.tv.setVisibility(View.GONE);
			}
			System.out.println("message status : " + message.status);
			if (message.status == EMMessage.Status.SUCCESS) {
				// if (message.getType() == EMMessage.Type.FILE) {
				// holder.pb.setVisibility(View.INVISIBLE);
				// holder.staus_iv.setVisibility(View.INVISIBLE);
				// } else {
				// holder.pb.setVisibility(View.GONE);
				// holder.staus_iv.setVisibility(View.GONE);
				// }

			} else if (message.status == EMMessage.Status.FAIL) {
				// if (message.getType() == EMMessage.Type.FILE) {
				// holder.pb.setVisibility(View.INVISIBLE);
				// } else {
				// holder.pb.setVisibility(View.GONE);
				// }
				// holder.staus_iv.setVisibility(View.VISIBLE);
				Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0)
						.show();
			}

			notifyDataSetChanged();
		}
	});
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:40,代码来源:MessageAdapter.java


示例20: getItemViewType

import com.easemob.chat.EMMessage.Type; //导入依赖的package包/类
/**
 * 获取item类型
 */
public int getItemViewType(int position) {
	EMMessage message = getItem(position); 
	if (message == null) {
		return -1;
	}
	if (message.getType() == Type.TXT) {
		if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false))
		    return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE_CALL : MESSAGE_TYPE_SENT_VOICE_CALL;
		else if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false))
		    return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO_CALL : MESSAGE_TYPE_SENT_VIDEO_CALL;
		else if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message))
			return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_ROBOT_MENU : MESSAGE_TYPE_SENT_ROBOT_MENU;
		else
			return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
	}
	if (message.getType() == Type.IMAGE) {
		return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;

	}
	if (message.getType() == Type.LOCATION) {
		return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
	}
	if (message.getType() == Type.VOICE) {
		return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
	}
	if (message.getType() == Type.VIDEO) {
		return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
	}
	if (message.getType() == Type.FILE) {
		return message.direct == Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
	}

	return -1;// invalid
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:38,代码来源:MessageAdapter.java



注:本文中的com.easemob.chat.EMMessage.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResourceType类代码示例发布时间:2022-05-22
下一篇:
Java FloatDocValuesField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap