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
d351e3ea
Commit
d351e3ea
authored
Jul 11, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网易2.0
parent
fefe46ba
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
179 additions
and
4 deletions
+179
-4
build.gradle
m-im/build.gradle
+2
-0
NimApplication.java
m-im/src/main/java/com/yidianling/im/config/NimApplication.java
+9
-1
ImObserversHelper.kt
m-im/src/main/java/com/yidianling/im/helper/ImObserversHelper.kt
+4
-0
NIMInitManager.java
m-im/src/main/java/com/yidianling/im/helper/NIMInitManager.java
+4
-0
NimUICallInit.java
m-im/src/main/java/com/yidianling/im/helper/NimUICallInit.java
+118
-0
ImApi.kt
m-im/src/main/java/com/yidianling/im/http/ImApi.kt
+14
-2
ImHttpImpl.kt
m-im/src/main/java/com/yidianling/im/http/ImHttpImpl.kt
+1
-1
ImIn.kt
m-im/src/main/java/com/yidianling/im/router/ImIn.kt
+3
-0
XLog.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/log/XLog.kt
+24
-0
No files found.
m-im/build.gradle
View file @
d351e3ea
...
@@ -63,6 +63,8 @@ dependencies {
...
@@ -63,6 +63,8 @@ dependencies {
implementation
rootProject
.
ext
.
dependencies
[
"BaseRecyclerViewAdapterHelper"
]
implementation
rootProject
.
ext
.
dependencies
[
"BaseRecyclerViewAdapterHelper"
]
api
'com.tencent.tbs.tbssdk:sdk:43903'
api
'com.tencent.tbs.tbssdk:sdk:43903'
implementation
(
'com.netease.yunxin.kit:call-ui:1.5.6'
)
api
project
(
':ydl-webview'
)
api
project
(
':ydl-webview'
)
api
project
(
':ydl-platform'
)
api
project
(
':ydl-platform'
)
implementation
project
(
":api:im"
)
implementation
project
(
":api:im"
)
...
...
m-im/src/main/java/com/yidianling/im/config/NimApplication.java
View file @
d351e3ea
...
@@ -10,6 +10,7 @@ import androidx.annotation.DrawableRes;
...
@@ -10,6 +10,7 @@ import androidx.annotation.DrawableRes;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.SDKOptions
;
import
com.netease.nimlib.sdk.auth.LoginInfo
;
import
com.netease.nimlib.sdk.auth.LoginInfo
;
import
com.netease.nimlib.sdk.mixpush.MixPushMessageHandler
;
import
com.netease.nimlib.sdk.mixpush.MixPushMessageHandler
;
import
com.netease.nimlib.sdk.mixpush.NIMPushClient
;
import
com.netease.nimlib.sdk.mixpush.NIMPushClient
;
...
@@ -42,6 +43,7 @@ import de.greenrobot.event.EventBus;
...
@@ -42,6 +43,7 @@ import de.greenrobot.event.EventBus;
public
class
NimApplication
{
public
class
NimApplication
{
private
String
appKey
;
private
NimApplication
()
{
private
NimApplication
()
{
}
}
...
@@ -54,10 +56,16 @@ public class NimApplication {
...
@@ -54,10 +56,16 @@ public class NimApplication {
return
InstanceHolder
.
nimApplication
;
return
InstanceHolder
.
nimApplication
;
}
}
public
String
getAppKey
()
{
return
appKey
;
}
public
void
initIm
(
Application
app
,
Class
activity
,
IMInitConfigBean
configBean
)
{
public
void
initIm
(
Application
app
,
Class
activity
,
IMInitConfigBean
configBean
)
{
IMCache
.
setContext
(
app
);
IMCache
.
setContext
(
app
);
// 初始化云信SDK
// 初始化云信SDK
NIMClient
.
init
(
app
,
loginInfo
(),
NimSDKOptionConfig
.
prepareSDKOptions
(
app
,
activity
,
configBean
));
SDKOptions
sdkOptions
=
NimSDKOptionConfig
.
prepareSDKOptions
(
app
,
activity
,
configBean
);
appKey
=
sdkOptions
.
appKey
;
NIMClient
.
init
(
app
,
loginInfo
(),
sdkOptions
);
// 以下逻辑只在主进程初始化时执行
// 以下逻辑只在主进程初始化时执行
if
(
NIMUtil
.
isMainProcess
(
app
))
{
if
(
NIMUtil
.
isMainProcess
(
app
))
{
...
...
m-im/src/main/java/com/yidianling/im/helper/ImObserversHelper.kt
View file @
d351e3ea
...
@@ -17,6 +17,7 @@ import com.netease.nimlib.sdk.msg.model.IMMessage
...
@@ -17,6 +17,7 @@ import com.netease.nimlib.sdk.msg.model.IMMessage
import
com.netease.nimlib.sdk.msg.model.RevokeMsgNotification
import
com.netease.nimlib.sdk.msg.model.RevokeMsgNotification
import
com.netease.nimlib.sdk.team.TeamServiceObserver
import
com.netease.nimlib.sdk.team.TeamServiceObserver
import
com.netease.nimlib.sdk.team.model.Team
import
com.netease.nimlib.sdk.team.model.Team
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.LogUtil
import
com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import
com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import
com.yidianling.im.api.event.AccountChangeEvent
import
com.yidianling.im.api.event.AccountChangeEvent
...
@@ -91,6 +92,9 @@ class ImObserversHelper {
...
@@ -91,6 +92,9 @@ class ImObserversHelper {
if
(
code
.
wontAutoLoginForever
())
{
if
(
code
.
wontAutoLoginForever
())
{
EventBus
.
getDefault
().
post
(
AccountChangeEvent
(
1
))
EventBus
.
getDefault
().
post
(
AccountChangeEvent
(
1
))
}
}
if
(
code
==
StatusCode
.
LOGINED
)
{
NimUICallInit
.
initNim2
(
BaseApp
.
getApp
())
}
}
}
private
var
messageRevokeObserver
:
Observer
<
RevokeMsgNotification
>
=
NimMessageRevokeObserver
()
private
var
messageRevokeObserver
:
Observer
<
RevokeMsgNotification
>
=
NimMessageRevokeObserver
()
...
...
m-im/src/main/java/com/yidianling/im/helper/NIMInitManager.java
View file @
d351e3ea
...
@@ -5,6 +5,7 @@ import android.content.Context;
...
@@ -5,6 +5,7 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
;
import
com.yidianling.im.session.extension.CustomAttachmentFilter
;
import
com.yidianling.im.session.extension.CustomAttachmentFilter
;
import
com.yidianling.nimbase.common.ToastHelper
;
import
com.yidianling.nimbase.common.ToastHelper
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.NIMClient
;
...
@@ -120,6 +121,9 @@ public class NIMInitManager{
...
@@ -120,6 +121,9 @@ public class NIMInitManager{
return
true
;
return
true
;
}
}
}
}
if
(
message
.
getMsgType
()
==
MsgTypeEnum
.
nrtc_netcall
){
return
true
;
}
return
false
;
return
false
;
}
}
});
});
...
...
m-im/src/main/java/com/yidianling/im/helper/NimUICallInit.java
0 → 100644
View file @
d351e3ea
package
com
.
yidianling
.
im
.
helper
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
com.netease.lava.nertc.sdk.NERtcOption
;
import
com.netease.nimlib.sdk.RequestCallback
;
import
com.netease.yunxin.nertc.nertcvideocall.bean.InvitedInfo
;
import
com.netease.yunxin.nertc.ui.CallKitNotificationConfig
;
import
com.netease.yunxin.nertc.ui.CallKitUI
;
import
com.netease.yunxin.nertc.ui.CallKitUIOptions
;
import
com.netease.yunxin.nertc.ui.service.DefaultIncomingCallEx
;
import
com.ydl.ydlcommon.modular.ModularServiceManagerKt
;
import
com.ydl.ydlcommon.utils.log.XLog
;
import
com.yidianling.im.R
;
import
com.yidianling.im.config.NimApplication
;
import
com.yidianling.im.http.ImHttpImpl
;
import
com.yidianling.user.api.bean.UserResponseBean
;
import
com.yidianling.user.api.service.IUserService
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.reactivex.functions.Consumer
;
import
io.reactivex.schedulers.Schedulers
;
public
class
NimUICallInit
{
private
static
boolean
hasReportSupportLine
=
false
;
private
static
String
curChannelName
;
public
static
void
initNim2
(
Context
context
)
{
UserResponseBean
.
UserInfo
userInfo
=
ModularServiceManagerKt
.
findRouteService
(
IUserService
.
class
).
getUserInfo
();
if
(
userInfo
==
null
)
return
;
String
userId
=
userInfo
.
getUid
();
android
.
util
.
Log
.
e
(
"qwert"
,
userId
);
String
appKey
=
NimApplication
.
getInstance
().
getAppKey
();
CallKitUIOptions
options
=
new
CallKitUIOptions
.
Builder
()
// 必要:音视频通话 sdk appKey,用于通话中使用
.
rtcAppKey
(
appKey
)
// 必要:当前用户 AccId
.
currentUserAccId
(
userId
)
.
currentUserRtcUId
(
Long
.
parseLong
(
userId
))
// 通话接听成功的超时时间单位 毫秒,默认30s
.
timeOutMillisecond
(
30
*
1000L
)
// 此处为 收到来电时展示的 notification 相关配置,如图标,提示语等。
.
notificationConfigFetcher
(
invitedInfo
->
new
CallKitNotificationConfig
(
R
.
drawable
.
avchat_imcoming_call
))
// 收到被叫时若 app 在后台,在恢复到前台时是否自动唤起被叫页面,默认为 true
.
resumeBGInvitation
(
true
)
.
incomingCallEx
(
new
DefaultIncomingCallEx
()
{
@Override
public
boolean
onIncomingCall
(
@NotNull
InvitedInfo
invitedInfo
)
{
XLog
.
INSTANCE
.
i
(
"incomingCallEx"
,
invitedInfo
.
toString
());
curChannelName
=
invitedInfo
.
channelName
;
return
super
.
onIncomingCall
(
invitedInfo
);
}
})
.
enableOrder
(
false
)
// .p2pAudioActivity(TestActivity.class)
// .p2pVideoActivity(TestActivity.class)
// 请求 rtc token 服务,若非安全模式则不需设置
.
rtcTokenService
((
uid
,
callback
)
->
requestRtcToken
(
uid
,
callback
))
// 自己实现的 token 请求方法
// 设置初始化 rtc sdk 相关配置,按照所需进行配置
.
rtcSdkOption
(
new
NERtcOption
())
// 呼叫组件初始化 rtc 范围,true-全局初始化,false-每次通话进行初始化以及销毁
// 全局初始化有助于更快进入首帧页面,当结合其他组件使用时存在rtc初始化冲突可设置false
.
rtcInitScope
(
true
)
.
build
();
// 若重复初始化会销毁之前的初始化实例,重新初始化
CallKitUI
.
init
(
context
.
getApplicationContext
(),
options
);
}
@SuppressLint
(
"CheckResult"
)
private
static
void
requestRtcToken
(
long
uid
,
RequestCallback
<
String
>
callback
)
{
Map
<
String
,
String
>
body
=
new
HashMap
<>();
if
(
curChannelName
!=
null
)
{
body
.
put
(
"channelName"
,
curChannelName
);
}
body
.
put
(
"uid"
,
String
.
valueOf
(
uid
));
ImHttpImpl
.
Companion
.
getInstance
().
getImApi
().
nim2Token
(
body
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
Schedulers
.
io
())
.
subscribe
(
resp
->
{
curChannelName
=
null
;
if
(
resp
.
code
==
200
)
{
callback
.
onSuccess
(
resp
.
data
);
}
else
{
XLog
.
INSTANCE
.
i
(
"requestRtcToken"
,
resp
.
msg
);
callback
.
onFailed
(
resp
.
code
);
}
},
new
Consumer
<
Throwable
>()
{
@Override
public
void
accept
(
Throwable
throwable
)
throws
Exception
{
curChannelName
=
null
;
callback
.
onException
(
throwable
);
}
});
}
@SuppressLint
(
"CheckResult"
)
public
static
void
reportSupportLine
()
{
if
(
hasReportSupportLine
)
return
;
Map
<
String
,
Object
>
report
=
new
HashMap
<>();
report
.
put
(
"callKeys"
,
new
String
[]{
"netease_app2"
});
//支持云信2.0呼叫通话
ImHttpImpl
.
Companion
.
getInstance
().
getImApi
()
.
reportSupportLine
(
report
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribe
(
resp
->
{
if
(
TextUtils
.
equals
(
resp
.
code
,
"200"
))
{
hasReportSupportLine
=
true
;
}
});
}
}
m-im/src/main/java/com/yidianling/im/http/ImApi.kt
View file @
d351e3ea
...
@@ -5,8 +5,12 @@ import com.ydl.ydlcommon.base.config.YDL_DOMAIN
...
@@ -5,8 +5,12 @@ import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.yidianling.im.api.bean.*
import
com.yidianling.im.api.bean.IMExpertBuild
import
com.yidianling.im.bean.*
import
com.yidianling.im.api.bean.MsgDetail
import
com.yidianling.im.api.bean.UpdateStatusBean
import
com.yidianling.im.bean.MsgData
import
com.yidianling.im.bean.MsgHome
import
com.yidianling.im.bean.SystemMsgBean
import
com.yidianling.im.ui.page.fragment.bean.ChatModelBean
import
com.yidianling.im.ui.page.fragment.bean.ChatModelBean
import
com.yidianling.im.ui.page.fragment.bean.InteractBean
import
com.yidianling.im.ui.page.fragment.bean.InteractBean
import
com.yidianling.im.ui.page.fragment.bean.NoticeItemBean
import
com.yidianling.im.ui.page.fragment.bean.NoticeItemBean
...
@@ -21,6 +25,14 @@ import retrofit2.http.*
...
@@ -21,6 +25,14 @@ import retrofit2.http.*
*/
*/
interface
ImApi
{
interface
ImApi
{
@POST
(
"call/v2/dial/yunxin"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
nim2Token
(
@Body
body
:
Map
<
String
,
String
>):
Observable
<
BaseResponse
<
String
?>>
@POST
(
"counselor/device/callline"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
reportSupportLine
(
@Body
body
:
Map
<
String
,
@JvmSuppressWildcards
Any
>):
Observable
<
BaseAPIResponse
<
Any
?>>
//获得消息列表
//获得消息列表
@FormUrlEncoded
@FormUrlEncoded
@POST
(
"sms/list"
)
@POST
(
"sms/list"
)
...
...
m-im/src/main/java/com/yidianling/im/http/ImHttpImpl.kt
View file @
d351e3ea
...
@@ -41,7 +41,7 @@ class ImHttpImpl private constructor() : ImHttp {
...
@@ -41,7 +41,7 @@ class ImHttpImpl private constructor() : ImHttp {
private
var
imApi
:
ImApi
?
=
null
private
var
imApi
:
ImApi
?
=
null
private
var
imJavaApi
:
ImApi
?
=
null
private
var
imJavaApi
:
ImApi
?
=
null
private
fun
getImApi
():
ImApi
{
fun
getImApi
():
ImApi
{
if
(
imApi
==
null
)
{
if
(
imApi
==
null
)
{
imApi
=
YDLHttpUtils
.
obtainApi
(
ImApi
::
class
.
java
)
imApi
=
YDLHttpUtils
.
obtainApi
(
ImApi
::
class
.
java
)
}
}
...
...
m-im/src/main/java/com/yidianling/im/router/ImIn.kt
View file @
d351e3ea
...
@@ -27,6 +27,7 @@ import com.yidianling.fm.api.service.IFMService
...
@@ -27,6 +27,7 @@ import com.yidianling.fm.api.service.IFMService
import
com.yidianling.im.api.bean.ReceiveRedPacketParam
import
com.yidianling.im.api.bean.ReceiveRedPacketParam
import
com.yidianling.im.api.service.IImService
import
com.yidianling.im.api.service.IImService
import
com.yidianling.im.config.constants.UserPreferences
import
com.yidianling.im.config.constants.UserPreferences
import
com.yidianling.im.helper.NimUICallInit
import
com.yidianling.im.preference.IMCache
import
com.yidianling.im.preference.IMCache
import
com.yidianling.tests.api.service.ITestsApiService
import
com.yidianling.tests.api.service.ITestsApiService
import
com.yidianling.uikit.api.NimUIKit
import
com.yidianling.uikit.api.NimUIKit
...
@@ -202,6 +203,8 @@ object ImIn {
...
@@ -202,6 +203,8 @@ object ImIn {
IMCache
.
setAccount
(
uid
)
IMCache
.
setAccount
(
uid
)
//此代码进行登录,并且会进行回调
//此代码进行登录,并且会进行回调
NimUIKit
.
login
(
info
,
callback
);
NimUIKit
.
login
(
info
,
callback
);
NimUICallInit
.
reportSupportLine
()
//登录nim时上报支持的线路
}
}
fun
loginIm
(
uid
:
String
,
pwd
:
String
,
callback
:
RequestCallback
<
LoginInfo
>){
fun
loginIm
(
uid
:
String
,
pwd
:
String
,
callback
:
RequestCallback
<
LoginInfo
>){
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/log/XLog.kt
0 → 100644
View file @
d351e3ea
package
com.ydl.ydlcommon.utils.log
import
com.apm.insight.log.VLog
object
XLog
{
fun
d
(
tag
:
String
,
msg
:
String
)
{
VLog
.
i
(
tag
,
msg
)
}
fun
i
(
tag
:
String
,
msg
:
String
)
{
VLog
.
i
(
tag
,
msg
)
}
fun
w
(
tag
:
String
,
msg
:
String
)
{
VLog
.
i
(
tag
,
msg
)
}
fun
e
(
tag
:
String
,
msg
:
String
)
{
VLog
.
e
(
tag
,
msg
)
}
}
\ No newline at end of file
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