Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
6ce6a104
Commit
6ce6a104
authored
Jun 22, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: IImService注册自定义通知改造,AudioHomeActivity处理自定义消息
parent
613d0d77
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
25 deletions
+69
-25
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+36
-0
ImObserversHelper.kt
m-im/src/main/java/com/yidianling/im/helper/ImObserversHelper.kt
+4
-7
IMServiceImpl.kt
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
+5
-2
YDLP2PMessageActivity.java
m-im/src/main/java/com/yidianling/uikit/business/session/activity/YDLP2PMessageActivity.java
+22
-16
IImService.kt
m-im/src/main/modular_api/com/yidianling/im/api/service/IImService.kt
+2
-0
No files found.
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
6ce6a104
...
...
@@ -25,6 +25,7 @@ import com.alibaba.android.arouter.launcher.ARouter
import
com.google.gson.Gson
import
com.hjq.permissions.OnPermissionCallback
import
com.hjq.permissions.XXPermissions
import
com.ydl.audioim.bean.AgoraInvitationBean
import
com.ydl.audioim.bean.AgoraLogInfoBean
import
com.ydl.audioim.contract.IAudioHomeActivityContract
import
com.ydl.audioim.http.command.ConnectCommand
...
...
@@ -49,6 +50,7 @@ import com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.manager.YDLImageCacheManager
import
com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.modular.findRouteService
import
com.ydl.ydlcommon.router.YdlCommonRouterManager
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.StatusBarUtils
...
...
@@ -58,6 +60,8 @@ import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import
com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import
com.yidianling.im.api.service.IImService
import
com.yidianling.user.api.service.IUserService
import
de.greenrobot.event.EventBus
...
...
@@ -227,6 +231,36 @@ class AudioHomeActivity :
private
var
canChangeRoute
:
Boolean
=
false
private
val
notificationCallback
=
object
:
IMRegisterObserverCustomNotificationCallBack
{
override
fun
onObserverCustomNotification
(
fromUid
:
String
,
toUid
:
String
,
content
:
String
)
{
if
(
fromUid
==
listenerUid
)
{
try
{
val
bean
=
Gson
().
fromJson
(
content
,
AgoraInvitationBean
::
class
.
java
)
when
(
bean
.
callType
)
{
"2"
->
{
//接受
runOnUiThread
{
joinChannel
()
onPeerAccepted
()
}
}
"4"
->
{
//拒绝
runOnUiThread
{
ToastUtil
.
toastShort
(
"对方已挂断"
)
writeAgoraLog
(
"被叫(专家)拒绝了通话邀请"
)
//通话结束或挂断时,上传日志文件
uploadLog
()
leaveChannel
()
uploadExceptionStatus
(
"对方已拒绝"
,
2
)
}
}
}
}
catch
(
throwable
:
Throwable
)
{
LogUtil
.
e
(
throwable
.
message
)
}
}
}
}
/**
* 声网事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
...
...
@@ -484,6 +518,7 @@ class AudioHomeActivity :
setClickEvent
()
//权限申请
requestPermission
()
findRouteService
(
IImService
::
class
.
java
).
registerObserveCustomNotification
(
notificationCallback
)
ActionCountUtils
.
record
(
"call_phone_page"
,
"call_phone_page_visit"
,
listenerUid
?:
"0"
,
"1"
)
}
...
...
@@ -1545,6 +1580,7 @@ class AudioHomeActivity :
override
fun
onDestroy
()
{
super
.
onDestroy
()
findRouteService
(
IImService
::
class
.
java
).
unregisterObserveCustomNotification
(
notificationCallback
)
uploadLog
()
phoneHandler
?.
removeCallbacksAndMessages
(
null
)
if
(
isConnectSuccess
)
{
...
...
m-im/src/main/java/com/yidianling/im/helper/ImObserversHelper.kt
View file @
6ce6a104
...
...
@@ -41,10 +41,7 @@ import java.util.concurrent.Executors
* Des:
*/
class
ImObserversHelper
{
var
imCustomNotificationCallBack
:
IMRegisterObserverCustomNotificationCallBack
?
=
null
set
(
value
)
{
field
=
value
}
internal
val
imCustomNotificationCallBack
:
MutableList
<
IMRegisterObserverCustomNotificationCallBack
>
=
arrayListOf
()
companion
object
{
fun
getInstance
():
ImObserversHelper
{
...
...
@@ -172,9 +169,9 @@ class ImObserversHelper {
false
}
private
var
receiveSystemMessageObserver
:
Observer
<
CustomNotification
>
=
Observer
<
CustomNotification
>
{
LogUtil
.
e
(
it
.
content
)
imCustomNotificationCallBack
?.
onObserverCustomNotification
(
it
.
fromAccount
,
it
.
sessionId
,
it
.
content
)
private
var
receiveSystemMessageObserver
:
Observer
<
CustomNotification
>
=
Observer
<
CustomNotification
>
{
notification
->
LogUtil
.
e
(
notification
.
content
)
imCustomNotificationCallBack
.
forEach
{
it
.
onObserverCustomNotification
(
notification
.
fromAccount
,
notification
.
sessionId
,
notification
.
content
)
}
}
private
var
msgRevokeFilter
=
MsgRevokeFilter
{
message
->
...
...
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
View file @
6ce6a104
...
...
@@ -39,7 +39,6 @@ import com.yidianling.im.session.SessionHelper
import
com.yidianling.im.session.extension.CustomAttachModifyTime
import
com.yidianling.im.session.extension.CustomAttachSubScriptTime
import
com.yidianling.im.session.extension.CustomAttachmentTest
import
com.yidianling.im.ui.activity.CmsExamQuestionPaperActivity
import
com.yidianling.im.ui.page.NewMultiMessageFragment
import
com.yidianling.nimbase.common.media.picker.PickImageHelper
import
com.yidianling.uikit.api.NimUIKit
...
...
@@ -257,7 +256,11 @@ class IMServiceImpl : IImService {
}
override
fun
registerObserveCustomNotification
(
callback
:
IMRegisterObserverCustomNotificationCallBack
)
{
ImObserversHelper
.
getInstance
().
imCustomNotificationCallBack
=
callback
ImObserversHelper
.
getInstance
().
imCustomNotificationCallBack
.
add
(
callback
)
}
override
fun
unregisterObserveCustomNotification
(
callback
:
IMRegisterObserverCustomNotificationCallBack
)
{
ImObserversHelper
.
getInstance
().
imCustomNotificationCallBack
.
remove
(
callback
)
}
override
fun
getMultiMessageFragment
():
Fragment
{
...
...
m-im/src/main/java/com/yidianling/uikit/business/session/activity/YDLP2PMessageActivity.java
View file @
6ce6a104
...
...
@@ -16,15 +16,15 @@ import com.netease.nimlib.sdk.msg.MsgServiceObserve;
import
com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
;
import
com.netease.nimlib.sdk.msg.model.CustomNotification
;
import
com.netease.nimlib.sdk.msg.model.IMMessage
;
import
com.ydl.ydlcommon.modular.ModularServiceManagerKt
;
import
com.ydl.ydlcommon.utils.log.AliYunLogConfig
;
import
com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
;
import
com.yidianling.im.api.service.IImService
;
import
com.yidianling.im.bean.ServiceBean
;
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
;
import
com.yidianling.im.config.constants.ImConstants
;
import
com.yidianling.im.helper.ImObserversHelper
;
import
com.yidianling.im.session.SessionHelper
;
import
com.yidianling.nimbase.api.model.session.SessionCustomization
;
import
com.yidianling.nimbase.api.model.user.UserInfoObserver
;
...
...
@@ -54,6 +54,7 @@ public class YDLP2PMessageActivity extends YDLBaseMessageActivity {
protected
YDLMessageFragment
messageFragment
;
private
boolean
isChangeDoctor
=
false
;
String
oldName
=
""
;
private
IMRegisterObserverCustomNotificationCallBack
notificationCallBack
;
/**
* @param context
...
...
@@ -129,23 +130,24 @@ public class YDLP2PMessageActivity extends YDLBaseMessageActivity {
NIMClient
.
getService
(
MsgService
.
class
).
clearUnreadCount
(
sessionId
,
SessionTypeEnum
.
P2P
);
// 转客服通知监听
ImObserversHelper
.
Companion
.
getInstance
().
setImCustomNotificationCallBack
(
new
IMRegisterObserverCustomNotificationCallBack
()
{
notificationCallBack
=
new
IMRegisterObserverCustomNotificationCallBack
()
{
@Override
public
void
onObserverCustomNotification
(
@NotNull
String
fromUid
,
@NotNull
String
toUid
,
@NotNull
String
content
)
{
try
{
ServiceBean
serviceBean
=
new
Gson
().
fromJson
(
content
,
ServiceBean
.
class
);
// 切换到客服
if
(
serviceBean
!=
null
&&
serviceBean
.
getData
()
!=
null
&&
serviceBean
.
getBusiness
()!=
null
&&
serviceBean
.
getBusiness
().
equals
(
"change_doctor"
))
{
isChangeDoctor
=
true
;
String
serviceUid
=
String
.
valueOf
(
serviceBean
.
getData
().
getToUid
());
tb
.
setTitle
(
serviceBean
.
getData
().
getName
());
YDLP2PMessageActivity
.
startChangeDoctor
(
YDLP2PMessageActivity
.
this
,
serviceUid
,
SessionHelper
.
getP2pCustomization
(-
1
),
null
,
new
P2PCustomActionHandlerImpl
(
serviceUid
,
serviceBean
.
getData
().
getName
(),
serviceUid
));
}
}
catch
(
Exception
e
)
{
com
.
ydl
.
ydlcommon
.
utils
.
LogUtil
.
e
(
"exception:"
+
e
.
getMessage
());
}
try
{
ServiceBean
serviceBean
=
new
Gson
().
fromJson
(
content
,
ServiceBean
.
class
);
// 切换到客服
if
(
serviceBean
!=
null
&&
serviceBean
.
getData
()
!=
null
&&
serviceBean
.
getBusiness
()
!=
null
&&
serviceBean
.
getBusiness
().
equals
(
"change_doctor"
))
{
isChangeDoctor
=
true
;
String
serviceUid
=
String
.
valueOf
(
serviceBean
.
getData
().
getToUid
());
tb
.
setTitle
(
serviceBean
.
getData
().
getName
());
YDLP2PMessageActivity
.
startChangeDoctor
(
YDLP2PMessageActivity
.
this
,
serviceUid
,
SessionHelper
.
getP2pCustomization
(-
1
),
null
,
new
P2PCustomActionHandlerImpl
(
serviceUid
,
serviceBean
.
getData
().
getName
(),
serviceUid
));
}
}
catch
(
Exception
e
)
{
com
.
ydl
.
ydlcommon
.
utils
.
LogUtil
.
e
(
"exception:"
+
e
.
getMessage
());
}
}
});
};
ModularServiceManagerKt
.
findRouteService
(
IImService
.
class
).
registerObserveCustomNotification
(
notificationCallBack
);
}
@Override
...
...
@@ -156,6 +158,10 @@ public class YDLP2PMessageActivity extends YDLBaseMessageActivity {
registerObservers
(
false
);
super
.
onDestroy
();
if
(
notificationCallBack
!=
null
)
{
ModularServiceManagerKt
.
findRouteService
(
IImService
.
class
).
registerObserveCustomNotification
(
notificationCallBack
);
}
AliYunRichLogsHelper
.
Companion
.
getInstance
().
sendRichLog
(
AliYunLogConfig
.
YUNXIN
,
"退出聊天页面"
);
}
...
...
m-im/src/main/modular_api/com/yidianling/im/api/service/IImService.kt
View file @
6ce6a104
...
...
@@ -110,6 +110,8 @@ interface IImService : IProvider {
*/
fun
registerObserveCustomNotification
(
callback
:
IMRegisterObserverCustomNotificationCallBack
)
fun
unregisterObserveCustomNotification
(
callback
:
IMRegisterObserverCustomNotificationCallBack
)
fun
getMultiMessageFragment
():
Fragment
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment