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
f81c445c
Commit
f81c445c
authored
Mar 21, 2020
by
严久程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
咨询加声网
parent
2326a717
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
312 additions
and
252 deletions
+312
-252
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+3
-3
DemoAppLifecycles.java
app/src/main/java/com/ydl/component/base/DemoAppLifecycles.java
+11
-7
config.gradle
config.gradle
+5
-5
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+80
-93
YDLavManager.kt
m-audioim/src/main/java/com/ydl/audioim/YDLavManager.kt
+147
-39
ConsultantAudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
+48
-102
audioim_cativity_consultant_audio_home.xml
m-audioim/src/main/res/layout/audioim_cativity_consultant_audio_home.xml
+18
-3
No files found.
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
f81c445c
...
@@ -69,10 +69,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -69,10 +69,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override
fun
initDataAndEvent
()
{
override
fun
initDataAndEvent
()
{
// YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
YDLavManager
.
instances
.
login
(
"13081706"
)
bindService
()
bindService
()
reLoadData
()
//
reLoadData()
requestPermission
()
requestPermission
()
tv_user
.
setOnClickListener
{
tv_user
.
setOnClickListener
{
reLoadData
()
reLoadData
()
...
@@ -111,7 +112,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -111,7 +112,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
startActivity
(
Intent
(
this
,
NewTestHomeActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
NewTestHomeActivity
::
class
.
java
))
}
}
bt_to_confide
.
setOnClickListener
{
bt_to_confide
.
setOnClickListener
{
YDLavManager
.
instances
.
login
(
"1193016"
)
startActivity
(
Intent
(
this
,
ConfideHomeActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
ConfideHomeActivity
::
class
.
java
))
}
}
bt_to_muse
.
setOnClickListener
{
bt_to_muse
.
setOnClickListener
{
...
...
app/src/main/java/com/ydl/component/base/DemoAppLifecycles.java
View file @
f81c445c
...
@@ -17,6 +17,7 @@ import com.umeng.analytics.MobclickAgent;
...
@@ -17,6 +17,7 @@ import com.umeng.analytics.MobclickAgent;
import
com.umeng.commonsdk.UMConfigure
;
import
com.umeng.commonsdk.UMConfigure
;
import
com.umeng.socialize.PlatformConfig
;
import
com.umeng.socialize.PlatformConfig
;
import
com.umeng.socialize.UMShareAPI
;
import
com.umeng.socialize.UMShareAPI
;
import
com.ydl.audioim.YDLavManager
;
import
com.ydl.component.BuildConfig
;
import
com.ydl.component.BuildConfig
;
import
com.ydl.component.MainActivity
;
import
com.ydl.component.MainActivity
;
import
com.ydl.media.audio.PlayService
;
import
com.ydl.media.audio.PlayService
;
...
@@ -49,6 +50,9 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -49,6 +50,9 @@ public class DemoAppLifecycles implements IAppLifecycles {
//模块初始化
//模块初始化
moduleInit
(
application
);
moduleInit
(
application
);
if
(
NIMUtil
.
isMainProcess
(
application
))
{
if
(
NIMUtil
.
isMainProcess
(
application
))
{
YDLavManager
.
Companion
.
getInstances
().
init
(
application
,
"13b1536698f64905a1e7e5bb978ba821"
);
//第三方SDK初始化
//第三方SDK初始化
initThirdServiceSDK
(
application
);
initThirdServiceSDK
(
application
);
//Flutter 初始化需要在主线程中执行
//Flutter 初始化需要在主线程中执行
...
@@ -88,9 +92,9 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -88,9 +92,9 @@ public class DemoAppLifecycles implements IAppLifecycles {
//子线程中初始化X5内核,防止ANR问题
//子线程中初始化X5内核,防止ANR问题
initX5
(
application
);
initX5
(
application
);
if
(
DemoGlobalConfig
.
appEnv
.
equals
(
YDLConstants
.
ENV_PROD
)){
if
(
DemoGlobalConfig
.
appEnv
.
equals
(
YDLConstants
.
ENV_PROD
))
{
// YDLavManager.Companion.getInstances().init(application, "3387e9b251f3491e9221a9877e8f7830");
// YDLavManager.Companion.getInstances().init(application, "3387e9b251f3491e9221a9877e8f7830");
}
else
{
}
else
{
// YDLavManager.Companion.getInstances().init(application, "13b1536698f64905a1e7e5bb978ba821");
// YDLavManager.Companion.getInstances().init(application, "13b1536698f64905a1e7e5bb978ba821");
}
}
...
@@ -110,13 +114,13 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -110,13 +114,13 @@ public class DemoAppLifecycles implements IAppLifecycles {
if
(
BuildConfig
.
FLAVOR
.
endsWith
(
"ydl"
))
{
if
(
BuildConfig
.
FLAVOR
.
endsWith
(
"ydl"
))
{
umAppkey
=
"56970affe0f55a9cda001e24"
;
umAppkey
=
"56970affe0f55a9cda001e24"
;
channel
=
"android_"
+
channel
;
channel
=
"android_"
+
channel
;
initUM
(
umAppkey
,
channel
,
application
);
initUM
(
umAppkey
,
channel
,
application
);
PlatformConfig
.
setWeixin
(
"wx57a9d930270498c7"
,
"17c031f02500ded3457a80e69d8e5e45"
);
PlatformConfig
.
setWeixin
(
"wx57a9d930270498c7"
,
"17c031f02500ded3457a80e69d8e5e45"
);
PlatformConfig
.
setQQZone
(
"1105070461"
,
"6BvkUnk6wXJekcgR"
);
PlatformConfig
.
setQQZone
(
"1105070461"
,
"6BvkUnk6wXJekcgR"
);
}
else
if
(
BuildConfig
.
FLAVOR
.
endsWith
(
"xlzx"
))
{
}
else
if
(
BuildConfig
.
FLAVOR
.
endsWith
(
"xlzx"
))
{
umAppkey
=
"5859e1656e27a42fa400021f"
;
umAppkey
=
"5859e1656e27a42fa400021f"
;
channel
=
"ATK_7_android_"
+
channel
;
channel
=
"ATK_7_android_"
+
channel
;
initUM
(
umAppkey
,
channel
,
application
);
initUM
(
umAppkey
,
channel
,
application
);
PlatformConfig
.
setWeixin
(
"wx1c6af5a11b5f531f"
,
"1ddb93abbb2d81e604657d38e94a5720"
);
PlatformConfig
.
setWeixin
(
"wx1c6af5a11b5f531f"
,
"1ddb93abbb2d81e604657d38e94a5720"
);
PlatformConfig
.
setQQZone
(
"1107931541"
,
"8dCvxUpi525uPGTJ"
);
PlatformConfig
.
setQQZone
(
"1107931541"
,
"8dCvxUpi525uPGTJ"
);
}
}
...
@@ -139,7 +143,6 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -139,7 +143,6 @@ public class DemoAppLifecycles implements IAppLifecycles {
}
}
private
void
initUM
(
String
umAppKey
,
String
channel
,
Application
application
)
{
private
void
initUM
(
String
umAppKey
,
String
channel
,
Application
application
)
{
/**
/**
* 初始化common库
* 初始化common库
...
@@ -156,6 +159,7 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -156,6 +159,7 @@ public class DemoAppLifecycles implements IAppLifecycles {
/**
/**
* 初始化X5内核
* 初始化X5内核
*
* @param application
* @param application
*/
*/
private
void
initX5
(
Application
application
)
{
private
void
initX5
(
Application
application
)
{
...
@@ -173,7 +177,7 @@ public class DemoAppLifecycles implements IAppLifecycles {
...
@@ -173,7 +177,7 @@ public class DemoAppLifecycles implements IAppLifecycles {
@Override
@Override
public
void
onViewInitFinished
(
boolean
arg0
)
{
public
void
onViewInitFinished
(
boolean
arg0
)
{
//初始化完成回调
//初始化完成回调
LogUtil
.
i
(
"QbSdk onViewInitFinished:"
+
arg0
);
LogUtil
.
i
(
"QbSdk onViewInitFinished:"
+
arg0
);
}
}
@Override
@Override
...
...
config.gradle
View file @
f81c445c
...
@@ -5,8 +5,8 @@ ext {
...
@@ -5,8 +5,8 @@ ext {
ydl_app
=
[
ydl_app
=
[
appName
:
"心理咨询壹点灵"
,
appName
:
"心理咨询壹点灵"
,
applicationId:
"com.cxzapp.yidianling"
,
applicationId:
"com.cxzapp.yidianling"
,
versionName
:
"4.0.
31
"
,
versionName
:
"4.0.
99
"
,
versionCode
:
40
31
,
versionCode
:
40
99
,
]
]
xlzx_app
=
[
xlzx_app
=
[
...
@@ -42,7 +42,7 @@ ext {
...
@@ -42,7 +42,7 @@ ext {
ydlPublishVersion
=
[
ydlPublishVersion
=
[
// -------------- 业务模块 --------------
// -------------- 业务模块 --------------
//第三步 若干
//第三步 若干
"m-confide"
:
"0.0.48.7.
5
"
,
"m-confide"
:
"0.0.48.7.
6
"
,
"m-consultant"
:
"0.0.57.4"
,
"m-consultant"
:
"0.0.57.4"
,
"m-fm"
:
"0.0.29.3"
,
"m-fm"
:
"0.0.29.3"
,
"m-user"
:
"0.0.58.2"
,
"m-user"
:
"0.0.58.2"
,
...
@@ -75,7 +75,7 @@ ext {
...
@@ -75,7 +75,7 @@ ext {
"ydl-webview"
:
"0.0.37.1"
,
"ydl-webview"
:
"0.0.37.1"
,
"ydl-media"
:
"0.0.20"
,
"ydl-media"
:
"0.0.20"
,
"ydl-pay"
:
"0.0.17"
,
"ydl-pay"
:
"0.0.17"
,
"m-audioim"
:
"0.0.48.2.
5
"
,
"m-audioim"
:
"0.0.48.2.
6
"
,
"ydl-flutter-base"
:
"0.0.10.9"
,
"ydl-flutter-base"
:
"0.0.10.9"
,
//以下 几乎不会动
//以下 几乎不会动
...
@@ -121,7 +121,7 @@ ext {
...
@@ -121,7 +121,7 @@ ext {
"ydl-webview"
:
"0.0.37.1"
,
"ydl-webview"
:
"0.0.37.1"
,
"ydl-media"
:
"0.0.20"
,
"ydl-media"
:
"0.0.20"
,
"ydl-pay"
:
"0.0.17"
,
"ydl-pay"
:
"0.0.17"
,
"m-audioim"
:
"0.0.48.2.
5
"
,
"m-audioim"
:
"0.0.48.2.
6
"
,
"ydl-flutter-base"
:
"0.0.10.9"
,
"ydl-flutter-base"
:
"0.0.10.9"
,
//以下 几乎不会动
//以下 几乎不会动
...
...
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
f81c445c
...
@@ -483,100 +483,81 @@ class AudioHomeActivity :
...
@@ -483,100 +483,81 @@ class AudioHomeActivity :
}
}
private
fun
setCallBack
()
{
private
fun
setCallBack
()
{
/**
//RTC 回调
* RTC 回调 在[YDLavManager.setCallback]中注册使用
YDLRTMClient
.
instances
.
setCallListener
(
object
:
CallListener
{
*/
override
fun
onCallRecivedByPeer
(
response
:
CallLocalResponse
?)
{
// //RTC 回调
playWaitingMusic
()
// YDLRTMClient.instances.setCallListener(object : CallListener {
//返回给主叫:被叫已收到呼叫邀请
// override fun onCallRecivedByPeer(response: CallLocalResponse?) {
LogUtil
.
i
(
"[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}"
)
// playWaitingMusic()
}
// //返回给主叫:被叫已收到呼叫邀请
// LogUtil.i("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}")
override
fun
onCallAccepted
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
// }
//返回给主叫
//
LogUtil
.
i
(
"[agora]${response?.calleeId}已接受呼叫邀请"
)
// override fun onCallAccepted(response: CallLocalResponse?, msg: String?) {
//加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道
// //返回给主叫
joinChannel
()
// LogUtil.i("[agora]${response?.calleeId}已接受呼叫邀请")
}
// //加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道
// joinChannel()
override
fun
onCallRefused
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
// }
//返回给主叫
//
LogUtil
.
i
(
"[agora]${response?.calleeId}已拒绝呼叫邀请"
)
// override fun onCallRefused(response: CallLocalResponse?, msg: String?) {
ToastUtil
.
showToast
(
applicationContext
,
"对方已挂断"
)
// //返回给主叫
//通话结束或挂断时,上传日志文件
// LogUtil.i("[agora]${response?.calleeId}已拒绝呼叫邀请")
uploadLog
()
// ToastUtil.showToast(applicationContext, "对方已挂断")
leaveChannel
()
// //通话结束或挂断时,上传日志文件
}
// uploadLog()
// leaveChannel()
override
fun
onCallCanceled
(
response
:
CallLocalResponse
?)
{
// }
//返回给主叫
//
LogUtil
.
i
(
"[agora]主叫已取消呼叫邀请"
)
// override fun onCallCanceled(response: CallLocalResponse?) {
}
// //返回给主叫
// LogUtil.i("[agora]主叫已取消呼叫邀请")
override
fun
onCallFailure
(
response
:
CallLocalResponse
?,
errorCode
:
Int
)
{
// }
//返回给主叫
//
LogUtil
.
i
(
"[agora]呼叫${response?.calleeId}用户失败:${response?.response}"
)
// override fun onCallFailure(response: CallLocalResponse?, errorCode: Int) {
//专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
// //返回给主叫
when
(
errorCode
)
{
// LogUtil.i("[agora]呼叫${response?.calleeId}用户失败:${response?.response}")
//被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
// //专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_PEER_OFFLINE
,
// when (errorCode) {
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_PEER_NO_RESPONSE
->
{
// //被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
YDLRTMClient
.
instances
.
call
(
listenerUid
!!
,
channelId
,
sendDoctocrMsg
)
// RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_OFFLINE,
}
// RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_NO_RESPONSE -> {
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_INVITATION_EXPIRE
->
{
//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
// rtcCall()
// }
}
// RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> {//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
}
//
}
// }
// }
override
fun
onRemoteInvitationReceived
(
response
:
CallRemoteResponse
?)
{
// }
//返回给被叫
//
LogUtil
.
i
(
"[agora]收到来自${response?.callerId}的呼叫邀请"
)
// override fun onRemoteInvitationReceived(response: CallRemoteResponse?) {
}
// //返回给被叫
// LogUtil.i("[agora]收到来自${response?.callerId}的呼叫邀请")
override
fun
onRemoteInvitationAccepted
(
response
:
CallRemoteResponse
?)
{
// }
//返回给被叫
//
LogUtil
.
i
(
"[agora]接受来自${response?.callerId}的呼叫成功"
)
// override fun onRemoteInvitationAccepted(response: CallRemoteResponse?) {
}
// //返回给被叫
// LogUtil.i("[agora]接受来自${response?.callerId}的呼叫成功")
override
fun
onRemoteInvitationRefused
(
response
:
CallRemoteResponse
?)
{
// }
//返回给被叫
//
LogUtil
.
i
(
"[agora]已拒绝来自${response?.callerId}的呼叫"
)
// override fun onRemoteInvitationRefused(response: CallRemoteResponse?) {
}
// //返回给被叫
// LogUtil.i("[agora]已拒绝来自${response?.callerId}的呼叫")
override
fun
onRemoteInvitationCanceled
(
response
:
CallRemoteResponse
?)
{
//返回给被叫
LogUtil
.
i
(
"[agora]主叫${response?.callerId}已取消呼叫邀请"
)
}
override
fun
onRemoteInvitationFailure
(
response
:
CallRemoteResponse
?,
errorCode
:
Int
)
{
//返回给被叫
LogUtil
.
i
(
"[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}"
)
}
override
fun
onOtherMsg
(
error
:
String
?)
{
LogUtil
.
i
(
"[agora]其它消息:${error}"
)
}
})
// channelManager = YDLRTMClient.instances.createChannelManager(channelId, object : ChannelListener {
// override fun onMemberCountUpdated(memberCount: Int) {
// //频道人数更新
// LogUtil.i("[agora]当前频道人数:$memberCount")
// }
// }
//
//
// override fun on
MessageReceived(message: RTMMesssage?, member: ChannelMember
?) {
// override fun on
RemoteInvitationCanceled(response: CallRemoteResponse
?) {
// //
接到频道消息
// //
返回给被叫
// LogUtil.i("[agora]
接到${member?.channelId}频道${member?.userId}的消息:" + message?.text
)
// LogUtil.i("[agora]
主叫${response?.callerId}已取消呼叫邀请"
)
// }
// }
//
//
// override fun on
MemberJoined(member: ChannelMember?
) {
// override fun on
RemoteInvitationFailure(response: CallRemoteResponse?, errorCode: Int
) {
// //
新用户加入频道
// //
返回给被叫
// LogUtil.i("[agora]
新用户加入${member?.channelId}频道:${member?.userId
}")
// LogUtil.i("[agora]
来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response
}")
// }
// }
//
//
// override fun on
MemberLeft(member: ChannelMember
?) {
// override fun on
OtherMsg(error: String
?) {
// LogUtil.i("[agora]
有用户离开${member?.channelId}频道:${member?.userId
}")
// LogUtil.i("[agora]
其它消息:${error
}")
// }
// }
// })
// })
}
}
...
@@ -626,7 +607,8 @@ class AudioHomeActivity :
...
@@ -626,7 +607,8 @@ class AudioHomeActivity :
)
)
sendDoctocrMsg
=
Gson
().
toJson
(
msgBean
)
sendDoctocrMsg
=
Gson
().
toJson
(
msgBean
)
YDLRTMClient
.
instances
.
call
(
listenerUid
!!
,
channelId
,
sendDoctocrMsg
)
rtcCall
()
Observable
.
interval
(
0
,
100
,
TimeUnit
.
MILLISECONDS
)
Observable
.
interval
(
0
,
100
,
TimeUnit
.
MILLISECONDS
)
.
subscribeOn
(
Schedulers
.
computation
())
.
subscribeOn
(
Schedulers
.
computation
())
...
@@ -670,6 +652,11 @@ class AudioHomeActivity :
...
@@ -670,6 +652,11 @@ class AudioHomeActivity :
noticeServerPush
(
true
)
noticeServerPush
(
true
)
}
}
fun
rtcCall
(){
YDLRTMClient
.
instances
.
call
(
listenerUid
!!
,
channelId
,
sendDoctocrMsg
)
}
/**
/**
* 声网初始化
* 声网初始化
*/
*/
...
@@ -689,7 +676,7 @@ class AudioHomeActivity :
...
@@ -689,7 +676,7 @@ class AudioHomeActivity :
/**
/**
* 声网加入频道
* 声网加入频道
*/
*/
private
fun
joinChannel
()
{
fun
joinChannel
()
{
voiceManage
!!
.
getVoiceApi
().
joinChannel
(
voiceManage
!!
.
getVoiceApi
().
joinChannel
(
token
!!
,
token
!!
,
channelId
!!
,
channelId
!!
,
...
@@ -874,7 +861,7 @@ class AudioHomeActivity :
...
@@ -874,7 +861,7 @@ class AudioHomeActivity :
/**
/**
* 播放等待音频
* 播放等待音频
*/
*/
private
fun
playWaitingMusic
()
{
fun
playWaitingMusic
()
{
if
(
mPlayer
==
null
)
{
if
(
mPlayer
==
null
)
{
mPlayer
=
AudioPlayer
(
this
)
mPlayer
=
AudioPlayer
(
this
)
}
}
...
@@ -1046,7 +1033,7 @@ class AudioHomeActivity :
...
@@ -1046,7 +1033,7 @@ class AudioHomeActivity :
/**
/**
* 声网离开频道
* 声网离开频道
*/
*/
private
fun
leaveChannel
()
{
fun
leaveChannel
()
{
if
(!
isLeavelChannel
)
{
if
(!
isLeavelChannel
)
{
isLeavelChannel
=
true
isLeavelChannel
=
true
//刷新h5页面
//刷新h5页面
...
@@ -1123,7 +1110,7 @@ class AudioHomeActivity :
...
@@ -1123,7 +1110,7 @@ class AudioHomeActivity :
}
}
private
fun
uploadLog
()
{
fun
uploadLog
()
{
if
(!
hasUpLoadLog
)
{
if
(!
hasUpLoadLog
)
{
hasUpLoadLog
=
true
hasUpLoadLog
=
true
LogHelper
.
getInstance
().
uploadLog
(
false
)
LogHelper
.
getInstance
().
uploadLog
(
false
)
...
...
m-audioim/src/main/java/com/ydl/audioim/YDLavManager.kt
View file @
f81c445c
...
@@ -3,20 +3,29 @@ package com.ydl.audioim
...
@@ -3,20 +3,29 @@ package com.ydl.audioim
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
android.text.TextUtils
import
android.text.TextUtils
import
com.alibaba.android.arouter.launcher.ARouter
import
com.ydl.audioim.http.AudioApiRequestUtil
import
com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.consultantim.ConsultantAudioHomeActivity
import
com.ydl.ydl_av.messge_service.YDLRTMClient
import
com.ydl.ydl_av.messge_service.YDLRTMClient
import
com.ydl.ydl_av.messge_service.bean.RTMMesssage
import
com.ydl.ydl_av.messge_service.bean.RTMMesssage
import
com.ydl.ydl_av.messge_service.callback.CallListener
import
com.ydl.ydl_av.messge_service.callback.InitListener
import
com.ydl.ydl_av.messge_service.callback.InitListener
import
com.ydl.ydl_av.messge_service.callback.LoginCallback
import
com.ydl.ydl_av.messge_service.callback.LoginCallback
import
com.ydl.ydl_av.messge_service.request.LoginParam
import
com.ydl.ydl_av.messge_service.request.LoginParam
import
com.ydl.audioim.http.AudioApiRequestUtil
import
com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.ydl_av.messge_service.callback.CallListener
import
com.ydl.ydl_av.messge_service.response.CallLocalResponse
import
com.ydl.ydl_av.messge_service.response.CallLocalResponse
import
com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import
com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.utils.ActivityManager
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.user.api.service.IUserService
import
io.agora.rtm.RtmStatusCode
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
java.util.concurrent.TimeUnit
/**
/**
* @author harvie
* @author harvie
...
@@ -26,86 +35,130 @@ import io.reactivex.schedulers.Schedulers
...
@@ -26,86 +35,130 @@ import io.reactivex.schedulers.Schedulers
class
YDLavManager
{
class
YDLavManager
{
companion
object
{
companion
object
{
val
instances
:
YDLavManager
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
val
instances
:
YDLavManager
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
YDLavManager
()
YDLavManager
()
}
}
}
}
private
constructor
()
private
constructor
()
fun
init
(
context
:
Context
,
appId
:
String
)
{
fun
init
(
context
:
Context
,
appId
:
String
)
{
YDLRTMClient
.
instances
.
init
(
context
,
appId
,
listener
)
YDLRTMClient
.
instances
.
init
(
context
,
appId
,
listener
)
//设置回调
//设置回调
setCallback
()
setCallback
()
}
}
fun
setCallback
()
{
private
fun
setCallback
()
{
YDLRTMClient
.
instances
.
setCallListener
(
object
:
CallListener
{
YDLRTMClient
.
instances
.
setCallListener
(
object
:
CallListener
{
override
fun
onCallRecivedByPeer
(
response
:
CallLocalResponse
?)
{
override
fun
onCallRecivedByPeer
(
response
:
CallLocalResponse
?)
{
//返回给主叫:被叫已收到呼叫邀请
//返回给主叫:被叫已收到呼叫邀请
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}"
)
LogUtil
.
e
(
"[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}"
)
val
act
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
act
is
AudioHomeActivity
)
{
act
.
runOnUiThread
{
act
.
playWaitingMusic
()
}
}
}
}
override
fun
onCallAccepted
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
override
fun
onCallAccepted
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
//返回给主叫
//返回给主叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]${response?.calleeId}已接收呼叫邀请"
)
LogUtil
.
e
(
"[agora]${response?.calleeId}已接收呼叫邀请"
)
//加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道
val
act
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
act
is
AudioHomeActivity
)
{
act
.
runOnUiThread
{
act
.
joinChannel
()
}
}
}
}
override
fun
onCallRefused
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
override
fun
onCallRefused
(
response
:
CallLocalResponse
?,
msg
:
String
?)
{
//返回给主叫
//返回给主叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]${response?.calleeId}已拒绝呼叫邀请"
)
LogUtil
.
e
(
"[agora]${response?.calleeId}已拒绝呼叫邀请"
)
val
act
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
act
is
AudioHomeActivity
)
{
act
.
runOnUiThread
{
ToastUtil
.
toastShort
(
"对方已挂断"
)
//通话结束或挂断时,上传日志文件
act
.
uploadLog
()
act
.
leaveChannel
()
}
}
}
}
override
fun
onCallCanceled
(
response
:
CallLocalResponse
?)
{
override
fun
onCallCanceled
(
response
:
CallLocalResponse
?)
{
//返回给主叫
//返回给主叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]主叫已取消呼叫邀请"
)
LogUtil
.
e
(
"[agora]主叫已取消呼叫邀请"
)
}
}
override
fun
onCallFailure
(
response
:
CallLocalResponse
?,
errorCode
:
Int
)
{
override
fun
onCallFailure
(
response
:
CallLocalResponse
?,
errorCode
:
Int
)
{
//返回给主叫
//返回给主叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]呼叫${response?.calleeId}用户失败:${response?.response}"
)
LogUtil
.
e
(
"[agora]呼叫${response?.calleeId}用户失败:${response?.response}"
)
//专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
when
(
errorCode
)
{
//被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_PEER_OFFLINE
,
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_PEER_NO_RESPONSE
->
{
val
act
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
act
is
AudioHomeActivity
)
{
act
.
runOnUiThread
{
act
.
rtcCall
()
}
}
}
RtmStatusCode
.
LocalInvitationError
.
LOCAL_INVITATION_ERR_INVITATION_EXPIRE
->
{
//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
}
}
}
}
override
fun
onRemoteInvitationReceived
(
response
:
CallRemoteResponse
?)
{
override
fun
onRemoteInvitationReceived
(
response
:
CallRemoteResponse
?)
{
//返回给被叫
//返回给被叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]收到来自${response?.callerId}的呼叫邀请"
)
LogUtil
.
e
(
"[agora]收到来自${response?.callerId}的呼叫邀请"
)
receivedCall
(
response
?.
content
)
receivedCall
(
response
?.
content
)
}
}
override
fun
onRemoteInvitationAccepted
(
response
:
CallRemoteResponse
?)
{
override
fun
onRemoteInvitationAccepted
(
response
:
CallRemoteResponse
?)
{
//返回给被叫
//返回给被叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]接受来自${response?.callerId}的呼叫成功"
)
LogUtil
.
e
(
"[agora]接受来自${response?.callerId}的呼叫成功"
)
}
}
override
fun
onRemoteInvitationRefused
(
response
:
CallRemoteResponse
?)
{
override
fun
onRemoteInvitationRefused
(
response
:
CallRemoteResponse
?)
{
//返回给被叫
//返回给被叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]已拒绝来自${response?.callerId}的呼叫"
)
LogUtil
.
e
(
"[agora]已拒绝来自${response?.callerId}的呼叫"
)
}
}
override
fun
onRemoteInvitationCanceled
(
response
:
CallRemoteResponse
?)
{
override
fun
onRemoteInvitationCanceled
(
response
:
CallRemoteResponse
?)
{
//返回给被叫
//返回给被叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]主叫${response?.callerId}已取消呼叫邀请"
)
LogUtil
.
e
(
"[agora]主叫${response?.callerId}已取消呼叫邀请"
)
closePage
(
true
)
closePage
()
}
}
override
fun
onRemoteInvitationFailure
(
response
:
CallRemoteResponse
?,
errorCode
:
Int
)
{
override
fun
onRemoteInvitationFailure
(
response
:
CallRemoteResponse
?,
errorCode
:
Int
)
{
//返回给被叫
//返回给被叫
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}"
)
LogUtil
.
e
(
"[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}"
)
//关闭页面
//关闭页面
closePage
(
true
)
closePage
()
}
}
override
fun
onOtherMsg
(
error
:
String
?)
{
override
fun
onOtherMsg
(
error
:
String
?)
{
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"[agora]其它消息:${error}"
)
LogUtil
.
e
(
"[agora]其它消息:${error}"
)
}
}
})
})
}
}
@SuppressLint
(
"CheckResult"
)
@SuppressLint
(
"CheckResult"
)
fun
login
(
userId
:
String
?)
{
fun
login
(
userId
:
String
?)
{
if
(
TextUtils
.
isEmpty
(
userId
)
||
userId
?:
"0"
<=
"0"
)
{
if
(
TextUtils
.
isEmpty
(
userId
)
||
userId
?:
"0"
<=
"0"
)
{
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
LogUtil
.
e
(
"[agora]login-uid:$userId"
)
LogUtil
.
e
(
"[agora]login-uid:$userId"
)
return
return
...
@@ -113,34 +166,88 @@ class YDLavManager {
...
@@ -113,34 +166,88 @@ class YDLavManager {
//登录实时消息
//登录实时消息
//获取token
//获取token
AudioApiRequestUtil
.
getAgoraToken
()
AudioApiRequestUtil
.
getAgoraToken
()
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
.
subscribe
({
if
(
"200"
.
equals
(
it
.
code
)){
if
(
"200"
.
equals
(
it
.
code
))
{
YDLRTMClient
.
instances
.
login
(
LoginParam
(
userId
,
it
.
data
.
token
),
object
:
LoginCallback
{
YDLRTMClient
.
instances
.
login
(
LoginParam
(
userId
,
it
.
data
.
token
),
object
:
LoginCallback
{
override
fun
onSuccess
()
{
override
fun
onSuccess
()
{
//登陆成功,发起呼叫
//登陆成功,发起呼叫
LogUtil
.
d
(
"[agora]实时消息登录成功"
)
LogUtil
.
e
(
"[agora]实时消息登录成功"
)
}
}
override
fun
onFailure
(
msg
:
String
?)
{
override
fun
onFailure
(
msg
:
String
?)
{
LogUtil
.
d
(
"[agora]实时消息登录失败:$msg"
)
LogUtil
.
e
(
"[agora]实时消息登录失败:$msg"
)
}
}
})
})
}
else
{
}
else
{
LogUtil
.
e
(
"声网token获取失败uid:"
+
userId
+
" error:"
+
it
.
msg
)
LogUtil
.
e
(
"声网token获取失败uid:"
+
userId
+
" error:"
+
it
.
msg
)
LogHelper
.
getInstance
().
writeLogSync
(
"声网token获取失败uid:"
+
userId
+
" error:"
+
it
.
msg
)
LogHelper
.
getInstance
()
.
writeLogSync
(
"声网token获取失败uid:"
+
userId
+
" error:"
+
it
.
msg
)
}
},
{
LogUtil
.
e
(
"声网token获取异常uid:"
+
userId
+
" error:"
+
it
.
message
)
})
}
/**
* 收到邀请
*/
@SuppressLint
(
"CheckResult"
)
fun
receivedCall
(
content
:
String
?)
{
if
(!
TextUtils
.
isEmpty
(
content
))
{
//如果已经接听了用户电话 再有电话进来 是不能接听的
if
(!
activityIsExists
(
ConsultantAudioHomeActivity
::
class
.
java
)
||
ActivityManager
.
getInstance
().
getTopTaskActivity
()
!
is
AudioHomeActivity
)
{
//延时启动通话界面,防止刚打开就被main遮挡
Observable
.
timer
(
1000
,
TimeUnit
.
MILLISECONDS
).
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
LogUtil
.
e
(
"[agora]启动通话界面"
)
//邀请加入频道消息,跳转通话界面
ARouter
.
getInstance
().
build
(
"/av/ConsultantAudioHomeActivity"
)
.
withString
(
"param"
,
content
)
.
navigation
()
}
}
},{
}
else
{
LogUtil
.
e
(
"声网token获取异常uid:"
+
userId
+
" error:"
+
it
.
message
)
LogUtil
.
d
(
"[agora]收到声网邀请,但界面实例已存在"
)
})
}
}
else
{
LogUtil
.
d
(
"[agora]收到声网邀请,但response==null"
)
}
}
private
fun
activityIsExists
(
cls
:
Class
<*>):
Boolean
{
for
(
activity
in
ActivityManager
.
getInstance
().
getActivitys
())
{
if
(
activity
.
javaClass
==
cls
)
{
return
true
}
}
return
false
}
}
/**
* 关闭通话界面
*/
fun
closePage
()
{
var
act
=
ActivityManager
.
getInstance
().
getTopTaskActivity
()
if
(
act
is
ConsultantAudioHomeActivity
)
{
//未接通时,收到呼叫进程失败关闭页面,已接通无需关闭
if
(
act
.
status
==
ConsultantAudioHomeActivity
.
STATUS_NOT_ANSWERED
)
{
act
.
close
(
ConsultantAudioHomeActivity
.
RESULT_USER_CANCEL
,
""
)
}
}
}
/**
/**
* 退出登录
* 退出登录
*/
*/
fun
logout
(){
fun
logout
()
{
YDLRTMClient
.
instances
.
logout
(
object
:
LoginCallback
{
YDLRTMClient
.
instances
.
logout
(
object
:
LoginCallback
{
override
fun
onSuccess
()
{
override
fun
onSuccess
()
{
//退出登陆成功
//退出登陆成功
...
@@ -166,17 +273,18 @@ class YDLavManager {
...
@@ -166,17 +273,18 @@ class YDLavManager {
.
subscribe
({
.
subscribe
({
},
{
},
{
com
.
yidianling
.
common
.
tools
.
LogUtil
.
e
(
"agora"
,
"声网上传异常与错误日志接口调用失败:"
+
it
.
message
)
LogUtil
.
e
(
"agora"
,
"声网上传异常与错误日志接口调用失败:"
+
it
.
message
)
})
})
}
}
/**
/**
* 实时消息全局监听
* 实时消息全局监听
*/
*/
private
val
listener
=
object
:
InitListener
{
private
val
listener
=
object
:
InitListener
{
override
fun
onTokenExpired
()
{
override
fun
onTokenExpired
()
{
LogUtil
.
e
(
"[agora]onTokenExpired"
)
LogUtil
.
e
(
"[agora]onTokenExpired"
)
instances
.
login
(
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
uid
)
}
}
override
fun
onMessageReceived
(
message
:
RTMMesssage
,
userId
:
Int
)
{
override
fun
onMessageReceived
(
message
:
RTMMesssage
,
userId
:
Int
)
{
...
...
m-audioim/src/main/java/com/ydl/consultantim/ConsultantAudioHomeActivity.kt
View file @
f81c445c
...
@@ -27,6 +27,7 @@ import com.ydl.audioim.http.command.ConnectExceptionCommand
...
@@ -27,6 +27,7 @@ import com.ydl.audioim.http.command.ConnectExceptionCommand
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.http.command.PayLoad
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.player.AudioPlayer
import
com.ydl.audioim.utils.AudioLogUtils
import
com.ydl.audioim.utils.AudioLogUtils
import
com.ydl.audioim.utils.DateUtils
import
com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
import
com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
import
com.ydl.consultantim.event.AudioHomeEvent
import
com.ydl.consultantim.event.AudioHomeEvent
import
com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl
import
com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl
...
@@ -38,7 +39,6 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
...
@@ -38,7 +39,6 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import
com.ydl.ydl_av.voice.manager.YDLVoiceManager
import
com.ydl.ydl_av.voice.manager.YDLVoiceManager
import
com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.config.SimpleImageOpConfiger
import
com.ydl.ydl_image.manager.YDLImageCacheManager
import
com.ydl.ydl_image.manager.YDLImageCacheManager
import
com.ydl.ydl_router.manager.YDLRouterManager
import
com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.router.YdlCommonRouterManager
import
com.ydl.ydlcommon.router.YdlCommonRouterManager
...
@@ -49,17 +49,16 @@ import com.ydl.ydlcommon.utils.Utils
...
@@ -49,17 +49,16 @@ import com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.RxActivityTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.user.api.service.IUserService
import
com.yidianling.user.api.service.IUserService
import
de.greenrobot.event.EventBus
import
de.greenrobot.event.EventBus
import
io.agora.rtc.IRtcEngineEventHandler
import
io.agora.rtc.IRtcEngineEventHandler
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.disposables.Disposable
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.*
import
kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.*
import
org.reactivestreams.Subscription
import
java.util.concurrent.TimeUnit
/**
/**
* @author jiucheng
* @author jiucheng
...
@@ -68,7 +67,7 @@ import org.reactivestreams.Subscription
...
@@ -68,7 +67,7 @@ import org.reactivestreams.Subscription
* @Company 壹点灵
* @Company 壹点灵
* @date 2018/10/30
* @date 2018/10/30
*/
*/
@Route
(
path
=
"/av/AudioHomeActivity"
)
@Route
(
path
=
"/av/
Consultant
AudioHomeActivity"
)
class
ConsultantAudioHomeActivity
:
class
ConsultantAudioHomeActivity
:
BaseMvpActivity
<
IConsultantAudioHomeActivityContract
.
View
,
IConsultantAudioHomeActivityContract
.
Presenter
>(),
BaseMvpActivity
<
IConsultantAudioHomeActivityContract
.
View
,
IConsultantAudioHomeActivityContract
.
Presenter
>(),
IConsultantAudioHomeActivityContract
.
View
,
IConsultantAudioHomeActivityContract
.
View
,
...
@@ -97,16 +96,12 @@ class ConsultantAudioHomeActivity :
...
@@ -97,16 +96,12 @@ class ConsultantAudioHomeActivity :
*/
*/
private
var
totalDisposable
:
Disposable
?
=
null
private
var
totalDisposable
:
Disposable
?
=
null
private
var
ensureDialog
:
CommonDialog
?
=
null
//频道管理器
//频道管理器
// private var channelManager: ChannelManager? = null
// private var channelManager: ChannelManager? = null
//频道token
//频道token
private
var
channelToken
:
String
?
=
null
private
var
channelToken
:
String
?
=
null
private
var
hasUpLoadLog
=
false
private
var
hasUpLoadLog
=
false
private
var
dialog
:
CommonDialog
?
=
null
/**
/**
* 事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
* 事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
*/
...
@@ -119,7 +114,7 @@ class ConsultantAudioHomeActivity :
...
@@ -119,7 +114,7 @@ class ConsultantAudioHomeActivity :
*/
*/
override
fun
onUserMuteAudio
(
uid
:
Int
,
muted
:
Boolean
)
{
override
fun
onUserMuteAudio
(
uid
:
Int
,
muted
:
Boolean
)
{
runOnUiThread
{
runOnUiThread
{
showLongToast
(
"
[agora]
对方静音了,提醒他打开!"
)
showLongToast
(
"对方静音了,提醒他打开!"
)
}
}
}
}
...
@@ -149,19 +144,13 @@ class ConsultantAudioHomeActivity :
...
@@ -149,19 +144,13 @@ class ConsultantAudioHomeActivity :
override
fun
onRtcStats
(
stats
:
IRtcEngineEventHandler
.
RtcStats
?)
{
override
fun
onRtcStats
(
stats
:
IRtcEngineEventHandler
.
RtcStats
?)
{
if
(
null
!=
stats
?.
users
&&
stats
.
users
==
1
)
{
ToastUtil
.
toastShort
(
"用户已挂断"
)
//通话结束或挂断时,上传日志文件
uploadLog
()
leaveChannel
()
}
}
}
override
fun
onConnectionStateChanged
(
state
:
Int
,
reason
:
Int
)
{
override
fun
onConnectionStateChanged
(
state
:
Int
,
reason
:
Int
)
{
super
.
onConnectionStateChanged
(
state
,
reason
)
super
.
onConnectionStateChanged
(
state
,
reason
)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if
(
reason
==
3
)
{
if
(
reason
==
3
)
{
ToastUtil
.
toastShort
(
"
用户
已挂断"
)
ToastUtil
.
toastShort
(
"
对方
已挂断"
)
//通话结束或挂断时,上传日志文件
//通话结束或挂断时,上传日志文件
uploadLog
()
uploadLog
()
leaveChannel
()
leaveChannel
()
...
@@ -198,7 +187,7 @@ class ConsultantAudioHomeActivity :
...
@@ -198,7 +187,7 @@ class ConsultantAudioHomeActivity :
super
.
onUserOffline
(
uid
,
elapsed
)
super
.
onUserOffline
(
uid
,
elapsed
)
LogUtil
.
e
(
"[agora]$uid 主播离开频道回调"
)
LogUtil
.
e
(
"[agora]$uid 主播离开频道回调"
)
runOnUiThread
{
runOnUiThread
{
showLongToast
(
"
用户
已挂断"
)
showLongToast
(
"
对方
已挂断"
)
//通话结束或挂断时,上传日志文件
//通话结束或挂断时,上传日志文件
uploadLog
()
uploadLog
()
if
(
null
!=
totalDisposable
)
{
if
(
null
!=
totalDisposable
)
{
...
@@ -283,7 +272,7 @@ class ConsultantAudioHomeActivity :
...
@@ -283,7 +272,7 @@ class ConsultantAudioHomeActivity :
close
(
RESULT_NOT_ANSWERED_CODE
,
"频道错误,请联系技术"
)
close
(
RESULT_NOT_ANSWERED_CODE
,
"频道错误,请联系技术"
)
}
}
123
->
{
123
->
{
showLongToast
(
"
当前用户
不允许接听电话,请联系客服"
)
showLongToast
(
"
对方
不允许接听电话,请联系客服"
)
close
(
RESULT_NOT_ANSWERED_CODE
,
"该专家不允许接听电话,请联系客服"
)
close
(
RESULT_NOT_ANSWERED_CODE
,
"该专家不允许接听电话,请联系客服"
)
}
}
else
->
{
else
->
{
...
@@ -415,26 +404,6 @@ class ConsultantAudioHomeActivity :
...
@@ -415,26 +404,6 @@ class ConsultantAudioHomeActivity :
// }
// }
// })
// })
// channelManager = YDLRTMClient.instances.createChannelManager(mAudioMessageBean?.channelId, object : ChannelListener {
// override fun onMemberCountUpdated(memberCount: Int) {
// //频道人数更新
// com.yidianling.common.tools.LogUtil.i("[agora]当前频道人数:$memberCount")
// }
//
// override fun onMessageReceived(message: RTMMesssage?, member: ChannelMember?) {
// //接到频道消息
// com.yidianling.common.tools.LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:" + message?.text)
// }
//
// override fun onMemberJoined(member: ChannelMember?) {
// //新用户加入频道
// com.yidianling.common.tools.LogUtil.i("[agora]新用户加入${member?.channelId}频道:${member?.userId}")
// }
//
// override fun onMemberLeft(member: ChannelMember?) {
// com.yidianling.common.tools.LogUtil.i("[agora]有用户离开${member?.channelId}频道:${member?.userId}")
// }
// })
}
}
@SuppressLint
(
"InvalidWakeLockTag"
)
@SuppressLint
(
"InvalidWakeLockTag"
)
...
@@ -452,7 +421,7 @@ class ConsultantAudioHomeActivity :
...
@@ -452,7 +421,7 @@ class ConsultantAudioHomeActivity :
* 初始化界面用户信息
* 初始化界面用户信息
*/
*/
private
fun
initUser
()
{
private
fun
initUser
()
{
var
userName
=
"
倾诉
用户"
var
userName
=
"
咨询
用户"
if
(
null
!=
mAudioMessageBean
)
{
if
(
null
!=
mAudioMessageBean
)
{
if
(!
TextUtils
.
isEmpty
(
mAudioMessageBean
!!
.
userName
))
{
if
(!
TextUtils
.
isEmpty
(
mAudioMessageBean
!!
.
userName
))
{
userName
=
mAudioMessageBean
!!
.
userName
!!
userName
=
mAudioMessageBean
!!
.
userName
!!
...
@@ -586,7 +555,7 @@ class ConsultantAudioHomeActivity :
...
@@ -586,7 +555,7 @@ class ConsultantAudioHomeActivity :
override
fun
executeFinish
()
{
override
fun
executeFinish
()
{
//通话结束或挂断时,上传日志文件
//通话结束或挂断时,上传日志文件
uploadLog
()
uploadLog
()
ToastUtil
.
toastShort
(
"
用户
已挂断"
)
ToastUtil
.
toastShort
(
"
对方
已挂断"
)
close
(
RESULT_ANSWERED_CODE
,
""
)
close
(
RESULT_ANSWERED_CODE
,
""
)
}
}
...
@@ -597,6 +566,15 @@ class ConsultantAudioHomeActivity :
...
@@ -597,6 +566,15 @@ class ConsultantAudioHomeActivity :
tv_toast
.
text
=
"已接通"
tv_toast
.
text
=
"已接通"
tv_toast
.
postDelayed
({
tv_toast
.
visibility
=
View
.
GONE
},
500
)
tv_toast
.
postDelayed
({
tv_toast
.
visibility
=
View
.
GONE
},
500
)
rl_remain_time
.
visibility
=
View
.
VISIBLE
rl_remain_time
.
visibility
=
View
.
VISIBLE
totalDisposable
=
Observable
.
interval
(
0
,
1
,
TimeUnit
.
SECONDS
)
.
subscribeOn
(
Schedulers
.
computation
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
tv_remain_time
.
text
=
DateUtils
.
formatTime
(
it
.
toString
())
},
{})
}
}
/**
/**
...
@@ -607,30 +585,15 @@ class ConsultantAudioHomeActivity :
...
@@ -607,30 +585,15 @@ class ConsultantAudioHomeActivity :
}
}
/**
* 显示终止服务弹窗
*/
private
fun
showStopService
()
{
private
fun
showStopService
()
{
if
(
null
==
dialog
)
{
if
(
status
==
STATUS_NOT_ANSWERED
)
{
dialog
=
CommonDialog
(
this
)
//通话结束或挂断时,上传日志文件
.
setTitle
(
"温馨提示"
)
uploadLog
()
.
setMessage
(
"中途挂断可能会影响您在倾听专家榜的排名和曝光率,要谨慎选择哦!"
)
//当未接听 直接挂断 要发送给老师一条消息
.
setLeftOnclick
(
"点错了"
,
null
)
close
(
RESULT_NOT_ANSWERED_CODE
,
"用户已挂断"
)
.
setRightClick
(
"挂断"
)
{
}
else
if
(
status
==
STATUS_ANSWERED
)
{
if
(
status
==
STATUS_NOT_ANSWERED
)
{
//正常接听 挂断电话 需要重置信令管理类状态
//通话结束或挂断时,上传日志文件
close
(
RESULT_ANSWERED_CODE
,
""
)
uploadLog
()
//当未接听 直接挂断 要发送给用户一条消息
close
(
RESULT_NOT_ANSWERED_CODE
,
"咨询师已挂断"
)
}
else
if
(
status
==
STATUS_ANSWERED
)
{
//正常接听 挂断电话 需要重置信令管理类状态
close
(
RESULT_ANSWERED_CODE
,
""
)
}
}
.
setCancelAble
(
true
)
}
if
(
null
!=
dialog
&&
!
isFinishing
)
{
dialog
!!
.
show
()
}
}
}
}
...
@@ -688,7 +651,7 @@ class ConsultantAudioHomeActivity :
...
@@ -688,7 +651,7 @@ class ConsultantAudioHomeActivity :
//停止震动
//停止震动
VibratorUtil
.
StopVibrate
(
this
)
VibratorUtil
.
StopVibrate
(
this
)
if
(!
canExcute
)
{
if
(!
canExcute
)
{
ToastUtil
.
toastShort
(
"
用户
已挂断"
)
ToastUtil
.
toastShort
(
"
对方
已挂断"
)
finish
()
finish
()
}
else
{
}
else
{
if
(
null
!=
mAudioMessageBean
)
{
if
(
null
!=
mAudioMessageBean
)
{
...
@@ -778,24 +741,27 @@ class ConsultantAudioHomeActivity :
...
@@ -778,24 +741,27 @@ class ConsultantAudioHomeActivity :
//关闭本页面
//关闭本页面
fun
close
(
code
:
Int
,
msg
:
String
)
{
fun
close
(
code
:
Int
,
msg
:
String
)
{
LogUtil
.
e
(
"[agora]close(code:$code,msg:$msg)"
)
if
(
status
==
STATUS_ANSWERED
)
{
runOnUiThread
{
//不再做操作,原先为调用接口
LogUtil
.
e
(
"[agora]close(code:$code,msg:$msg)"
)
}
if
(
status
==
STATUS_ANSWERED
)
{
stopMusic
()
//不再做操作,原先为调用接口
//播放结束音频
}
playFinishMusic
()
stopMusic
()
if
(
code
==
RESULT_ANSWERED_CODE
)
{
//播放结束音频
//已接听,正常挂断
playFinishMusic
()
//离开频道
if
(
code
==
RESULT_ANSWERED_CODE
)
{
leaveChannel
()
//已接听,正常挂断
}
else
if
(
code
==
RESULT_NOT_ANSWERED_CODE
)
{
//离开频道
//未接听,直接挂断 发送消息
leaveChannel
()
YDLRTMClient
.
instances
.
refuseCall
(
mAudioMessageBean
?.
channelId
)
}
else
if
(
code
==
RESULT_NOT_ANSWERED_CODE
)
{
}
else
if
(
code
==
RESULT_USER_CANCEL
)
{
//未接听,直接挂断 发送消息
// ToastUtils.toastShort(this, "用户已挂断")
YDLRTMClient
.
instances
.
refuseCall
(
mAudioMessageBean
?.
channelId
)
}
else
if
(
code
==
RESULT_USER_CANCEL
)
{
ToastUtil
.
toastShort
(
"对方已挂断"
)
}
finish
()
}
}
finish
()
}
}
private
fun
stopMusic
()
{
private
fun
stopMusic
()
{
...
@@ -901,26 +867,6 @@ class ConsultantAudioHomeActivity :
...
@@ -901,26 +867,6 @@ class ConsultantAudioHomeActivity :
}
}
}
}
fun
showEnsureDialog
()
{
runOnUiThread
{
//停止震动
VibratorUtil
.
StopVibrate
(
this
)
if
(
ensureDialog
==
null
)
{
ensureDialog
=
CommonDialog
(
this
)
.
setMessage
(
"用户已结束通话"
)
.
setRightClick
(
"确定"
)
{
finish
()
}
.
setCancleIsVisibility
(
View
.
GONE
)
.
setCancelAble
(
false
)
}
if
(
null
!=
ensureDialog
&&
!
isFinishing
)
{
ensureDialog
!!
.
show
()
}
}
}
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
LogUtil
.
e
(
"http-------------onDestory"
)
LogUtil
.
e
(
"http-------------onDestory"
)
leaveChannel
()
leaveChannel
()
...
...
m-audioim/src/main/res/layout/audioim_cativity_consultant_audio_home.xml
View file @
f81c445c
...
@@ -47,6 +47,21 @@
...
@@ -47,6 +47,21 @@
android:textColor=
"@color/white"
android:textColor=
"@color/white"
android:textSize=
"26sp"
android:textSize=
"26sp"
tools:text=
"用户"
/>
tools:text=
"用户"
/>
<TextView
android:id=
"@+id/tv_tips"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/tv_name"
android:layout_centerHorizontal=
"true"
android:layout_marginLeft=
"25dp"
android:layout_marginTop=
"6dp"
android:layout_marginRight=
"25dp"
android:ellipsize=
"end"
android:gravity=
"center"
android:maxLines=
"2"
android:textColor=
"@color/white"
android:textSize=
"15sp"
android:text=
"向您发起语音通话请求"
/>
<!--自定义弹窗-->
<!--自定义弹窗-->
...
@@ -54,7 +69,7 @@
...
@@ -54,7 +69,7 @@
android:id=
"@+id/tv_toast"
android:id=
"@+id/tv_toast"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/tv_
name
"
android:layout_below=
"@+id/tv_
tips
"
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"34dp"
android:layout_marginTop=
"34dp"
android:background=
"@drawable/audioim_toast_view_background"
android:background=
"@drawable/audioim_toast_view_background"
...
@@ -83,7 +98,7 @@
...
@@ -83,7 +98,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:text=
"
本次倾诉时间还有
"
android:text=
"
通话时长
"
android:textColor=
"@color/platform_color_30FFFFFF"
android:textColor=
"@color/platform_color_30FFFFFF"
android:textSize=
"12sp"
/>
android:textSize=
"12sp"
/>
...
@@ -93,7 +108,7 @@
...
@@ -93,7 +108,7 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/tv_notes"
android:layout_below=
"@+id/tv_notes"
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:text=
"
23:23
"
android:text=
"
00:00
"
android:textColor=
"@color/white"
android:textColor=
"@color/white"
android:textSize=
"20sp"
/>
android:textSize=
"20sp"
/>
</RelativeLayout>
</RelativeLayout>
...
...
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