public class ConversationFragment extends UriFragment implements android.widget.AbsListView.OnScrollListener, IExtensionClickListener, IUserInfoProvider, CSEvaluateDialog.EvaluateClickListener, android.view.View.OnClickListener
限定符和类型 | 类和说明 |
---|---|
protected static class |
ConversationFragment.LoadMessageDirection |
UriFragment.IActionBarHandler
IUserInfoProvider.UserInfoCallback
限定符和类型 | 字段和说明 |
---|---|
protected PublicServiceProfile |
mPublicServiceProfile |
protected ReferenceMessage |
referenceMessage |
static int |
REQUEST_CODE_FORWARD |
static int |
SCROLL_MODE_BOTTOM |
static int |
SCROLL_MODE_NORMAL |
static int |
SCROLL_MODE_TOP |
static java.lang.String |
TAG |
RONG_URI
UI_RESTORE
构造器和说明 |
---|
ConversationFragment() |
限定符和类型 | 方法和说明 |
---|---|
void |
afterTextChanged(android.text.Editable s) |
void |
beforeTextChanged(java.lang.CharSequence s,
int start,
int count,
int after) |
java.util.List<io.rong.imlib.model.Message> |
getCheckedMessages()
获取选中的消息
|
Conversation.ConversationType |
getConversationType() |
void |
getHistoryMessage(Conversation.ConversationType conversationType,
java.lang.String targetId,
int lastMessageId,
int reqCount,
ConversationFragment.LoadMessageDirection direction,
IHistoryDataResultCallback<java.util.List<io.rong.imlib.model.Message>> callback,
boolean isNewMentionMessage)
加载本地历史消息。
|
MessageListAdapter |
getMessageAdapter()
获取会话界面消息展示适配器。
|
java.util.List<IClickActions> |
getMoreClickActions()
获取点击更多时,底部的动作
开发者重写此方法,返回自定义的点击动作
|
void |
getPublicServiceProfile(Conversation.PublicServiceType publicServiceType,
java.lang.String publicServiceId)
公众服务账号名称,头像信息和公众服务号菜单
|
void |
getRemoteHistoryMessages(Conversation.ConversationType conversationType,
java.lang.String targetId,
long dateTime,
int reqCount,
IHistoryDataResultCallback<java.util.List<io.rong.imlib.model.Message>> callback)
加载服务器远端历史消息。
|
android.content.Intent |
getSelectIntentForForward()
用户重写该接口,可以自定义一个用于转发的选择联系人界面
|
java.lang.String |
getTargetId() |
void |
getUserInfo(java.lang.String userId,
IUserInfoProvider.UserInfoCallback callback) |
boolean |
handleMessage(android.os.Message msg) |
void |
hideNotificationView(android.view.View notificationView)
隐藏调用showNotificationView所显示的通知view
|
protected void |
hideReferenceView() |
protected void |
increaseNewMessageCountIfNeed(io.rong.imlib.model.Message message) |
android.view.View |
inflateNotificationView(int layout)
用来生成需要显示在会话界面的通知view
|
protected void |
initFragment(android.net.Uri uri) |
boolean |
isLocationSharing() |
protected boolean |
isSendReferenceMsg(java.lang.String text) |
protected void |
messageSelectedCountDidExceed()
设置多选时,超过最大可选数量回调。
|
void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data) |
boolean |
onBackPressed() |
void |
onClick(android.view.View v) |
void |
onCreate(android.os.Bundle savedInstanceState) |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
boolean |
onCustomServiceEvaluation(boolean isPullEva,
java.lang.String dialogId,
boolean robotType,
boolean evaluate)
客服弹出评价并提交评价
通过重写此方法 App 可以自定义评价的弹出窗口和评价的提交
|
void |
onCustomServiceWarning(java.lang.String msg,
boolean evaluate,
boolean robotType)
弹出客服提示信息
通过重写此方法可以自定义弹出提示的窗口
|
void |
onDestroy() |
void |
onEditTextClick(android.widget.EditText editText)
点击 “输入框” 时回调。
|
void |
onEmoticonToggleClick(android.view.View v,
android.view.ViewGroup extensionBoard)
点击“表情” 回调.
|
void |
onEvaluateCanceled() |
void |
onEvaluateSubmit() |
void |
onEventBackgroundThread(Event.PlayAudioEvent event) |
void |
onEventMainThread(Event.MessageDeleteEvent deleteEvent) |
void |
onEventMainThread(Event.MessageRecallEvent event) |
void |
onEventMainThread(Event.MessagesClearEvent clearEvent) |
void |
onEventMainThread(Event.PublicServiceFollowableEvent event) |
void |
onEventMainThread(Event.ReadReceiptRequestEvent event) |
void |
onEventMainThread(Event.ReadReceiptResponseEvent event) |
void |
onEventMainThread(Event.RemoteMessageRecallEvent event) |
void |
onEventMainThread(io.rong.imlib.model.Message msg) |
void |
onEventMainThread(PublicServiceProfile publicServiceProfile) |
void |
onEventMainThread(RongIMClient.ConnectionStatusListener.ConnectionStatus status) |
void |
onEventMainThread(UserInfo userInfo) |
void |
onExtensionCollapsed()
Extension 收起。
|
void |
onExtensionExpanded(int h)
Extension 已展开。
|
void |
onImageResult(java.util.List<LocalMedia> selectList)
发送图片结果
sdk 中集成了发送图片功能,在相册选择图片并发送后,回调此方法。
|
boolean |
onKey(android.view.View v,
int keyCode,
android.view.KeyEvent event)
Called when a hardware key is dispatched to EditText.
|
void |
onLocationResult(double lat,
double lng,
java.lang.String poi,
android.net.Uri thumb)
发送地理位置结果
|
void |
onMenuClick(int root,
int sub)
菜单点击回调。
|
void |
onPause()
|
void |
onPhrasesClicked(java.lang.String phrases,
int position)
短语条目被点击的回调
|
void |
onPluginClicked(IPluginModule pluginModule,
int position)
Plugin 点击回调。
|
void |
onPluginToggleClick(android.view.View v,
android.view.ViewGroup extensionBoard)
点击 “+” 号区域, 回调中携带 ViewGroup
|
void |
onReadReceiptStateClick(io.rong.imlib.model.Message message)
回执详情按钮点击事件.
|
void |
onRequestPermissionsResult(int requestCode,
java.lang.String[] permissions,
int[] grantResults) |
void |
onResendItemClick(io.rong.imlib.model.Message message)
点击重发按钮重新发送消息
如果图片消息或文件消息需要上传到开发者指定的服务器,可以通过集成ConversaitonFragment重写此方法
|
MessageListAdapter |
onResolveAdapter(android.content.Context context)
提供 ListView 的 Adapter 适配器。
|
void |
onResume() |
void |
onSaveInstanceState(android.os.Bundle outState) |
void |
onScroll(android.widget.AbsListView view,
int firstVisibleItem,
int visibleItemCount,
int totalItemCount) |
void |
onScrollStateChanged(android.widget.AbsListView view,
int scrollState) |
void |
onSelectCustomerServiceGroup(java.util.List<CSGroupItem> groupList)
如果客服后台有分组,会弹出此对话框选择分组
可以通过自定义类继承自 ConversationFragment 并重写此方法来自定义弹窗
|
void |
onSendToggleClick(android.view.View v,
java.lang.String text)
点击 “发送”
|
void |
onShowAnnounceView(java.lang.String announceMsg,
java.lang.String announceUrl)
展示客服通告栏。
|
void |
onShowStarAndTabletDialog(java.lang.String dialogId)
显示评价星级及标签的方法
App可以继承ConversationFragment类并重写此方法来自定义弹出的评价窗口
评价所需数据可以通过设置监听来获取
|
void |
onStartCustomService(java.lang.String targetId)
开启客服,进入客服会话界面时,会回调此方法
开发者可以重写此方法,修改启动客服的行为
|
void |
onStopCustomService(java.lang.String targetId)
会话结束时,回调此方法。
|
void |
onSwitchToggleClick(android.view.View v,
android.view.ViewGroup inputBoard)
点击左侧按钮(例如:左侧语音切换按钮,客服时的转人工按钮)
切换后,回调中携带 ViewGroup,用户可以添加自己的布局
|
void |
onTextChanged(java.lang.CharSequence s,
int start,
int before,
int count) |
void |
onViewCreated(android.view.View view,
android.os.Bundle savedInstanceState) |
void |
onVoiceInputToggleTouch(android.view.View v,
android.view.MotionEvent event)
点击“按住 说话”,用户可以在此回调方法中实现录音功能。
|
void |
onWarningDialog(java.lang.String msg)
提示dialog.
|
void |
resetMoreActionState()
重置多选状态,隐藏多选框,隐藏底部点击事件
|
void |
setMaxMessageSelectedCount(int maxMessageSelectedCount)
设置多选时,最大可选消息数量,默认都可选,如果设置了改值,超过改值,则会回调
messageSelectedCountDidExceed()
,需要在onCreateView(LayoutInflater, ViewGroup, Bundle) 之后调用 |
void |
setMoreActionState(UIMessage message)
显示多选状态
|
void |
setMoreActionStateListener(OnMoreActionStateListener moreActionStateListener) |
boolean |
shouldUpdateMessage(io.rong.imlib.model.Message message,
int left)
接收到消息,先调用此方法,检查是否可以更新该消息。
|
boolean |
showAboveIsHistoryMessage()
是否显示"以上是历史消息"
|
boolean |
showMoreClickItem()
是否在长按时显示更多选项
|
void |
showNotificationView(android.view.View notificationView)
在通知区域显示一个view
|
void |
showQuitLocationSharingDialog(android.app.Activity activity) |
protected void |
updateNewMessageCountIfNeed(io.rong.imlib.model.Message message,
boolean increase) |
protected void |
updatePublicServiceMenu(PublicServiceProfile publicServiceProfile) |
getActionBarHandler, getUri, obtainUriBundle, onRestoreUI, setActionBarHandler, setUri
findViewById, getHandler
public static final java.lang.String TAG
protected PublicServiceProfile mPublicServiceProfile
public static final int REQUEST_CODE_FORWARD
public static final int SCROLL_MODE_NORMAL
public static final int SCROLL_MODE_TOP
public static final int SCROLL_MODE_BOTTOM
protected ReferenceMessage referenceMessage
public void onCreate(android.os.Bundle savedInstanceState)
onCreate
在类中 UriFragment
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
public void onViewCreated(android.view.View view, android.os.Bundle savedInstanceState)
onViewCreated
在类中 UriFragment
public void onScrollStateChanged(android.widget.AbsListView view, int scrollState)
onScrollStateChanged
在接口中 android.widget.AbsListView.OnScrollListener
public void onScroll(android.widget.AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
onScroll
在接口中 android.widget.AbsListView.OnScrollListener
public void onSaveInstanceState(android.os.Bundle outState)
onSaveInstanceState
在类中 UriFragment
public void onResume()
onResume
在类中 UriFragment
public final void getUserInfo(java.lang.String userId, IUserInfoProvider.UserInfoCallback callback)
getUserInfo
在接口中 IUserInfoProvider
public void setMoreActionStateListener(OnMoreActionStateListener moreActionStateListener)
public void setMoreActionState(UIMessage message)
message
- UIMessagepublic void resetMoreActionState()
public java.util.List<IClickActions> getMoreClickActions()
public java.util.List<io.rong.imlib.model.Message> getCheckedMessages()
public void setMaxMessageSelectedCount(int maxMessageSelectedCount)
messageSelectedCountDidExceed()
,需要在onCreateView(LayoutInflater, ViewGroup, Bundle)
之后调用maxMessageSelectedCount
- 最大可选数。protected void messageSelectedCountDidExceed()
public boolean showMoreClickItem()
public boolean showAboveIsHistoryMessage()
public MessageListAdapter onResolveAdapter(android.content.Context context)
ConversationFragment
并重写此方法。
注意:提供的适配器,要继承自 MessageListAdapter
protected void initFragment(android.net.Uri uri)
initFragment
在类中 UriFragment
public void getPublicServiceProfile(Conversation.PublicServiceType publicServiceType, java.lang.String publicServiceId)
publicServiceType
- 公众服务账号类型publicServiceId
- 公众服务账号idprotected void updatePublicServiceMenu(PublicServiceProfile publicServiceProfile)
public void hideNotificationView(android.view.View notificationView)
notificationView
- 通知栏 viewpublic void showNotificationView(android.view.View notificationView)
public android.view.View inflateNotificationView(int layout)
public void onResendItemClick(io.rong.imlib.model.Message message)
message
- 消息public void onReadReceiptStateClick(io.rong.imlib.model.Message message)
message
- 消息public void onSelectCustomerServiceGroup(java.util.List<CSGroupItem> groupList)
public void onPause()
onDestroy()
会被延迟调用,RongExtension
中
IExtensionModule.onDetachedFromExtension()
也会被延迟。频繁进入会话界面,
IExtensionModule.onAttachedToExtension(RongExtension)
两者时序错乱。
通过在 Activity.isFinishing()
判断 Activity 是否将要结束,决定 RongExtension 的销毁。onPause
在类中 UriFragment
public void onShowAnnounceView(java.lang.String announceMsg, java.lang.String announceUrl)
announceMsg
- 通告栏展示内容announceUrl
- 通告栏点击链接地址public void onDestroy()
onDestroy
在类中 BaseFragment
public boolean isLocationSharing()
public void showQuitLocationSharingDialog(android.app.Activity activity)
public boolean onBackPressed()
onBackPressed
在类中 UriFragment
protected void hideReferenceView()
public boolean handleMessage(android.os.Message msg)
handleMessage
在接口中 android.os.Handler.Callback
handleMessage
在类中 BaseFragment
public void onWarningDialog(java.lang.String msg)
msg
- dialog 提示public void onCustomServiceWarning(java.lang.String msg, boolean evaluate, boolean robotType)
弹出客服提示信息
通过重写此方法可以自定义弹出提示的窗口msg
- 提示的内容evaluate
- 是否需要评价. true 表示还需要弹出评价窗口进行评价, false 表示仅需要提示不需要评价robotType
- 是否是机器人模式public boolean onCustomServiceEvaluation(boolean isPullEva, java.lang.String dialogId, boolean robotType, boolean evaluate)
客服弹出评价并提交评价
通过重写此方法 App 可以自定义评价的弹出窗口和评价的提交isPullEva
- 是否是客服后台主动拉评价,如果为 false,则需要判断在客服界面停留的时间是否超过60秒,
超过这个时间则弹出评价窗口,否则不弹; 如果为 true,则不论停留时间为多少都要弹出评价窗口dialogId
- 会话 Id. 客服后台主动拉评价的时候这个参数有效robotType
- 是否为机器人模式,true 表示机器人模式,false 表示人工模式evaluate
- 是否需要评价. true 表示需要弹出评价窗口进行评价, false 不需要弹出评价窗口
例如有些客服不需要针对整个会话评价,只需要针对每条回复评价,这个时候 evaluate 为 falsepublic void onShowStarAndTabletDialog(java.lang.String dialogId)
dialogId
- 对话框 idpublic void onSendToggleClick(android.view.View v, java.lang.String text)
IExtensionClickListener
onSendToggleClick
在接口中 IExtensionClickListener
v
- “发送” view 实例text
- 输入框内容protected boolean isSendReferenceMsg(java.lang.String text)
public void onImageResult(java.util.List<LocalMedia> selectList)
IExtensionClickListener
onImageResult
在接口中 IExtensionClickListener
selectList
- 要发送的图片管理类public void onEditTextClick(android.widget.EditText editText)
IExtensionClickListener
onEditTextClick
在接口中 IExtensionClickListener
editText
- “输入框” 实例public void onLocationResult(double lat, double lng, java.lang.String poi, android.net.Uri thumb)
IExtensionClickListener
onLocationResult
在接口中 IExtensionClickListener
public void onSwitchToggleClick(android.view.View v, android.view.ViewGroup inputBoard)
IExtensionClickListener
onSwitchToggleClick
在接口中 IExtensionClickListener
v
- ”切换“ 实例inputBoard
- 切换后的输入面板 ViewGroup(例如:语音输入面板,公众号时的菜单面板)public void onVoiceInputToggleTouch(android.view.View v, android.view.MotionEvent event)
IExtensionClickListener
onVoiceInputToggleTouch
在接口中 IExtensionClickListener
v
- 语音输入面板 view 实例event
- 点击事件public void onRequestPermissionsResult(int requestCode, java.lang.String[] permissions, int[] grantResults)
public void onEmoticonToggleClick(android.view.View v, android.view.ViewGroup extensionBoard)
IExtensionClickListener
onEmoticonToggleClick
在接口中 IExtensionClickListener
v
- 表情 view 实例extensionBoard
- 用于展示表情的 ViewGrouppublic void onPluginToggleClick(android.view.View v, android.view.ViewGroup extensionBoard)
IExtensionClickListener
onPluginToggleClick
在接口中 IExtensionClickListener
v
- “+” 号 view 实例extensionBoard
- 用于展示 plugin 的 ViewGrouppublic void beforeTextChanged(java.lang.CharSequence s, int start, int count, int after)
beforeTextChanged
在接口中 android.text.TextWatcher
public void onTextChanged(java.lang.CharSequence s, int start, int before, int count)
onTextChanged
在接口中 android.text.TextWatcher
public void afterTextChanged(android.text.Editable s)
afterTextChanged
在接口中 android.text.TextWatcher
public boolean onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
IExtensionClickListener
onKey
在接口中 IExtensionClickListener
v
- The view the key has been dispatched to.keyCode
- The code for the physical key that was pressedevent
- The KeyEvent object containing full information about
the event.public void onMenuClick(int root, int sub)
IExtensionClickListener
onMenuClick
在接口中 IExtensionClickListener
root
- 一级菜单。sub
- 二级菜单。public void onPluginClicked(IPluginModule pluginModule, int position)
IExtensionClickListener
onPluginClicked
在接口中 IExtensionClickListener
pluginModule
- 被点击的Plugin。position
- 被点击Plugin所在的位置。public void onPhrasesClicked(java.lang.String phrases, int position)
onPhrasesClicked
在接口中 IExtensionClickListener
phrases
- 短语position
- 被点击的短语positionpublic void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
public android.content.Intent getSelectIntentForForward()
public void onEventMainThread(Event.ReadReceiptRequestEvent event)
public void onEventMainThread(Event.ReadReceiptResponseEvent event)
public void onEventMainThread(Event.MessageDeleteEvent deleteEvent)
public void onEventMainThread(Event.PublicServiceFollowableEvent event)
public void onEventMainThread(Event.MessagesClearEvent clearEvent)
public void onEventMainThread(Event.MessageRecallEvent event)
public void onEventMainThread(Event.RemoteMessageRecallEvent event)
public void onEventMainThread(io.rong.imlib.model.Message msg)
public void onEventMainThread(RongIMClient.ConnectionStatusListener.ConnectionStatus status)
protected void increaseNewMessageCountIfNeed(io.rong.imlib.model.Message message)
protected void updateNewMessageCountIfNeed(io.rong.imlib.model.Message message, boolean increase)
public void onEventBackgroundThread(Event.PlayAudioEvent event)
public void onEventMainThread(UserInfo userInfo)
public void onEventMainThread(PublicServiceProfile publicServiceProfile)
public MessageListAdapter getMessageAdapter()
public boolean shouldUpdateMessage(io.rong.imlib.model.Message message, int left)
message
- 接收到的消息体。left
- 剩余的消息数量。public void getHistoryMessage(Conversation.ConversationType conversationType, java.lang.String targetId, int lastMessageId, int reqCount, ConversationFragment.LoadMessageDirection direction, IHistoryDataResultCallback<java.util.List<io.rong.imlib.model.Message>> callback, boolean isNewMentionMessage)
conversationType
- 会话类型targetId
- 会话 idlastMessageId
- 最后一条消息 idreqCount
- 加载数量callback
- 数据加载后,通过回调返回数据
上拉加载时,返回数据中包含当前消息;例:当前消息 id 为 500, before = 0 after = 10,返回 510 - 500 ,按消息 id 倒序。
public void onClick(android.view.View v)
onClick
在接口中 android.view.View.OnClickListener
public void getRemoteHistoryMessages(Conversation.ConversationType conversationType, java.lang.String targetId, long dateTime, int reqCount, IHistoryDataResultCallback<java.util.List<io.rong.imlib.model.Message>> callback)
conversationType
- 会话类型targetId
- 会话 iddateTime
- 从该时间点开始获取消息。即:消息中的 sentTime;第一次可传 0,获取最新 count 条。reqCount
- 加载数量callback
- 数据加载后,通过回调返回数据public void onExtensionCollapsed()
IExtensionClickListener
onExtensionCollapsed
在接口中 IExtensionClickListener
public void onExtensionExpanded(int h)
IExtensionClickListener
onExtensionExpanded
在接口中 IExtensionClickListener
h
- Extension 展开后的高度。public void onStartCustomService(java.lang.String targetId)
targetId
- 客服 idpublic void onStopCustomService(java.lang.String targetId)
targetId
- 客服 idpublic final void onEvaluateSubmit()
public final void onEvaluateCanceled()
public Conversation.ConversationType getConversationType()
public java.lang.String getTargetId()