package com.hyphenate.easeui.modules.chat;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.hyphenate.EMConversationListener;
import com.hyphenate.EMMessageListener;
import com.hyphenate.chat.EMChatManager;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMCmdMessageBody;
import com.hyphenate.chat.EMConversation;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.chat.EMTextMessageBody;
import com.hyphenate.chat.adapter.EMAChatRoomManagerListener;
import com.hyphenate.easeui.EaseIM;
import com.hyphenate.easeui.R;
import com.hyphenate.easeui.constants.EaseConstant;
import com.hyphenate.easeui.domain.EaseEmojicon;
import com.hyphenate.easeui.domain.EaseUser;
import com.hyphenate.easeui.interfaces.EaseChatRoomListener;
import com.hyphenate.easeui.interfaces.EaseGroupListener;
import com.hyphenate.easeui.interfaces.MessageListItemClickListener;
import com.hyphenate.easeui.manager.EaseAtMessageHelper;
import com.hyphenate.easeui.manager.EaseThreadManager;
import com.hyphenate.easeui.modules.chat.interfaces.ChatInputMenuListener;
import com.hyphenate.easeui.modules.chat.interfaces.IChatLayout;
import com.hyphenate.easeui.modules.chat.interfaces.OnAddMsgAttrsBeforeSendEvent;
import com.hyphenate.easeui.modules.chat.interfaces.OnChatLayoutListener;
import com.hyphenate.easeui.modules.chat.interfaces.OnChatRecordTouchListener;
import com.hyphenate.easeui.modules.chat.interfaces.OnMenuChangeListener;
import com.hyphenate.easeui.modules.chat.interfaces.OnRecallMessageResultListener;
import com.hyphenate.easeui.modules.chat.presenter.EaseHandleMessagePresenter;
import com.hyphenate.easeui.modules.chat.presenter.EaseHandleMessagePresenterImpl;
import com.hyphenate.easeui.modules.chat.presenter.IHandleMessageView;
import com.hyphenate.easeui.modules.interfaces.IPopupWindow;
import com.hyphenate.easeui.modules.menu.EasePopupWindow;
import com.hyphenate.easeui.modules.menu.EasePopupWindowHelper;
import com.hyphenate.easeui.modules.menu.MenuItemBean;
import com.hyphenate.easeui.utils.EaseCommonUtils;
import com.hyphenate.easeui.utils.EaseUserUtils;
import com.hyphenate.easeui.widget.EaseAlertDialog;
import com.hyphenate.easeui.widget.EaseVoiceRecorderView;
import com.hyphenate.exceptions.HyphenateException;
import com.hyphenate.util.EMLog;
import java.util.List;
public class EaseChatLayout extends RelativeLayout implements IChatLayout, IHandleMessageView, IPopupWindow
, ChatInputMenuListener, EMMessageListener, EaseChatMessageListLayout.OnMessageTouchListener
, MessageListItemClickListener, EaseChatMessageListLayout.OnChatErrorListener {
private static final String TAG = EaseChatLayout.class.getSimpleName();
private static final int MSG_TYPING_HEARTBEAT = 0;
private static final int MSG_TYPING_END = 1;
private static final int MSG_OTHER_TYPING_END = 2;
public static final String ACTION_TYPING_BEGIN = "TypingBegin";
public static final String ACTION_TYPING_END = "TypingEnd";
protected static final int TYPING_SHOW_TIME = 10000;
protected static final int OTHER_TYPING_SHOW_TIME = 5000;
public static final String AT_PREFIX = "@";
public static final String AT_SUFFIX = " ";
private EaseChatMessageListLayout messageListLayout;
private EaseChatInputMenu inputMenu;
private EaseVoiceRecorderView voiceRecorder;
/**
* "正在输入"功能的开关,打开后本设备发送消息将持续发送cmd类型消息通知对方"正在输入"
*/
private boolean turnOnTyping;
/**
* 用于处理用户是否正在输入的handler
*/
private Handler typingHandler;
/**
* 会话id,可能是对方环信id,也可能是群id或者聊天室id
*/
private String conversationId;
/**
* 聊天类型
*/
private int chatType;
/**
* 用于监听消息的变化
*/
private OnChatLayoutListener listener;
/**
* 用于监听发送语音的触摸事件
*/
private OnChatRecordTouchListener recordTouchListener;
private EaseHandleMessagePresenter presenter;
/**
* 是否展示默认菜单
*/
private boolean showDefaultMenu = true;
/**
* 长按条目菜单帮助类
*/
private EasePopupWindowHelper menuHelper;
private ClipboardManager clipboard;
private OnMenuChangeListener menuChangeListener;
/**
* 撤回监听
*/
private OnRecallMessageResultListener recallMessageListener;
/**
* 聊天室监听
*/
private ChatRoomListener chatRoomListener;
/**
* 群组监听
*/
private GroupListener groupListener;
/**
* 发送消息前添加消息属性事件
*/
private OnAddMsgAttrsBeforeSendEvent sendMsgEvent;
/**
* 是否是首次发送,默认true
*/
private boolean isNotFirstSend;
public EaseChatLayout(Context context) {
this(context, null);
}
public EaseChatLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public EaseChatLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
presenter = new EaseHandleMessagePresenterImpl();
if(context instanceof AppCompatActivity) {
((AppCompatActivity) context).getLifecycle().addObserver(presenter);
}
LayoutInflater.from(context).inflate(R.layout.ease_layout_chat, this);
initView();
initListener();
}
private void initView() {
messageListLayout = findViewById(R.id.layout_chat_message);
inputMenu = findViewById(R.id.layout_menu);
voiceRecorder = findViewById(R.id.voice_recorder);
presenter.attachView(this);
menuHelper = new EasePopupWindowHelper();
clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
}
private void initListener() {
messageListLayout.setOnMessageTouchListener(this);
messageListLayout.setMessageListItemClickListener(this);
messageListLayout.setOnChatErrorListener(this);
inputMenu.setChatInputMenuListener(this);
getChatManager().addMessageListener(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
getChatManager().removeMessageListener(this);
if(chatRoomListener != null) {
EMClient.getInstance().chatroomManager().removeChatRoomListener(chatRoomListener);
}
if(groupListener != null) {
EMClient.getInstance().groupManager().removeGroupChangeListener(groupListener);
}
if(isChatRoomCon()) {
EMClient.getInstance().chatroomManager().leaveChatRoom(conversationId);
}
if(isGroupCon()) {
EaseAtMessageHelper.get().removeAtMeGroup(conversationId);
EaseAtMessageHelper.get().cleanToAtUserList();
}
if(typingHandler != null) {
typingHandler.removeCallbacksAndMessages(null);
}
}
/**
* 初始化
* @param username 环信id
* @param chatType 聊天类型,单聊,群聊或者聊天室
*/
public void init(String username, int chatType) {
init(EaseChatMessageListLayout.LoadDataType.LOCAL, username, chatType);
}
/**
* 初始化
* @param loadDataType 加载数据模式
* @param conversationId 会话id,可能是对方环信i
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
AndroidAppAppAndroid StudioJavaXMLApp android studio开发app项目 android studio开发app项目 android studio开发app项目 android studio开发app项目 android studio开发app项目
资源推荐
资源详情
资源评论
收起资源包目录
Android实现智慧医疗App-android studio开发app项目 (854个子文件)
gradlew.bat 3KB
.gitignore 525B
.gitignore 225B
.gitignore 47B
.gitignore 6B
build.gradle 2KB
build.gradle 2KB
settings.gradle 484B
build.gradle 229B
gradlew 6KB
BaiduLBS_Android.jar 3.21MB
BaiduLBS_Android.jar 1.3MB
gradle-wrapper.jar 58KB
EaseChatLayout.java 33KB
EasyVideoPlayer.java 32KB
EaseChatMessageListLayout.java 31KB
PhotoViewAttacher.java 27KB
EaseConversationListLayout.java 24KB
EaseChatRow.java 21KB
EaseContactListLayout.java 19KB
Camera2.java 18KB
EaseFileUtils.java 17KB
EaseCompat.java 16KB
ServiceFragment.java 16KB
EaseNotifier.java 15KB
DBManager.java 15KB
ShopDetailActivity.java 13KB
EaseTitleBar.java 13KB
EaseChatExtendMenu.java 12KB
EaseChatPrimaryMenu.java 12KB
EaseChatFragment.java 12KB
EaseRecyclerView.java 12KB
EaseImageView.java 12KB
EaseCommonUtils.java 11KB
PagingScrollHelper.java 11KB
EaseBaseRecyclerViewAdapter.java 10KB
EaseEmojiconPagerView.java 10KB
EaseImageUtils.java 10KB
EaseRoundImageView.java 10KB
SubmitFragment.java 10KB
EaseAdapterDelegatesManager.java 10KB
EaseChatInputMenu.java 10KB
EaseDingMessageHelper.java 10KB
EaseBaiduMapActivity.java 10KB
HorizontalPageLayoutManager.java 10KB
EasePopupWindowHelper.java 10KB
RomUtils.java 10KB
FriendsFragment.java 9KB
MyselfFragment.java 9KB
EaseHandleMessagePresenterImpl.java 9KB
EaseVoiceRecorderView.java 8KB
EaseUser.java 8KB
EaseDefaultConversationDelegate.java 8KB
EaseDateUtils.java 8KB
VersionedGestureDetector.java 8KB
StatusBarCompat.java 8KB
EaseEditTextUtils.java 8KB
HomeFragment.java 8KB
EaseChatMessagePresenterImpl.java 8KB
EaseIM.java 7KB
EaseAtMessageHelper.java 7KB
InviteTableDao.java 7KB
EaseSidebar.java 7KB
EaseSystemMsgManager.java 7KB
EaseContactListAdapter.java 6KB
EaseEmojiconMenu.java 6KB
EaseVoiceViewHolder.java 6KB
EaseSmileUtils.java 6KB
EaseConversationPresenterImpl.java 6KB
LoginActivity.java 6KB
EasePopupWindow.java 6KB
ConversationDelegate.java 6KB
InviteActivity.java 6KB
InviteAdapter.java 5KB
EaseConversationDelegate.java 5KB
EaseChatRowVoice.java 5KB
IPhotoView.java 5KB
MainActivity.java 5KB
SendRequest.java 5KB
EaseShowBigImageActivity.java 5KB
EaseVoiceRecorder.java 5KB
EaseChatRowVideo.java 5KB
EasePhotoView.java 5KB
EaseContactCustomAdapter.java 5KB
EaseBaseDelegateAdapter.java 5KB
EaseEmojiconIndicatorView.java 5KB
AssetsUtils.java 5KB
EaseShowVideoActivity.java 5KB
EaseContactPresenterImpl.java 5KB
EaseConversationListFragment.java 5KB
ContactTableDao.java 4KB
EaseDingAckUserListActivity.java 4KB
EaseChatRowFile.java 4KB
EaseSearchTextView.java 4KB
EaseBaseActivity.java 4KB
EasePopupMenuHelper.java 4KB
EaseEmojiconScrollTabBar.java 4KB
IntroActivity.java 4KB
PlayVideoActivity.java 4KB
PagingItemDecoration.java 4KB
共 854 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
lly202406
- 粉丝: 2603
- 资源: 5442
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功