Commit 3b6b36d7 by ydl

Merge branch '声网通话流程优化' of…

Merge branch '声网通话流程优化' of ssh://gitlab.yidianling.com:2224/app_android_lib/YDL-Component into 声网通话流程优化
parents 134cdc1c 6e4790e1
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = true dev_mode = false
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.48.23", "m-confide" : "0.0.48.43",
"m-consultant" : "0.0.59.10", "m-consultant" : "0.0.59.10",
"m-fm" : "0.0.29.9", "m-fm" : "0.0.29.9",
"m-user" : "0.0.60.8", "m-user" : "0.0.60.8",
"m-home" : "0.0.22.3", "m-home" : "0.0.22.3",
"m-im" : "0.0.18.4", "m-im" : "0.0.18.5",
"m-dynamic" : "0.0.7.7", "m-dynamic" : "0.0.7.7",
"m-article" : "0.0.0.5", "m-article" : "0.0.0.5",
...@@ -28,7 +28,7 @@ ext { ...@@ -28,7 +28,7 @@ ext {
"m-tests-api" : "0.0.2", "m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.15", "m-user-api" : "0.0.10.15",
"m-home-api" : "0.0.4.1", "m-home-api" : "0.0.4.1",
"m-im-api" : "0.0.12.19", "m-im-api" : "0.0.12.20",
"m-dynamic-api" : "0.0.3.7", "m-dynamic-api" : "0.0.3.7",
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
...@@ -39,7 +39,7 @@ ext { ...@@ -39,7 +39,7 @@ ext {
"ydl-webview" : "0.0.38.31", "ydl-webview" : "0.0.38.31",
"ydl-media" : "0.0.21.6", "ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.9", "ydl-pay" : "0.0.18.9",
"m-audioim" : "0.0.49.2", "m-audioim" : "0.0.49.16",
"ydl-flutter-base": "0.0.14.14", "ydl-flutter-base": "0.0.14.14",
//以下 几乎不会动 //以下 几乎不会动
...@@ -111,7 +111,7 @@ ext { ...@@ -111,7 +111,7 @@ ext {
"m-tests-api" : "0.0.2", "m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.15", "m-user-api" : "0.0.10.15",
"m-home-api" : "0.0.4.1", "m-home-api" : "0.0.4.1",
"m-im-api" : "0.0.12.18", "m-im-api" : "0.0.12.20",
"m-dynamic-api" : "0.0.3.7", "m-dynamic-api" : "0.0.3.7",
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
...@@ -122,7 +122,7 @@ ext { ...@@ -122,7 +122,7 @@ ext {
"ydl-webview" : "0.0.38.31", "ydl-webview" : "0.0.38.31",
"ydl-media" : "0.0.21.6", "ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.9", "ydl-pay" : "0.0.18.9",
"m-audioim" : "0.0.49.2", "m-audioim" : "0.0.49.16",
"ydl-flutter-base": "0.0.14.14", "ydl-flutter-base": "0.0.14.14",
//以下 几乎不会动 //以下 几乎不会动
......
...@@ -84,10 +84,14 @@ dependencies { ...@@ -84,10 +84,14 @@ dependencies {
api project(':ydl-platform') api project(':ydl-platform')
api project(':ydl-webview') api project(':ydl-webview')
implementation modularPublication('com.ydl:m-user-api') implementation modularPublication('com.ydl:m-user-api')
implementation modularPublication('com.ydl:m-audioim-api')
implementation modularPublication('com.ydl:m-im-api')
}else { }else {
//发布时使用 //发布时使用
api rootProject.ext.dependencies["ydl-webview"] api rootProject.ext.dependencies["ydl-webview"]
compileOnly rootProject.ext.dependencies["ydl-m-user-api"] compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
compileOnly rootProject.ext.dependencies["ydl-m-audioim-api"]
compileOnly rootProject.ext.dependencies["ydl-m-im-api"]
api(rootProject.ext.dependencies["ydl-platform"]) { api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true transitive = true
} }
......
...@@ -39,8 +39,6 @@ import com.ydl.webview.H5Params ...@@ -39,8 +39,6 @@ import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent import com.ydl.webview.RefreshWebEvent
import com.ydl.ydl_av.chat.bean.AudioMessageBean import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.callback.CancelCallStatusListener
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler 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
...@@ -65,7 +63,6 @@ import io.reactivex.schedulers.Schedulers ...@@ -65,7 +63,6 @@ import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.audioim_activity_audio_home.* import kotlinx.android.synthetic.main.audioim_activity_audio_home.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
* @author jiucheng * @author jiucheng
* @描述: 倾诉声网通话页面 * @描述: 倾诉声网通话页面
...@@ -74,9 +71,7 @@ import java.util.concurrent.TimeUnit ...@@ -74,9 +71,7 @@ import java.util.concurrent.TimeUnit
* @date 2018/10/30 * @date 2018/10/30
*/ */
@Route(path = "/av/AudioHomeActivity") @Route(path = "/av/AudioHomeActivity")
class AudioHomeActivity : class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(), IAudioHomeActivityContract.View, SensorEventListener {
BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),
IAudioHomeActivityContract.View, SensorEventListener {
/** /**
* 专家头像地址 * 专家头像地址
...@@ -159,6 +154,7 @@ class AudioHomeActivity : ...@@ -159,6 +154,7 @@ class AudioHomeActivity :
private var axbPhone: String? = null private var axbPhone: String? = null
//是否跳转到拨号页面 //是否跳转到拨号页面
private var isJumpDail: Boolean = false private var isJumpDail: Boolean = false
private var isShowAXB: Boolean = true
private var mPlayer: AudioPlayer? = null private var mPlayer: AudioPlayer? = null
private var vibrator: Vibrator? = null private var vibrator: Vibrator? = null
private var handler: Handler? = null private var handler: Handler? = null
...@@ -192,7 +188,9 @@ class AudioHomeActivity : ...@@ -192,7 +188,9 @@ class AudioHomeActivity :
LogUtil.e("[agora]发生警告回调$warn") LogUtil.e("[agora]发生警告回调$warn")
runOnUiThread { runOnUiThread {
when (warn) { when (warn) {
103, 104, 105, 106, 107 -> { 103, 105, 107 -> {
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "收到频道回调警告信息$warn")
writeAgoraLog("通话挂断:网络异常(${warn})") writeAgoraLog("通话挂断:网络异常(${warn})")
showToast("当前网络较差,请更换网络!") showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -238,14 +236,15 @@ class AudioHomeActivity : ...@@ -238,14 +236,15 @@ class AudioHomeActivity :
leaveChannel() leaveChannel()
} }
123 -> { 123 -> {
// showToast("当前用户不允许接听电话,请联系客服") // showToast("当前用户不允许接听电话,请联系客服")
// leaveChannel() // leaveChannel()
} }
else -> { else -> {
//异常关闭 //异常关闭
leaveChannel() leaveChannel()
} }
} }
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "频道的错误回调信息$err")
} }
} }
...@@ -254,7 +253,6 @@ class AudioHomeActivity : ...@@ -254,7 +253,6 @@ class AudioHomeActivity :
// LogUtil.e("[agora]$api 已执行回调 $result") // LogUtil.e("[agora]$api 已执行回调 $result")
} }
override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onJoinChannelSuccess(channel, uid, elapsed) super.onJoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 用户声网加入频道成功:channel=$channel") LogUtil.e("[agora]$uid 用户声网加入频道成功:channel=$channel")
...@@ -299,6 +297,7 @@ class AudioHomeActivity : ...@@ -299,6 +297,7 @@ class AudioHomeActivity :
super.onConnectionStateChanged(state, reason) super.onConnectionStateChanged(state, reason)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑 // 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) { if (reason == 3) {
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "服务端踢人触发的回调")
writeAgoraLog("通话结束:原因(${reason})") writeAgoraLog("通话结束:原因(${reason})")
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断") com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -328,6 +327,8 @@ class AudioHomeActivity : ...@@ -328,6 +327,8 @@ class AudioHomeActivity :
uploadLog() uploadLog()
showToast("专家已挂断") showToast("专家已挂断")
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "对方离开频道")
if (totalDisposable != null) { if (totalDisposable != null) {
totalDisposable!!.dispose() totalDisposable!!.dispose()
} }
...@@ -336,6 +337,45 @@ class AudioHomeActivity : ...@@ -336,6 +337,45 @@ class AudioHomeActivity :
updateExpertStatus(false, 1) updateExpertStatus(false, 1)
}, 500) }, 500)
} }
override fun onNetworkQuality(uid: Int, txQuality: Int, rxQuality: Int) {
super.onNetworkQuality(uid, txQuality, rxQuality)
var status = -1
var netStatus = when (uid) {
listenerUid!!.toInt() -> {
if (txQuality in 1..2 && rxQuality in 1..2) {
""
} else if (txQuality >= 5 || rxQuality >= 5) {
"对方的网络已断开"
} else {
status = if (txQuality >= 4 || rxQuality >= 4) {
0
} else {
1
}
"对方的网络状况不佳"
}
}
0 -> {
if (txQuality in 1..2 && rxQuality in 1..2) {
""
} else if (txQuality >= 5 || rxQuality >= 5) {
"您的网络已断开"
} else {
status = if (txQuality >= 4 || rxQuality >= 4) {
0
} else {
1
}
"您的网络状况不佳"
}
}
else -> {
""
}
}
showNetStatus(netStatus, status)
}
} }
// //
...@@ -376,10 +416,7 @@ class AudioHomeActivity : ...@@ -376,10 +416,7 @@ class AudioHomeActivity :
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager? sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager?
localPowerManager = getSystemService(POWER_SERVICE) as PowerManager? localPowerManager = getSystemService(POWER_SERVICE) as PowerManager?
localWakeLock = localPowerManager!!.newWakeLock( localWakeLock = localPowerManager!!.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "yidianling")
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"yidianling"
)
} }
private fun initIntentData() { private fun initIntentData() {
...@@ -395,17 +432,9 @@ class AudioHomeActivity : ...@@ -395,17 +432,9 @@ class AudioHomeActivity :
listenerUid = intent.getStringExtra(IntentConstants.INTENT_LISTENER_UID) listenerUid = intent.getStringExtra(IntentConstants.INTENT_LISTENER_UID)
listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID) listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID)
commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL) commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL)
isShowAXB = intent.getBooleanExtra(IntentConstants.INTENT_ISSHOWAXB,true)
val logBean = AgoraLogInfoBean( val logBean = AgoraLogInfoBean(expertHeadUrl, expertName, channelId, remainTime, listenerUid, totalDuration, callId, listenId)
expertHeadUrl,
expertName,
channelId,
remainTime,
listenerUid,
totalDuration,
callId,
listenId
)
val content = Gson().toJson(logBean) val content = Gson().toJson(logBean)
writeAgoraLog("主叫方发送的邀请通话消息内容:$content", isAppend = false) writeAgoraLog("主叫方发送的邀请通话消息内容:$content", isAppend = false)
...@@ -424,7 +453,6 @@ class AudioHomeActivity : ...@@ -424,7 +453,6 @@ class AudioHomeActivity :
} }
} }
private fun initView() { private fun initView() {
tv_change_route.isEnabled = false tv_change_route.isEnabled = false
//水波纹view初始化 //水波纹view初始化
...@@ -451,11 +479,17 @@ class AudioHomeActivity : ...@@ -451,11 +479,17 @@ class AudioHomeActivity :
option.transform = 0 option.transform = 0
YDLImageCacheManager.showImage(this, expertHeadUrl, iv_head, option) YDLImageCacheManager.showImage(this, expertHeadUrl, iv_head, option)
} }
if(!isShowAXB){
tv_change_route.visibility=View.GONE
tv_change_time_counter.visibility=View.GONE
}
} }
private fun setClickEvent() { private fun setClickEvent() {
//切换线路 //切换线路
tv_change_route.setOnClickListener { showChooseDialog(1) } tv_change_route.setOnClickListener {
showChooseDialog(1) }
//挂断 //挂断
iv_hang_up.setOnClickListener { iv_hang_up.setOnClickListener {
if (Utils.isFastClick()) { if (Utils.isFastClick()) {
...@@ -463,6 +497,7 @@ class AudioHomeActivity : ...@@ -463,6 +497,7 @@ class AudioHomeActivity :
return@setOnClickListener return@setOnClickListener
} }
if (isConnectSuccess) { if (isConnectSuccess) {
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "主叫主动挂断")
writeAgoraLog("已接通:主叫主动挂断") writeAgoraLog("已接通:主叫主动挂断")
updateExpertStatus(false, 1) updateExpertStatus(false, 1)
leaveChannel() leaveChannel()
...@@ -471,11 +506,7 @@ class AudioHomeActivity : ...@@ -471,11 +506,7 @@ class AudioHomeActivity :
userCloseCalling() userCloseCalling()
} }
ActionCountUtils.count( ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_refuse_click", YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString())
"shengwang_popup_layer_page|shengwang_popup_layer_refuse_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
//免提 //免提
...@@ -507,99 +538,74 @@ class AudioHomeActivity : ...@@ -507,99 +538,74 @@ class AudioHomeActivity :
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private fun requestPermission() { private fun requestPermission() {
val rxPermissions = RxPermissions(this) val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO) rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO).subscribe { permission ->
.subscribe { permission -> if (permission.granted) {
if (permission.granted) { init()
init() } else if (permission.shouldShowRequestPermissionRationale) {
} else if (permission.shouldShowRequestPermissionRationale) { requestPermission()
requestPermission() } else {
} else {
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint)) ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null) val uri = Uri.fromParts("package", packageName, null)
intent.data = uri intent.data = uri
startActivity(intent) startActivity(intent)
finish() finish()
}
} }
}
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult", "SetTextI18n")
private fun init() { private fun init() {
wave_view.start() wave_view.start()
//初始化声网 //初始化声网
initializeAgoraEngine() initializeAgoraEngine()
//发起呼叫 //发起呼叫
var msgBean = AudioMessageBean( var msgBean = AudioMessageBean(1, channelId!!, YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, remainTime!!.toInt(), relationId, callId, null, channelId)
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
sendDoctocrMsg = Gson().toJson(msgBean) sendDoctocrMsg = Gson().toJson(msgBean)
writeAgoraLog("主叫发送通话邀请") writeAgoraLog("主叫发送通话邀请")
rtcCall() rtcCall()
//开始60s等待倒计时 //开始60s等待倒计时
waitDisposable = Observable.interval(0, 100, TimeUnit.MILLISECONDS) waitDisposable = Observable.interval(0, 100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()).take(600).observeOn(AndroidSchedulers.mainThread()).subscribe({
.subscribeOn(Schedulers.computation()) tv_change_time_counter.text = "${60 - it / 10}s"
.take(603) var result = it.toFloat() / 2.5f
.observeOn(AndroidSchedulers.mainThread()) progress_view.setProgress(result)
.subscribe({ if (result >= 100f && !iv_hang_up.isEnabled) {
var result = it.toFloat() / 2.5f //挂断按钮可点击
progress_view.setProgress(result) iv_hang_up.isEnabled = true
if (result >= 100f && !iv_hang_up.isEnabled) { iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up)
//挂断按钮可点击 }
iv_hang_up.isEnabled = true }, {
iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up) LogUtil.d(it.message)
} }) {
}, { waittingStatus()
LogUtil.d(it.message) if (!isConnectSuccess) {
}) { //关闭音乐
waittingStatus() stopPlaying()
if (!isConnectSuccess) { writeAgoraLog("未接通挂断:60s等待倒计时结束挂断")
//关闭音乐 //提示切换传统线路
stopPlaying() //发送消息通知专家用户已挂断
writeAgoraLog("未接通挂断:60s等待倒计时结束挂断") YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code ->
//提示切换传统线路 writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(
listenerUid,
channelId,
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
//通话结束或挂断时,上传日志文件
uploadLog()
showChooseDialog(2)
} }
//通话结束或挂断时,上传日志文件
uploadLog()
showChooseDialog(2)
} }
}
//双重保险:加入频道成功,通过服务端发推送给专家 //双重保险:加入频道成功,通过服务端发推送给专家
noticeServerPush(true) noticeServerPush(true)
} }
fun rtcCall() { fun rtcCall() {
YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg) YDLavManager.instances.rtcCall(listenerUid, channelId, sendDoctocrMsg)
} }
/** /**
* 声网初始化 * 声网初始化
*/ */
...@@ -618,12 +624,7 @@ class AudioHomeActivity : ...@@ -618,12 +624,7 @@ class AudioHomeActivity :
*/ */
fun joinChannel() { fun joinChannel() {
writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId") writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId")
voiceManage!!.getVoiceApi().joinChannel( voiceManage!!.getVoiceApi().joinChannel(token!!, channelId!!, "Extra Optional Data", YdlCommonRouterManager.getYdlCommonRoute().getUid())
token!!,
channelId!!,
"Extra Optional Data",
YdlCommonRouterManager.getYdlCommonRoute().getUid()
)
} }
/** /**
...@@ -635,18 +636,9 @@ class AudioHomeActivity : ...@@ -635,18 +636,9 @@ class AudioHomeActivity :
writeAgoraLog("未接听时:主叫主动挂断,取消呼叫") writeAgoraLog("未接听时:主叫主动挂断,取消呼叫")
LogUtil.e("未接听挂断") LogUtil.e("未接听挂断")
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall( YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code ->
listenerUid, writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
channelId, }
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$errorMsg($errorCode),再次挂断")
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
handler!!.postDelayed({ handler!!.postDelayed({
...@@ -689,20 +681,19 @@ class AudioHomeActivity : ...@@ -689,20 +681,19 @@ class AudioHomeActivity :
*/ */
private fun showChooseDialog(type: Int) { private fun showChooseDialog(type: Int) {
val dialog = val dialog = AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener {
AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener { override fun onClickEnsure() {
override fun onClickEnsure() { switchAXB()
switchAXB() }
}
override fun onClose() { override fun onClose() {
// 如果声网未连接成功,切换axb的弹框是自动弹出的,当关闭弹框的时候,执行用户挂断操作 // 如果声网未连接成功,切换axb的弹框是自动弹出的,当关闭弹框的时候,执行用户挂断操作
// 如果声网连接成功,点击右上角按钮弹出切换axb弹框,但是关闭时用户不执行挂断操作 // 如果声网连接成功,点击右上角按钮弹出切换axb弹框,但是关闭时用户不执行挂断操作
if (!isConnectSuccess) { if (!isConnectSuccess) {
userCloseCalling() userCloseCalling()
}
} }
}) }
})
dialog.show() dialog.show()
} }
...@@ -717,6 +708,8 @@ class AudioHomeActivity : ...@@ -717,6 +708,8 @@ class AudioHomeActivity :
} }
}) })
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "接通中:主叫主动切换AXB")
} else { } else {
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1")) mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
} }
...@@ -738,17 +731,9 @@ class AudioHomeActivity : ...@@ -738,17 +731,9 @@ class AudioHomeActivity :
//未连接成功,切换axb时:需发送消息通知专家端用户已挂断 //未连接成功,切换axb时:需发送消息通知专家端用户已挂断
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall( YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code ->
listenerUid, writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
channelId, }
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
leaveChannel() leaveChannel()
} }
} }
...@@ -768,6 +753,7 @@ class AudioHomeActivity : ...@@ -768,6 +753,7 @@ class AudioHomeActivity :
* 60s等待完成,专家未接听 * 60s等待完成,专家未接听
*/ */
private fun waittingStatus() { private fun waittingStatus() {
tv_change_time_counter.visibility = View.GONE
//挂断按钮可点击 //挂断按钮可点击
iv_hang_up.isEnabled = true iv_hang_up.isEnabled = true
iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up) iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up)
...@@ -777,56 +763,16 @@ class AudioHomeActivity : ...@@ -777,56 +763,16 @@ class AudioHomeActivity :
tv_change_doctor.text = "对方暂无应答,正在为您切换线路重播" tv_change_doctor.text = "对方暂无应答,正在为您切换线路重播"
tv_change_doctor.visibility = View.VISIBLE tv_change_doctor.visibility = View.VISIBLE
} }
//切换线路按钮可见 if(!isShowAXB){
tv_change_route.isEnabled = true tv_change_route.visibility=View.GONE
}else{
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.platform_white)) //切换线路按钮可见
tv_change_route.setCompoundDrawablesWithIntrinsicBounds( tv_change_route.isEnabled = true
null, tv_change_route.text = "切换至传统电话"
null,
ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow), tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.platform_white))
null }
)
}
/**
* 加入语音聊天频道成功
*/
private fun onJoinChannelSuccess() {
dismissProgressView()
playWaitingMusic()
//45s倒计时逻辑
// disposable = Observable.interval(0, 1, TimeUnit.SECONDS)
// .subscribeOn(Schedulers.computation())
// .take(45)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
// }, {
// LogUtil.d(it.message)
// }, {
// if (!isConnectSuccess) {
// tv_change_doctor.visibility = View.VISIBLE
// }
// })
//60超时倒计时逻辑
// waitDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
// .subscribeOn(Schedulers.computation())
// .take(60)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
// }, {
// LogUtil.d(it.message)
// }, {
// if (!isConnectSuccess) {
// ActivityManager.getInstance().finishActivity(NewH5Activity::class.java!!)
// showToast("专家未接听")
// userCloseCalling()
// }
// })
} }
/** /**
...@@ -911,48 +857,32 @@ class AudioHomeActivity : ...@@ -911,48 +857,32 @@ class AudioHomeActivity :
tv_tips.visibility = View.GONE tv_tips.visibility = View.GONE
//剩余倾诉时长倒计时 //剩余倾诉时长倒计时
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS) totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS).subscribeOn(Schedulers.computation()).take(remainTime!!.toLong() + 1).observeOn(AndroidSchedulers.mainThread()).subscribe({
.subscribeOn(Schedulers.computation()) localRemainTime = remainTime!!.toInt() - it.toInt()
.take(remainTime!!.toLong() + 1) if (localRemainTime == 180) {
.observeOn(AndroidSchedulers.mainThread()) playNoticeMusic(3)
.subscribe({ }
localRemainTime = remainTime!!.toInt() - it.toInt() if (localRemainTime == 60) {
if (localRemainTime == 180) { playNoticeMusic(1)
playNoticeMusic(3) }
} if (localRemainTime!! <= 60) {
if (localRemainTime == 60) { if (tv_change_route.isEnabled) {
playNoticeMusic(1) tv_change_route.isEnabled = false
} tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff))
if (localRemainTime!! <= 60) { tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse), null)
if (tv_change_route.isEnabled) {
tv_change_route.isEnabled = false
tv_change_route.setTextColor(
ContextCompat.getColor(
this,
R.color.audioim_color_50ffffff
)
)
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(
this,
R.drawable.audioim_img_choose_arrow_unuse
),
null
)
}
} }
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString()) }
}, { tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString())
LogUtil.d(it.message) }, {
}, { LogUtil.d(it.message)
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口 }, {
showToast("通话已结束") YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "倾诉时间已用完")
//通话结束或挂断时,上传日志文件 //注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
uploadLog() showToast("通话已结束")
updateExpertStatus(false, 1) //通话结束或挂断时,上传日志文件
}) uploadLog()
updateExpertStatus(false, 1)
})
} }
/** /**
...@@ -982,18 +912,7 @@ class AudioHomeActivity : ...@@ -982,18 +912,7 @@ class AudioHomeActivity :
* @param isCall true 拨打 false 取消拨打 * @param isCall true 拨打 false 取消拨打
*/ */
private fun noticeServerPush(isCall: Boolean) { private fun noticeServerPush(isCall: Boolean) {
var msgBean = AudioMessageBean( var msgBean = AudioMessageBean(1, channelId!!, YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, remainTime!!.toInt(), relationId, callId, null, channelId)
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
var cmd = NoticePushCommand() var cmd = NoticePushCommand()
cmd.data = msgBean cmd.data = msgBean
cmd.pushId = listenerUid cmd.pushId = listenerUid
...@@ -1005,7 +924,6 @@ class AudioHomeActivity : ...@@ -1005,7 +924,6 @@ class AudioHomeActivity :
mPresenter.noticeServerPush(cmd) mPresenter.noticeServerPush(cmd)
} }
/** /**
* 声网离开频道 * 声网离开频道
*/ */
...@@ -1023,22 +941,13 @@ class AudioHomeActivity : ...@@ -1023,22 +941,13 @@ class AudioHomeActivity :
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
sensorManager!!.registerListener( sensorManager!!.registerListener(this, sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL)
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_page_visit", "", uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString())
)
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_page_visit",
"",
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) { override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
} }
override fun onSensorChanged(event: SensorEvent?) { override fun onSensorChanged(event: SensorEvent?) {
...@@ -1061,28 +970,44 @@ class AudioHomeActivity : ...@@ -1061,28 +970,44 @@ class AudioHomeActivity :
} }
} }
/** /**
* 显示自定义弹窗 * 显示自定义弹窗
*/ */
private fun showToast(msg: String?) { private fun showToast(msg: String?) {
runOnUiThread { runOnUiThread {
// tv_toast.visibility = View.VISIBLE
//// tv_toast.text = msg
//// tv_toast.postDelayed({
//// tv_toast.visibility = View.GONE
//// }, 1000)
ToastHelper.show(msg ?: "") ToastHelper.show(msg ?: "")
} }
} }
/**
* 网络状态
*/
private fun showNetStatus(msg: String, status: Int = 0) {
runOnUiThread {
if (TextUtils.isEmpty(msg)) {
tv_nte_status.visibility = View.GONE
} else {
tv_nte_status.text = msg
if (status == 0) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_normal), null, null, null)
}
if (status == 1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_better), null, null, null)
}
if (status == -1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
}
tv_nte_status.visibility = View.VISIBLE
}
}
}
override fun showProgressView() { override fun showProgressView() {
try { try {
showProgressDialog() showProgressDialog()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
} }
override fun dismissProgressView() { override fun dismissProgressView() {
...@@ -1091,7 +1016,6 @@ class AudioHomeActivity : ...@@ -1091,7 +1016,6 @@ class AudioHomeActivity :
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
} }
fun uploadLog() { fun uploadLog() {
...@@ -1110,21 +1034,14 @@ class AudioHomeActivity : ...@@ -1110,21 +1034,14 @@ class AudioHomeActivity :
* 上传错误日志 * 上传错误日志
* zhu 洪平要的,判别是移动端主动调的还是声网返的 * zhu 洪平要的,判别是移动端主动调的还是声网返的
*/ */
private fun uploadException( private fun uploadException(message: String, zhu: String = "", eventType: String = "99", callback: YDLavManager.UploadExceptionCallback?) {
message: String,
zhu: String = "",
eventType: String = "99",
callback: YDLavManager.UploadExceptionCallback?
) {
var time: String = (System.currentTimeMillis() / 1000).toString() var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String = var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message) var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message)
var connectException = ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus) var connectException = ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus)
YDLavManager.instances.uploadException(connectException, callback) YDLavManager.instances.uploadException(connectException, callback)
} }
fun writeAgoraLog(content: String, isAppend: Boolean = true) { fun writeAgoraLog(content: String, isAppend: Boolean = true) {
try { try {
AudioLogUtils.writeAgoraLog(content, "confide", isAppend) AudioLogUtils.writeAgoraLog(content, "confide", isAppend)
...@@ -1132,7 +1049,6 @@ class AudioHomeActivity : ...@@ -1132,7 +1049,6 @@ class AudioHomeActivity :
} }
} }
override fun finishActivity() { override fun finishActivity() {
leaveChannel() leaveChannel()
} }
......
...@@ -21,4 +21,5 @@ public interface IntentConstants { ...@@ -21,4 +21,5 @@ public interface IntentConstants {
String INTENT_TOTAL_DURATION= "intent_total_duration"; String INTENT_TOTAL_DURATION= "intent_total_duration";
String INTENT_LISTEN_ID= "intent_listen_id"; String INTENT_LISTEN_ID= "intent_listen_id";
String INTENT_COMMENT_URL= "intent_comment_url"; String INTENT_COMMENT_URL= "intent_comment_url";
String INTENT_ISSHOWAXB= "intent_isshowaxb";
} }
...@@ -5,13 +5,17 @@ import android.content.Context ...@@ -5,13 +5,17 @@ import android.content.Context
import android.os.Handler import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraInvitationBean
import com.ydl.audioim.http.AudioApiRequestUtil import com.ydl.audioim.http.AudioApiRequestUtil
import com.ydl.audioim.http.command.ConnectExceptionCommand import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.router.AudioImIn
import com.ydl.audioim.utils.AudioLogUtils import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.consultantim.ConsultantAudioHomeActivity 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.CallListener
import com.ydl.ydl_av.messge_service.callback.CancelCallStatusListener
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
...@@ -22,6 +26,8 @@ import com.ydl.ydlcommon.utils.ActivityManager ...@@ -22,6 +26,8 @@ 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.common.tools.ToastUtil
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import com.yidianling.user.api.event.UserLoginEvent import com.yidianling.user.api.event.UserLoginEvent
import com.yidianling.user.api.event.UserLogoutEvent import com.yidianling.user.api.event.UserLogoutEvent
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
...@@ -39,9 +45,8 @@ import java.util.concurrent.TimeUnit ...@@ -39,9 +45,8 @@ import java.util.concurrent.TimeUnit
*/ */
class YDLavManager { class YDLavManager {
companion object { companion object {
val FILE_NAME = "consult" const val FILE_NAME = "consult"
//当前sdk的登录状态 //当前sdk的登录状态
var sdkStatus = -1 var sdkStatus = -1
...@@ -52,8 +57,8 @@ class YDLavManager { ...@@ -52,8 +57,8 @@ class 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)
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
//设置回调 //设置回调
setCallback() setCallback()
...@@ -74,6 +79,7 @@ class YDLavManager { ...@@ -74,6 +79,7 @@ class YDLavManager {
public fun onEvent(event: UserLogoutEvent) { public fun onEvent(event: UserLogoutEvent) {
instances.logout() instances.logout()
} }
private 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?) {
...@@ -86,14 +92,13 @@ class YDLavManager { ...@@ -86,14 +92,13 @@ class YDLavManager {
act.playWaitingMusic() act.playWaitingMusic()
} }
} }
} }
override fun onCallAccepted(response: CallLocalResponse?, msg: String?) { override fun onCallAccepted(response: CallLocalResponse?, msg: String?) {
//返回给主叫 //返回给主叫
LogUtil.e("[agora]${response?.calleeId}已接收呼叫邀请") LogUtil.e("[agora]${response?.calleeId}已接收呼叫邀请")
//加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道 //加入声网频道时机修改:主叫收到被叫接受邀请的回调后再加入声网频道
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
...@@ -109,6 +114,7 @@ class YDLavManager { ...@@ -109,6 +114,7 @@ class YDLavManager {
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
callEndStatusUpdate(response?.ChannelId!!, 2, "被叫拒绝")
ToastUtil.toastShort("对方已挂断") ToastUtil.toastShort("对方已挂断")
act.writeAgoraLog("被叫拒绝了通话邀请") act.writeAgoraLog("被叫拒绝了通话邀请")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -138,17 +144,18 @@ class YDLavManager { ...@@ -138,17 +144,18 @@ class YDLavManager {
//专家离线或者30 秒后仍未收到专家响应,重新再邀请一次 //专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
when (errorCode) { when (errorCode) {
//被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请 //被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_OFFLINE, RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_OFFLINE, RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_NO_RESPONSE -> {
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_NO_RESPONSE -> {
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
act.rtcCall() act.rtcCall()
} }
} }
} }
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> {//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。 RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> { //呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
sendCustomNotification(response?.calleeId!!, response?.ChannelId!!, "5")
callEndStatusUpdate(response.ChannelId!!, 2, "被叫超时未接听")
act.writeAgoraLog("呼叫失败:${errorCode}") act.writeAgoraLog("呼叫失败:${errorCode}")
act.uploadExceptionStatus("对方未接听", 3) act.uploadExceptionStatus("对方未接听", 3)
// //通话结束或挂断时,上传日志文件 // //通话结束或挂断时,上传日志文件
...@@ -181,6 +188,7 @@ class YDLavManager { ...@@ -181,6 +188,7 @@ class YDLavManager {
} }
override fun onRemoteInvitationCanceled(response: CallRemoteResponse?) { override fun onRemoteInvitationCanceled(response: CallRemoteResponse?) {
callEndStatusUpdate(response?.ChannelId!!, 1, "主叫取消呼叫")
//返回给被叫 //返回给被叫
LogUtil.e("[agora]主叫${response?.callerId}已取消呼叫邀请") LogUtil.e("[agora]主叫${response?.callerId}已取消呼叫邀请")
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME) AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME)
...@@ -196,7 +204,7 @@ class YDLavManager { ...@@ -196,7 +204,7 @@ class YDLavManager {
override fun onRemoteInvitationFailure(response: CallRemoteResponse?, errorCode: Int) { override fun onRemoteInvitationFailure(response: CallRemoteResponse?, errorCode: Int) {
//返回给被叫 //返回给被叫
LogUtil.e("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}") LogUtil.e("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}")
if (errorCode == RtmStatusCode.RemoteInvitationError.REMOTE_INVITATION_ERR_INVITATION_EXPIRE) {//呼叫邀请过期 if (errorCode == RtmStatusCode.RemoteInvitationError.REMOTE_INVITATION_ERR_INVITATION_EXPIRE) { //呼叫邀请过期
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME) AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME)
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is ConsultantAudioHomeActivity) { if (act is ConsultantAudioHomeActivity) {
...@@ -205,6 +213,7 @@ class YDLavManager { ...@@ -205,6 +213,7 @@ class YDLavManager {
} else { } else {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:错误原因(${errorCode})", FILE_NAME) AudioLogUtils.writeAgoraLog("呼叫邀请被取消:错误原因(${errorCode})", FILE_NAME)
} }
callEndStatusUpdate(response?.ChannelId!!, 2, "超时未接听导致的取消呼叫")
//关闭页面 //关闭页面
closePage() closePage()
} }
...@@ -213,15 +222,105 @@ class YDLavManager { ...@@ -213,15 +222,105 @@ class YDLavManager {
LogUtil.e("[agora]其它消息:${error}") LogUtil.e("[agora]其它消息:${error}")
} }
}) })
AudioImIn.registerObserveCustomNotification(object :
IMRegisterObserverCustomNotificationCallBack {
override fun onObserverCustomNotification(fromUid: String, toUid: String, content: String) {
LogUtil.e("[agora]收到云信的通知消息:$content")
val agoraInvitationBean = Gson().fromJson(content, AgoraInvitationBean::class.java)
//1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时
when (agoraInvitationBean.callType) {
"1" -> {
receivedCall(agoraInvitationBean.data, "来自云信")
}
"2" -> {
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.joinChannel()
}
}
}
"3" -> {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME)
closePage()
}
"4" -> {
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
ToastUtil.toastShort("对方已挂断")
act.writeAgoraLog("被叫拒绝了通话邀请")
//通话结束或挂断时,上传日志文件
act.uploadLog()
act.leaveChannel()
}
}
}
"5" -> {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME)
//关闭页面
closePage()
}
}
}
})
}
fun rtcCall(listenerUid: String?, channelId: String?, sendDoctocrMsg: String?) {
YDLRTMClient.instances.call(listenerUid, channelId, sendDoctocrMsg)
sendCustomNotification(listenerUid!!, sendDoctocrMsg!!, "1")
}
fun acceptCall(toUid: String, channelId: String?, data: String) {
YDLRTMClient.instances.acceptCall(channelId)
sendCustomNotification(toUid, data, "2")
}
fun refuseCall(toUid: String, channelId: String?, data: String) {
YDLRTMClient.instances.refuseCall(channelId)
sendCustomNotification(toUid, data, "4")
}
fun cancelCall(listenerUid: String, channelId: String, data: String, event: (msg: String?, code: Int) -> Unit) {
YDLRTMClient.instances.cancelCall(listenerUid, channelId, object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
event(errorMsg, errorCode)
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
callEndStatusUpdate(channelId, 1, "主叫取消呼叫")
sendCustomNotification(listenerUid, data, "3")
} }
private fun sendCustomNotification(toUid: String, data: String, callType: String) {
val infoBean = AgoraInvitationBean()
infoBean.data = data
infoBean.callType = callType
AudioImIn.sendCustomNotification(toUid, Gson().toJson(infoBean),
object : IMSendCustomNotificationResultCallBack {
override fun onException(throwable: Throwable) {
}
override fun onFailed(code: Int) {
}
override fun onSuccess() {
}
})
}
fun login(userId: String?) { fun login(userId: String?) {
login(userId) { _, _ -> login(userId) { _, _ ->
} }
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) { fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") { if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") {
...@@ -231,14 +330,11 @@ class YDLavManager { ...@@ -231,14 +330,11 @@ class YDLavManager {
} }
//登录实时消息 //登录实时消息
//获取token //获取token
AudioApiRequestUtil.getAgoraToken() AudioApiRequestUtil.getAgoraToken().subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe({
.observeOn(AndroidSchedulers.mainThread()) if ("200".equals(it.code)) {
.subscribe({ LogUtil.e("[agora]登录av的login-uid:$userId")
if ("200".equals(it.code)) { YDLRTMClient.instances.login(LoginParam(userId, it.data.token), object : LoginCallback {
LogUtil.e("[agora]登录av的login-uid:$userId")
YDLRTMClient.instances.login(LoginParam(userId, it.data.token),
object : LoginCallback {
override fun onSuccess() { override fun onSuccess() {
//登陆成功,发起呼叫 //登陆成功,发起呼叫
LogUtil.e("[agora]实时消息登录成功") LogUtil.e("[agora]实时消息登录成功")
...@@ -249,19 +345,16 @@ class YDLavManager { ...@@ -249,19 +345,16 @@ class YDLavManager {
LogUtil.e("[agora]实时消息登录失败:$msg") LogUtil.e("[agora]实时消息登录失败:$msg")
event(false, msg) event(false, msg)
} }
}) })
} else { } else {
LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg) LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg)
LogHelper.getInstance() LogHelper.getInstance().writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg)
.writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg) }
} }, {
}, { LogUtil.e("声网token获取异常uid:" + userId + " error:" + it.message)
LogUtil.e("声网token获取异常uid:" + userId + " error:" + it.message) })
})
} }
/** /**
* 收到邀请 * 收到邀请
*/ */
...@@ -270,21 +363,17 @@ class YDLavManager { ...@@ -270,21 +363,17 @@ class YDLavManager {
if (!TextUtils.isEmpty(content)) { if (!TextUtils.isEmpty(content)) {
//如果已经接听了用户电话 再有电话进来 是不能接听的 //如果已经接听了用户电话 再有电话进来 是不能接听的
if (!activityIsExists(ConsultantAudioHomeActivity::class.java) && !activityIsExists( if (!activityIsExists(ConsultantAudioHomeActivity::class.java) && !activityIsExists(
AudioHomeActivity::class.java AudioHomeActivity::class.java)) {
)
) {
//延时启动通话界面,防止刚打开就被main遮挡 //延时启动通话界面,防止刚打开就被main遮挡
Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io()) Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread()).subscribe {
.subscribe { LogUtil.e("[agora]启动通话界面")
LogUtil.e("[agora]启动通话界面") //邀请加入频道消息,跳转通话界面
//邀请加入频道消息,跳转通话界面 ARouter.getInstance().build("/av/ConsultantAudioHomeActivity")
ARouter.getInstance().build("/av/ConsultantAudioHomeActivity") .withString("param", content).navigation()
.withString("param", content)
.navigation() AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
}
AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
}
} else { } else {
LogUtil.d("[agora]收到声网邀请,但界面实例已存在") LogUtil.d("[agora]收到声网邀请,但界面实例已存在")
} }
...@@ -293,7 +382,6 @@ class YDLavManager { ...@@ -293,7 +382,6 @@ class YDLavManager {
} }
} }
private fun activityIsExists(cls: Class<*>): Boolean { private fun activityIsExists(cls: Class<*>): Boolean {
for (activity in ActivityManager.getInstance().getActivitys()) { for (activity in ActivityManager.getInstance().getActivitys()) {
if (activity.javaClass == cls) { if (activity.javaClass == cls) {
...@@ -303,7 +391,6 @@ class YDLavManager { ...@@ -303,7 +391,6 @@ class YDLavManager {
return false return false
} }
/** /**
* 关闭通话界面 * 关闭通话界面
*/ */
...@@ -317,11 +404,10 @@ class YDLavManager { ...@@ -317,11 +404,10 @@ class YDLavManager {
} }
} }
/** /**
* 退出登录 * 退出登录
*/ */
fun logout(){ fun logout() {
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
YDLRTMClient.instances.logout(object : LoginCallback { YDLRTMClient.instances.logout(object : LoginCallback {
override fun onSuccess() { override fun onSuccess() {
...@@ -332,7 +418,6 @@ class YDLavManager { ...@@ -332,7 +418,6 @@ class YDLavManager {
override fun onFailure(msg: String?) { override fun onFailure(msg: String?) {
LogUtil.d("[agora]实时消息退出失败:$msg") LogUtil.d("[agora]实时消息退出失败:$msg")
} }
}) })
} }
...@@ -341,16 +426,14 @@ class YDLavManager { ...@@ -341,16 +426,14 @@ class YDLavManager {
* 声网出现异常,上传错误日志 connectException * 声网出现异常,上传错误日志 connectException
*/ */
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun uploadException(connectException: ConnectExceptionCommand, callback: UploadExceptionCallback?) { fun uploadException(connectException: ConnectExceptionCommand,
AudioApiRequestUtil.connectException(connectException) callback: UploadExceptionCallback?) {
.subscribeOn(Schedulers.io()) AudioApiRequestUtil.connectException(connectException).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread()).subscribe({
callback?.onSuccess()
.subscribe({ }, {
callback?.onSuccess() LogUtil.e("agora", "声网上传异常与错误日志接口调用失败:" + it.message)
}, { })
LogUtil.e("agora", "声网上传异常与错误日志接口调用失败:" + it.message)
})
} }
/** /**
...@@ -360,13 +443,24 @@ class YDLavManager { ...@@ -360,13 +443,24 @@ class YDLavManager {
fun onSuccess() fun onSuccess()
} }
@SuppressLint("CheckResult")
fun callEndStatusUpdate(channelId: String, endStatus: Int, msg: String) {
AudioApiRequestUtil.callEndStatusUpdate(channelId, endStatus, msg)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe({
}, {
})
}
/** /**
* 实时消息全局监听 * 实时消息全局监听
*/ */
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) {
...@@ -374,8 +468,8 @@ class YDLavManager { ...@@ -374,8 +468,8 @@ class YDLavManager {
} }
override fun onConnectionStateChanged(state: Int, reason: Int) { override fun onConnectionStateChanged(state: Int, reason: Int) {
sdkStatus = state
LogUtil.i("[agora]onConnectionStateChanged:state:${state} -->reason:$reason") LogUtil.i("[agora]onConnectionStateChanged:state:${state} -->reason:$reason")
} }
} }
} }
\ No newline at end of file
package com.ydl.audioim.bean;
/**
* @author jiucheng
* @描述:自定义的Invitation
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/23
*/
public class AgoraInvitationBean {
public String data;
public String business="agora";
public String callType;//1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时
}
...@@ -3,7 +3,9 @@ package com.ydl.audioim.http ...@@ -3,7 +3,9 @@ package com.ydl.audioim.http
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraTokenResponse import com.ydl.audioim.bean.AgoraTokenResponse
import com.ydl.audioim.bean.ConnectBean import com.ydl.audioim.bean.ConnectBean
import com.ydl.audioim.http.command.* import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.consultantim.bean.ListenTokenBean import com.ydl.consultantim.bean.ListenTokenBean
import com.ydl.consultantim.command.ListenTokenCmd import com.ydl.consultantim.command.ListenTokenCmd
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
...@@ -29,8 +31,7 @@ class AudioApiRequestUtil { ...@@ -29,8 +31,7 @@ class AudioApiRequestUtil {
*/ */
fun connectListen(cmd: ConnectCommand): Observable<BaseAPIResponse<ConnectBean>> { fun connectListen(cmd: ConnectCommand): Observable<BaseAPIResponse<ConnectBean>> {
return RxUtils.mapObservable(cmd) return RxUtils.mapObservable(cmd)
.flatMap { .flatMap { it ->
it->
YDLHttpUtils.obtainApi(AudioNetAPi::class.java).connectListen(it) YDLHttpUtils.obtainApi(AudioNetAPi::class.java).connectListen(it)
} }
} }
...@@ -85,15 +86,19 @@ class AudioApiRequestUtil { ...@@ -85,15 +86,19 @@ class AudioApiRequestUtil {
/** /**
* 获取声网登录token * 获取声网登录token
*/ */
fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>>{ fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>> {
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).getAgoraToken() return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).getAgoraToken()
} }
/** /**
* 获取声网登录token * 获取声网登录token
*/ */
fun listenToken(cmd: ListenTokenCmd): Observable<BaseResponse<ListenTokenBean>>{ fun listenToken(cmd: ListenTokenCmd): Observable<BaseResponse<ListenTokenBean>> {
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).listenToken(NetworkParamsUtils.getMaps(cmd)) return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).listenToken(NetworkParamsUtils.getMaps(cmd))
} }
fun callEndStatusUpdate(channelId: String, endStatus: Int, msg: String): Observable<BaseResponse<Any>> {
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).callEndStatusUpdate(channelId, endStatus, msg)
}
} }
} }
\ No newline at end of file
...@@ -69,4 +69,7 @@ interface AudioNetAPi { ...@@ -69,4 +69,7 @@ interface AudioNetAPi {
fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>> fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>>
@GET("message/call-end/agora")
fun callEndStatusUpdate(channelId:String,endStatus:Int,msg:String): Observable<BaseResponse<Any>>
} }
\ No newline at end of file
package com.ydl.audioim.router
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import com.yidianling.im.api.service.IImService
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/21
*/
object AudioImIn {
private fun getImService(): IImService {
return ModularServiceManager.provide(IImService::class.java)
}
/**
* 发送自定义通知
*/
fun sendCustomNotification(toUid: String, content: String, callback: IMSendCustomNotificationResultCallBack) {
getImService().sendCustomNotification(toUid, content, callback)
}
/**
* 注册自定通知接收器
*/
fun registerObserveCustomNotification(callback: IMRegisterObserverCustomNotificationCallBack) {
getImService().registerObserveCustomNotification(callback)
}
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ import android.hardware.SensorManager ...@@ -13,6 +13,7 @@ import android.hardware.SensorManager
import android.net.Uri import android.net.Uri
import android.os.PowerManager import android.os.PowerManager
import android.provider.Settings import android.provider.Settings
import android.support.v4.content.ContextCompat
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import android.view.animation.AccelerateInterpolator import android.view.animation.AccelerateInterpolator
...@@ -34,7 +35,6 @@ import com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl ...@@ -34,7 +35,6 @@ import com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl
import com.ydl.consultantim.utils.ConsultantAudioUtils import com.ydl.consultantim.utils.ConsultantAudioUtils
import com.ydl.consultantim.utils.VibratorUtil import com.ydl.consultantim.utils.VibratorUtil
import com.ydl.ydl_av.chat.bean.AudioMessageBean import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler 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
...@@ -57,7 +57,17 @@ import io.reactivex.Observable ...@@ -57,7 +57,17 @@ import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers 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.iv_hands_free
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.iv_head
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.rl_call
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.rl_hands_free
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.rl_remain_time
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.tv_name
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.tv_nte_status
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.tv_remain_time
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.tv_tips
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.tv_toast
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.wave_view
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
...@@ -68,10 +78,7 @@ import java.util.concurrent.TimeUnit ...@@ -68,10 +78,7 @@ import java.util.concurrent.TimeUnit
* @date 2018/10/30 * @date 2018/10/30
*/ */
@Route(path = "/av/ConsultantAudioHomeActivity") @Route(path = "/av/ConsultantAudioHomeActivity")
class ConsultantAudioHomeActivity : class ConsultantAudioHomeActivity : BaseMvpActivity<IConsultantAudioHomeActivityContract.View, IConsultantAudioHomeActivityContract.Presenter>(), IConsultantAudioHomeActivityContract.View, SensorEventListener {
BaseMvpActivity<IConsultantAudioHomeActivityContract.View, IConsultantAudioHomeActivityContract.Presenter>(),
IConsultantAudioHomeActivityContract.View,
SensorEventListener {
//语音管理类 //语音管理类
private var voiceManage: YDLVoiceManager? = null private var voiceManage: YDLVoiceManager? = null
...@@ -98,12 +105,13 @@ class ConsultantAudioHomeActivity : ...@@ -98,12 +105,13 @@ class ConsultantAudioHomeActivity :
private var connectingStatusDisposable: Disposable? = null private var connectingStatusDisposable: Disposable? = 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 callStatus: Int = -1 private var callStatus: Int = -1
private var userId = -1
/** /**
* 是否连接成功 * 是否连接成功
...@@ -132,7 +140,8 @@ class ConsultantAudioHomeActivity : ...@@ -132,7 +140,8 @@ class ConsultantAudioHomeActivity :
runOnUiThread { runOnUiThread {
// 加入频道后再通知用户已接受 // 加入频道后再通知用户已接受
YDLRTMClient.instances.acceptCall(mAudioMessageBean?.channelId) // YDLRTMClient.instances.acceptCall(mAudioMessageBean?.channelId)
YDLavManager.instances.acceptCall(mAudioMessageBean!!.userId!!, mAudioMessageBean?.channelId, Gson().toJson(mAudioMessageBean))
tv_toast.visibility = View.VISIBLE tv_toast.visibility = View.VISIBLE
tv_toast.text = "连接中..." tv_toast.text = "连接中..."
...@@ -167,7 +176,6 @@ class ConsultantAudioHomeActivity : ...@@ -167,7 +176,6 @@ class ConsultantAudioHomeActivity :
} }
} }
override fun onUserJoined(uid: Int, elapsed: Int) { override fun onUserJoined(uid: Int, elapsed: Int) {
super.onUserJoined(uid, elapsed) super.onUserJoined(uid, elapsed)
LogUtil.e("[agora]远端用户加入频道回调") LogUtil.e("[agora]远端用户加入频道回调")
...@@ -183,7 +191,6 @@ class ConsultantAudioHomeActivity : ...@@ -183,7 +191,6 @@ class ConsultantAudioHomeActivity :
} }
} }
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) { override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
} }
...@@ -192,6 +199,8 @@ class ConsultantAudioHomeActivity : ...@@ -192,6 +199,8 @@ class ConsultantAudioHomeActivity :
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑 // 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) { if (reason == 3) {
showToast("对方已挂断") showToast("对方已挂断")
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "服务端踢人触发的回调")
writeAgoraLog("通话挂断:网络连接被服务器中止") writeAgoraLog("通话挂断:网络连接被服务器中止")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
...@@ -229,6 +238,7 @@ class ConsultantAudioHomeActivity : ...@@ -229,6 +238,7 @@ class ConsultantAudioHomeActivity :
super.onUserOffline(uid, elapsed) super.onUserOffline(uid, elapsed)
LogUtil.e("[agora]$uid 主播离开频道回调") LogUtil.e("[agora]$uid 主播离开频道回调")
runOnUiThread { runOnUiThread {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "对方离开频道")
showToast("对方已挂断") showToast("对方已挂断")
writeAgoraLog("通话接通后挂断:主叫离开频道") writeAgoraLog("通话接通后挂断:主叫离开频道")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -241,14 +251,6 @@ class ConsultantAudioHomeActivity : ...@@ -241,14 +251,6 @@ class ConsultantAudioHomeActivity :
} }
} }
/**
* 网络质量报告回调
* 报告本地用户的网络质量。当你调用 enableLastmileTest 之后,该回调函数每 2 秒触发一次
*/
override fun onLastmileQuality(quality: Int) {
super.onLastmileQuality(quality)
}
override fun onWarning(warn: Int) { override fun onWarning(warn: Int) {
super.onWarning(warn) super.onWarning(warn)
// 过滤1031 录制声音模糊 // 过滤1031 录制声音模糊
...@@ -263,7 +265,8 @@ class ConsultantAudioHomeActivity : ...@@ -263,7 +265,8 @@ class ConsultantAudioHomeActivity :
//107:打开频道请求被服务器拒绝。服务器可能没有办法处理该请求或该请求是非法的 //107:打开频道请求被服务器拒绝。服务器可能没有办法处理该请求或该请求是非法的
runOnUiThread { runOnUiThread {
when (warn) { when (warn) {
103, 104, 105, 106, 107 -> { 103, 105, 107 -> {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "收到频道回调警告信息${warn}")
writeAgoraLog("通话挂断:网络异常($warn)") writeAgoraLog("通话挂断:网络异常($warn)")
showToast("当前网络较差,请更换网络!") showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -278,6 +281,7 @@ class ConsultantAudioHomeActivity : ...@@ -278,6 +281,7 @@ class ConsultantAudioHomeActivity :
super.onError(err) super.onError(err)
uploadException("mRtcEventHandler-onError:errorCode--%${err}") uploadException("mRtcEventHandler-onError:errorCode--%${err}")
LogUtil.e("[agora] 发生错误回调 =$err") LogUtil.e("[agora] 发生错误回调 =$err")
//3:SDK 初始化失败。Agora 建议尝试以下处理方法 //3:SDK 初始化失败。Agora 建议尝试以下处理方法
//7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化 //7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化
//10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误 //10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误
...@@ -308,16 +312,56 @@ class ConsultantAudioHomeActivity : ...@@ -308,16 +312,56 @@ class ConsultantAudioHomeActivity :
close(RESULT_NOT_ANSWERED_CODE, "频道错误,请联系技术") close(RESULT_NOT_ANSWERED_CODE, "频道错误,请联系技术")
} }
123 -> { 123 -> {
// showToast("对方不允许接听电话,请联系客服") // showToast("对方不允许接听电话,请联系客服")
// close(RESULT_NOT_ANSWERED_CODE, "该专家不允许接听电话,请联系客服") // close(RESULT_NOT_ANSWERED_CODE, "该专家不允许接听电话,请联系客服")
} }
else -> { else -> {
} }
} }
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "频道的错误回调信息${err}")
} }
} }
}
override fun onNetworkQuality(uid: Int, txQuality: Int, rxQuality: Int) {
super.onNetworkQuality(uid, txQuality, rxQuality)
var status = -1
var netStatus = when (uid) {
userId!!.toInt() -> {
if (txQuality in 1..2 && rxQuality in 1..2) {
""
} else if (txQuality >= 5 || rxQuality >= 5) {
"对方的网络已断开"
} else {
status = if (txQuality >= 4 || rxQuality >= 4) {
0
} else {
1
}
"对方的网络状况不佳"
}
}
0 -> {
if (txQuality in 1..2 && rxQuality in 1..2) {
""
} else if (txQuality >= 5 || rxQuality >= 5) {
"您的网络已断开"
} else {
status = if (txQuality >= 4 || rxQuality >= 4) {
0
} else {
1
}
"您的网络状况不佳"
}
}
else -> {
""
}
}
showNetStatus(netStatus, status)
}
}
override fun createPresenter(): IConsultantAudioHomeActivityContract.Presenter { override fun createPresenter(): IConsultantAudioHomeActivityContract.Presenter {
return ConsultantAudioHomePresenterImpl() return ConsultantAudioHomePresenterImpl()
...@@ -338,7 +382,6 @@ class ConsultantAudioHomeActivity : ...@@ -338,7 +382,6 @@ class ConsultantAudioHomeActivity :
const val RESULT_USER_CANCEL = 668 const val RESULT_USER_CANCEL = 668
} }
override fun initDataAndEvent() { override fun initDataAndEvent() {
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
//状态栏颜色 //状态栏颜色
...@@ -359,7 +402,6 @@ class ConsultantAudioHomeActivity : ...@@ -359,7 +402,6 @@ class ConsultantAudioHomeActivity :
StatusBarUtils.setWindowStatusBarColor(this, R.color.audioim_color_40353535) StatusBarUtils.setWindowStatusBarColor(this, R.color.audioim_color_40353535)
} }
private fun getParam() { private fun getParam() {
if (null == intent) { if (null == intent) {
close(RESULT_NOT_ANSWERED_CODE, "通话异常") close(RESULT_NOT_ANSWERED_CODE, "通话异常")
...@@ -373,8 +415,7 @@ class ConsultantAudioHomeActivity : ...@@ -373,8 +415,7 @@ class ConsultantAudioHomeActivity :
if (YDLavManager.sdkStatus != Constants.CONNECTION_STATE_CONNECTED) { if (YDLavManager.sdkStatus != Constants.CONNECTION_STATE_CONNECTED) {
writeAgoraLog("RMT状态:${YDLavManager.sdkStatus},重新登录RMT") writeAgoraLog("RMT状态:${YDLavManager.sdkStatus},重新登录RMT")
val uid = val uid = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
YDLavManager.instances.login(uid) { _isSuccess, _msg -> YDLavManager.instances.login(uid) { _isSuccess, _msg ->
writeAgoraLog("登录RTM的uid=${uid}") writeAgoraLog("登录RTM的uid=${uid}")
val result = if (_isSuccess) "RMT登录成功" else "RMT登录失败:$_msg" val result = if (_isSuccess) "RMT登录成功" else "RMT登录失败:$_msg"
...@@ -395,10 +436,7 @@ class ConsultantAudioHomeActivity : ...@@ -395,10 +436,7 @@ class ConsultantAudioHomeActivity :
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager? sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager?
localPowerManager = getSystemService(POWER_SERVICE) as PowerManager? localPowerManager = getSystemService(POWER_SERVICE) as PowerManager?
localWakeLock = localPowerManager!!.newWakeLock( localWakeLock = localPowerManager!!.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "yidianling")
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"yidianling"
)
} }
/** /**
...@@ -419,6 +457,7 @@ class ConsultantAudioHomeActivity : ...@@ -419,6 +457,7 @@ class ConsultantAudioHomeActivity :
} else { } else {
iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic) iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic)
} }
userId = mAudioMessageBean!!.userId?.toInt() ?: -1
} else { } else {
iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic) iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic)
} }
...@@ -440,7 +479,6 @@ class ConsultantAudioHomeActivity : ...@@ -440,7 +479,6 @@ class ConsultantAudioHomeActivity :
//间接性震动手机 //间接性震动手机
VibratorUtil.vibrate(AudioHomeActivity@ this, longArrayOf(1000, 1000, 1000, 1000), true) VibratorUtil.vibrate(AudioHomeActivity@ this, longArrayOf(1000, 1000, 1000, 1000), true)
} }
/** /**
...@@ -452,7 +490,6 @@ class ConsultantAudioHomeActivity : ...@@ -452,7 +490,6 @@ class ConsultantAudioHomeActivity :
mPresenter.getChannelToken(mAudioMessageBean, false) mPresenter.getChannelToken(mAudioMessageBean, false)
} }
override fun channelTokenResponse(token: String?, needJoinChannel: Boolean) { override fun channelTokenResponse(token: String?, needJoinChannel: Boolean) {
if (TextUtils.isEmpty(token)) { if (TextUtils.isEmpty(token)) {
LogUtil.e("[agora]token not null") LogUtil.e("[agora]token not null")
...@@ -479,30 +516,28 @@ class ConsultantAudioHomeActivity : ...@@ -479,30 +516,28 @@ class ConsultantAudioHomeActivity :
rl_hands_free.visibility = View.VISIBLE rl_hands_free.visibility = View.VISIBLE
} }
//申请音频权限 //申请音频权限
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private fun requestPermission() { private fun requestPermission() {
val rxPermissions = RxPermissions(this) val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO) rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO).subscribe { permission ->
.subscribe { permission -> when {
when { //权限已申请 进行初始化操作
//权限已申请 进行初始化操作 permission.granted -> init()
permission.granted -> init() //权限为申请 重新申请
//权限为申请 重新申请 permission.shouldShowRequestPermissionRationale -> requestPermission()
permission.shouldShowRequestPermissionRationale -> requestPermission() //跳转设置界面
//跳转设置界面 else -> {
else -> { ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) val uri = Uri.fromParts("package", packageName, null)
val uri = Uri.fromParts("package", packageName, null) intent.data = uri
intent.data = uri startActivity(intent)
startActivity(intent) finish()
finish()
}
} }
} }
}
} }
private fun init() { private fun init() {
...@@ -524,7 +559,6 @@ class ConsultantAudioHomeActivity : ...@@ -524,7 +559,6 @@ class ConsultantAudioHomeActivity :
voiceManage!!.init() voiceManage!!.init()
} }
/** /**
* 加入频道 * 加入频道
*/ */
...@@ -532,14 +566,11 @@ class ConsultantAudioHomeActivity : ...@@ -532,14 +566,11 @@ class ConsultantAudioHomeActivity :
val account = YdlCommonRouterManager.getYdlCommonRoute().getUid() val account = YdlCommonRouterManager.getYdlCommonRoute().getUid()
if (!TextUtils.isEmpty(mAudioMessageBean?.channelId)) { if (!TextUtils.isEmpty(mAudioMessageBean?.channelId)) {
LogUtil.e("[agora] joinChannel:$account") LogUtil.e("[agora] joinChannel:$account")
voiceManage?.getVoiceApi()?.joinChannel( voiceManage?.getVoiceApi()?.joinChannel(channelToken
channelToken ?: "", mAudioMessageBean!!.channelId!!, "Extra Optional Data", account)
?: "", mAudioMessageBean!!.channelId!!, "Extra Optional Data", account
)
} }
} }
override fun executeFinish() { override fun executeFinish() {
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
...@@ -556,16 +587,13 @@ class ConsultantAudioHomeActivity : ...@@ -556,16 +587,13 @@ class ConsultantAudioHomeActivity :
rl_remain_time.visibility = View.VISIBLE rl_remain_time.visibility = View.VISIBLE
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS) totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS).subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe({
.subscribeOn(Schedulers.computation()) tv_remain_time.text = DateUtils.formatTime(it.toString())
.observeOn(AndroidSchedulers.mainThread()) }, {
.subscribe({ //通话结束或挂断时,上传日志文件
tv_remain_time.text = DateUtils.formatTime(it.toString()) uploadLog()
}, { close(RESULT_NOT_ANSWERED_CODE, "对方异常")
//通话结束或挂断时,上传日志文件 })
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "对方异常")
})
} }
/** /**
...@@ -575,15 +603,16 @@ class ConsultantAudioHomeActivity : ...@@ -575,15 +603,16 @@ class ConsultantAudioHomeActivity :
status = STATUS_NOT_ANSWERED status = STATUS_NOT_ANSWERED
} }
private fun showStopService() { private fun showStopService() {
if (status == STATUS_NOT_ANSWERED) { if (status == STATUS_NOT_ANSWERED) {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 2, "被叫主动拒绝")
writeAgoraLog("通话未接通挂断:主动挂断") writeAgoraLog("通话未接通挂断:主动挂断")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
//当未接听 直接挂断 要发送给老师一条消息 //当未接听 直接挂断 要发送给老师一条消息
close(RESULT_NOT_ANSWERED_CODE, "用户已挂断") close(RESULT_NOT_ANSWERED_CODE, "用户已挂断")
} else if (status == STATUS_ANSWERED) { } else if (status == STATUS_ANSWERED) {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 3, "被叫主动拒绝")
writeAgoraLog("通话接通后挂断:专家主动挂断") writeAgoraLog("通话接通后挂断:专家主动挂断")
//正常接听 挂断电话 需要重置信令管理类状态 //正常接听 挂断电话 需要重置信令管理类状态
close(RESULT_ANSWERED_CODE, "") close(RESULT_ANSWERED_CODE, "")
...@@ -591,7 +620,6 @@ class ConsultantAudioHomeActivity : ...@@ -591,7 +620,6 @@ class ConsultantAudioHomeActivity :
} }
override fun listenStatusPushResponse() { override fun listenStatusPushResponse() {
} }
/** /**
...@@ -604,12 +632,7 @@ class ConsultantAudioHomeActivity : ...@@ -604,12 +632,7 @@ class ConsultantAudioHomeActivity :
} }
showStopService() showStopService()
ActionCountUtils.count( ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_refuse_click", YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString())
"shengwang_popup_layer_page|shengwang_popup_layer_refuse_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
/** /**
...@@ -623,17 +646,13 @@ class ConsultantAudioHomeActivity : ...@@ -623,17 +646,13 @@ class ConsultantAudioHomeActivity :
//调用接口判断邀请专家的用户当前是否在频道内,如果在,则专家加入频道,如果不在,则提示用户已挂断 //调用接口判断邀请专家的用户当前是否在频道内,如果在,则专家加入频道,如果不在,则提示用户已挂断
//更改逻辑:现在是专家先进频道,这个接口暂时只作为参考 //更改逻辑:现在是专家先进频道,这个接口暂时只作为参考
// presenter.userIsInChannel(mAudioMessageBean?.channelId ?: "", mAudioMessageBean?.userId // presenter.userIsInChannel(mAudioMessageBean?.channelId ?: "", mAudioMessageBean?.userId
// ?: "") // ?: "")
executeCall(true) executeCall(true)
ActionCountUtils.count( ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_answer_click", YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString())
"shengwang_popup_layer_page|shengwang_popup_layer_answer_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
/** /**
...@@ -657,7 +676,6 @@ class ConsultantAudioHomeActivity : ...@@ -657,7 +676,6 @@ class ConsultantAudioHomeActivity :
//获取频道token //获取频道token
mPresenter.getChannelToken(mAudioMessageBean) mPresenter.getChannelToken(mAudioMessageBean)
} }
} }
} }
} }
...@@ -682,25 +700,14 @@ class ConsultantAudioHomeActivity : ...@@ -682,25 +700,14 @@ class ConsultantAudioHomeActivity :
voiceManage!!.getVoiceApi().setEnableSpeakerphone(view.isSelected) voiceManage!!.getVoiceApi().setEnableSpeakerphone(view.isSelected)
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
sensorManager!!.registerListener( sensorManager!!.registerListener(this, sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL)
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
ActionCountUtils.count( ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_page_visit", "", uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString())
"shengwang_popup_layer_page|shengwang_popup_layer_page_visit",
"",
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) { override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
} }
override fun onSensorChanged(event: SensorEvent?) { override fun onSensorChanged(event: SensorEvent?) {
...@@ -723,7 +730,6 @@ class ConsultantAudioHomeActivity : ...@@ -723,7 +730,6 @@ class ConsultantAudioHomeActivity :
} }
} }
/** /**
* 显示自定义弹窗 * 显示自定义弹窗
*/ */
...@@ -733,6 +739,29 @@ class ConsultantAudioHomeActivity : ...@@ -733,6 +739,29 @@ class ConsultantAudioHomeActivity :
} }
} }
/**
* 网络状态
*/
private fun showNetStatus(msg: String, status: Int = 0) {
runOnUiThread {
if (TextUtils.isEmpty(msg)) {
tv_nte_status.visibility = View.GONE
} else {
tv_nte_status.text = msg
if (status == 0) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_normal), null, null, null)
}
if (status == 1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_better), null, null, null)
}
if (status == -1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
}
tv_nte_status.visibility = View.VISIBLE
}
}
}
//关闭本页面 //关闭本页面
fun close(code: Int, msg: String) { fun close(code: Int, msg: String) {
runOnUiThread { runOnUiThread {
...@@ -748,7 +777,8 @@ class ConsultantAudioHomeActivity : ...@@ -748,7 +777,8 @@ class ConsultantAudioHomeActivity :
callStatus = 2 callStatus = 2
uploadException("被叫拒绝", zhu = "") uploadException("被叫拒绝", zhu = "")
//未接听,直接挂断 发送消息 //未接听,直接挂断 发送消息
YDLRTMClient.instances.refuseCall(mAudioMessageBean?.channelId) // YDLRTMClient.instances.refuseCall(mAudioMessageBean?.channelId)
YDLavManager.instances.refuseCall(mAudioMessageBean!!.userId!!, mAudioMessageBean?.channelId, Gson().toJson(mAudioMessageBean))
} else if (code == RESULT_USER_CANCEL) { } else if (code == RESULT_USER_CANCEL) {
callStatus = 1 callStatus = 1
uploadException("主叫取消", zhu = "") uploadException("主叫取消", zhu = "")
...@@ -782,7 +812,7 @@ class ConsultantAudioHomeActivity : ...@@ -782,7 +812,7 @@ class ConsultantAudioHomeActivity :
mPlayer = AudioPlayer(this) mPlayer = AudioPlayer(this)
} }
mPlayer!!.setDataSource(R.raw.audioim_hand_down_music) mPlayer!!.setDataSource(R.raw.audioim_hand_down_music)
// mPlayer!!.switchPlayType(true) // mPlayer!!.switchPlayType(true)
mPlayer!!.start(isLooping = false, isSetOnCompletionListener = false) mPlayer!!.start(isLooping = false, isSetOnCompletionListener = false)
} }
...@@ -795,21 +825,17 @@ class ConsultantAudioHomeActivity : ...@@ -795,21 +825,17 @@ class ConsultantAudioHomeActivity :
*/ */
private fun connectingStatusWaitingTimeCount() { private fun connectingStatusWaitingTimeCount() {
if (connectingStatusDisposable == null) { if (connectingStatusDisposable == null) {
connectingStatusDisposable = Observable.interval(0, 1, TimeUnit.SECONDS) connectingStatusDisposable = Observable.interval(0, 1, TimeUnit.SECONDS).subscribeOn(Schedulers.computation()).take(6).observeOn(AndroidSchedulers.mainThread()).subscribe({}, {}, {
.subscribeOn(Schedulers.computation()) if (!isConnectSuccess) {
.take(6) YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 1, "被叫加入频道后主叫未加入超时")
.observeOn(AndroidSchedulers.mainThread()) writeAgoraLog("通话未接通挂断:连接中的状态超过5s自动挂断")
.subscribe({}, {}, { showToast("用户已挂断")
if (!isConnectSuccess) { close(RESULT_NOT_ANSWERED_CODE, "")
writeAgoraLog("通话未接通挂断:连接中的状态超过5s自动挂断") }
showToast( "用户已挂断") })
close(RESULT_NOT_ANSWERED_CODE, "")
}
})
} }
} }
/** /**
* 离开频道 * 离开频道
*/ */
...@@ -854,7 +880,6 @@ class ConsultantAudioHomeActivity : ...@@ -854,7 +880,6 @@ class ConsultantAudioHomeActivity :
* 重写返回键逻辑:屏蔽返回键 * 重写返回键逻辑:屏蔽返回键
*/ */
override fun onBackPressed() { override fun onBackPressed() {
} }
private fun writeAgoraLog(content: String) { private fun writeAgoraLog(content: String) {
...@@ -863,8 +888,7 @@ class ConsultantAudioHomeActivity : ...@@ -863,8 +888,7 @@ class ConsultantAudioHomeActivity :
AudioLogUtils.writeAgoraLog(content, "consult") AudioLogUtils.writeAgoraLog(content, "consult")
} catch (e: Exception) { } catch (e: Exception) {
} }
}.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io()).subscribe()
.subscribe()
} }
fun uploadExceptionStatus(msg: String, status: Int) { fun uploadExceptionStatus(msg: String, status: Int) {
...@@ -875,17 +899,11 @@ class ConsultantAudioHomeActivity : ...@@ -875,17 +899,11 @@ class ConsultantAudioHomeActivity :
/** /**
* 上传错误日志 * 上传错误日志
*/ */
private fun uploadException( private fun uploadException(message: String, zhu: String = "", eventType: String = "99") {
message: String,
zhu: String = "",
eventType: String = "99"
) {
var time: String = (System.currentTimeMillis() / 1000).toString() var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String = var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(mAudioMessageBean?.channelId ?: "0", time, uid, "1", "999", message) var payLoad = PayLoad(mAudioMessageBean?.channelId ?: "0", time, uid, "1", "999", message)
var connectException = var connectException = ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus)
ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus)
YDLavManager.instances.uploadException(connectException, null) YDLavManager.instances.uploadException(connectException, null)
} }
...@@ -906,11 +924,8 @@ class ConsultantAudioHomeActivity : ...@@ -906,11 +924,8 @@ class ConsultantAudioHomeActivity :
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
if (ActivityManager.getActivitySize() == 1) { if (ActivityManager.getActivitySize() == 1) {
try { try {
// startActivity(MainActivity.newIntent(this, false)) // startActivity(MainActivity.newIntent(this, false))
ARouter.getInstance().build("/main/main") ARouter.getInstance().build("/main/main").addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).navigation()
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.navigation()
} catch (e: Exception) { } catch (e: Exception) {
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/platform_color_80353535"> android:background="@color/platform_color_80353535">
<TextView <TextView
android:id="@+id/tv_change_route" android:id="@+id/tv_change_route"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -14,21 +15,30 @@ ...@@ -14,21 +15,30 @@
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:drawableRight="@drawable/audioim_img_choose_arrow_unuse"
android:drawablePadding="6dp" android:drawablePadding="6dp"
android:padding="5dp" android:padding="5dp"
android:text="切换至传统电话" android:text="后可切换至传统电话"
android:textColor="@color/platform_color_50FFFFFF" android:textColor="@color/platform_color_50FFFFFF"
android:textSize="13sp" android:textSize="13sp"
android:visibility="visible" /> android:visibility="visible" />
<TextView
android:id="@+id/tv_change_time_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tv_change_route"
android:layout_toLeftOf="@+id/tv_change_route"
android:textColor="@color/white"
android:textSize="15dp"
tools:text="60s" />
<RelativeLayout <RelativeLayout
android:id="@+id/rl_head" android:id="@+id/rl_head"
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="250dp" android:layout_height="250dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="74dp"> android:layout_marginTop="60dp">
<com.ydl.ydlcommon.view.WaveView <com.ydl.ydlcommon.view.WaveView
android:id="@+id/wave_view" android:id="@+id/wave_view"
...@@ -80,33 +90,53 @@ ...@@ -80,33 +90,53 @@
tools:text="你存在的本身就是值得被爱的你存在的本身就是值得被爱的" /> tools:text="你存在的本身就是值得被爱的你存在的本身就是值得被爱的" />
<!-- 倾诉剩余时间--> <!-- 倾诉剩余时间-->
<RelativeLayout <android.support.constraint.ConstraintLayout
android:id="@+id/rl_remain_time" android:id="@+id/rl_remain_time"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/rl_hang_up" android:layout_above="@+id/rl_hang_up"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:visibility="gone"> android:visibility="gone"
tools:visibility="visible">
<TextView <TextView
android:id="@+id/tv_notes" android:id="@+id/tv_notes"
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:text="剩余时长"
android:text="您的倾诉时间还有" android:textColor="@color/white"
android:textColor="@color/platform_color_30FFFFFF" android:textSize="15dp"
android:textSize="12sp" /> app:layout_constraintEnd_toStartOf="@+id/tv_remain_time"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_remain_time" android:id="@+id/tv_remain_time"
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_notes" android:layout_marginStart="11dp"
android:layout_centerHorizontal="true" android:layout_toRightOf="@+id/tv_notes"
android:text="23:23" android:text="23:23"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="20sp" /> android:textSize="16dp"
</RelativeLayout> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_notes"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_notes"
android:layout_marginTop="2dp"
android:text="(限24小时内拨打)"
android:textColor="#80FFFFFF"
android:textSize="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_remain_time" />
</android.support.constraint.ConstraintLayout>
<TextView <TextView
android:id="@+id/tv_change_doctor" android:id="@+id/tv_change_doctor"
...@@ -130,7 +160,8 @@ ...@@ -130,7 +160,8 @@
android:text="正在等待聆听者接受邀请…" android:text="正在等待聆听者接受邀请…"
android:textColor="@color/platform_color_70FFFFFF" android:textColor="@color/platform_color_70FFFFFF"
android:textSize="12sp" android:textSize="12sp"
android:visibility="visible" /> android:visibility="visible"
tools:visibility="gone" />
<!--挂断按钮--> <!--挂断按钮-->
<RelativeLayout <RelativeLayout
...@@ -212,8 +243,27 @@ ...@@ -212,8 +243,27 @@
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:textColor="@color/white" android:textColor="@color/white"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"
tools:text="已接通" tools:text="已接通"
/> tools:visibility="visible" />
<TextView
android:id="@+id/tv_nte_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_tips"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="@drawable/audioim_toast_view_background"
android:drawableLeft="@drawable/av_audio_wifi_better"
android:elevation="6dp"
android:paddingLeft="11dp"
android:paddingTop="4dp"
android:paddingRight="11dp"
android:paddingBottom="4dp"
android:textColor="@color/white"
android:visibility="gone"
tools:text="对方的网络状况不佳"
tools:visibility="visible" />
</RelativeLayout> </RelativeLayout>
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="26sp" android:textSize="26sp"
tools:text="用户" /> tools:text="用户" />
<TextView <TextView
android:id="@+id/tv_tips" android:id="@+id/tv_tips"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -59,9 +60,9 @@ ...@@ -59,9 +60,9 @@
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="2" android:maxLines="2"
android:text="向您发起语音通话请求"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="15sp" android:textSize="15sp" />
android:text="向您发起语音通话请求" />
<!--自定义弹窗--> <!--自定义弹窗-->
...@@ -83,6 +84,26 @@ ...@@ -83,6 +84,26 @@
tools:text="连接中..." tools:text="连接中..."
tools:visibility="visible" /> tools:visibility="visible" />
<TextView
android:id="@+id/tv_nte_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_tips"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="@drawable/audioim_toast_view_background"
android:drawableLeft="@drawable/av_audio_wifi_better"
android:elevation="6dp"
android:paddingLeft="11dp"
android:paddingTop="4dp"
android:paddingRight="11dp"
android:paddingBottom="4dp"
android:textColor="@color/white"
android:visibility="gone"
tools:text="对方的网络状况不佳"
tools:visibility="visible" />
<!-- 倾诉剩余时间--> <!-- 倾诉剩余时间-->
<RelativeLayout <RelativeLayout
android:id="@+id/rl_remain_time" android:id="@+id/rl_remain_time"
......
...@@ -6,34 +6,35 @@ import com.ydl.audioim.bean.ExpertInfoBean ...@@ -6,34 +6,35 @@ import com.ydl.audioim.bean.ExpertInfoBean
/** /**
* 倾诉连接响应数据 * 倾诉连接响应数据
*/ */
class ConfideConnectResponse{ class ConfideConnectResponse {
var dialDetail : DialDetail? = null var dialDetail: DialDetail? = null
var listenOrderId : Long? = 0 //订单ID var listenOrderId: Long? = 0 //订单ID
var callId : String? = null // var callId: String? = null //
var payId : String?=null //支付ID var payId: String? = null //支付ID
var payTitle : String? = null //支付标题 var payTitle: String? = null //支付标题
var listenOrderPrice : Double? = null //订单金额 var listenOrderPrice: Double? = null //订单金额
var userBaseInfoRespDto : UserBaseInfoRespDto?=null var userBaseInfoRespDto: UserBaseInfoRespDto? = null
var coupon : CouponData? = null //优惠信息 var coupon: CouponData? = null //优惠信息
var isShowAxb = true
} }
class DialDetail{ class DialDetail {
var agoraExpertInfo: ExpertInfoBean? = null var agoraExpertInfo: ExpertInfoBean? = null
var callConnectType :Int ? = null var callConnectType: Int? = null
var dialReason : String? = null //连接失败原因 var dialReason: String? = null //连接失败原因
var dialStatus : Int? = null //连接状态 var dialStatus: Int? = null //连接状态
var phoneNu : String ?= null //axb号码 var phoneNu: String? = null //axb号码
} }
class UserBaseInfoRespDto{ class UserBaseInfoRespDto {
var availableMoney : Double ? = null var availableMoney: Double? = null
var companyMoney : Double ? = null var companyMoney: Double? = null
var doctorId : Long ? = null var doctorId: Long? = null
var phone : Long ? = null var phone: Long? = null
var userType : String?=null var userType: String? = null
} }
class CouponData{ class CouponData {
var couponMoney:Double? = 0.00 var couponMoney: Double? = 0.00
} }
\ No newline at end of file
...@@ -84,7 +84,7 @@ class ConfideWebServiceImpl{ ...@@ -84,7 +84,7 @@ class ConfideWebServiceImpl{
if (it.data?.dialDetail?.callConnectType?:-1==3){ if (it.data?.dialDetail?.callConnectType?:-1==3){
//声网 //声网
it.data?.dialDetail?.agoraExpertInfo?:return@subscribe it.data?.dialDetail?.agoraExpertInfo?:return@subscribe
callAgora(activity,id,it.data!!.dialDetail!!.agoraExpertInfo!!,it.data.callId?:"0",it.data.listenOrderId?:0L,tellData) callAgora(activity,id,it.data!!.dialDetail!!.agoraExpertInfo!!,it.data.callId?:"0",it.data.listenOrderId?:0L,tellData,it.data.isShowAxb)
}else{ }else{
//axb //axb
val dialog = AxbConfirmDialog(activity,1,object :AxbConfirmDialog.OnClickEnsureListener{ val dialog = AxbConfirmDialog(activity,1,object :AxbConfirmDialog.OnClickEnsureListener{
...@@ -114,7 +114,7 @@ class ConfideWebServiceImpl{ ...@@ -114,7 +114,7 @@ class ConfideWebServiceImpl{
} }
//启动声网电话 //启动声网电话
private fun callAgora(activity: Activity, confideId:Int, expertInfo : ExpertInfoBean, call_id:String, relation_id:Long, tellData: TellData?){ private fun callAgora(activity: Activity, confideId:Int, expertInfo : ExpertInfoBean, call_id:String, relation_id:Long, tellData: TellData?,isShowAXB:Boolean){
//3G以下或者其他不确定异常能判断出来的 //3G以下或者其他不确定异常能判断出来的
if (!ConfideNetworkUtil.isWifiOr3G(activity)) { if (!ConfideNetworkUtil.isWifiOr3G(activity)) {
CommonDialog.create(activity) CommonDialog.create(activity)
...@@ -156,6 +156,7 @@ class ConfideWebServiceImpl{ ...@@ -156,6 +156,7 @@ class ConfideWebServiceImpl{
.withString(IntentConstants.INTENT_TOTAL_DURATION, expertInfo.totalDuration) .withString(IntentConstants.INTENT_TOTAL_DURATION, expertInfo.totalDuration)
.withString(IntentConstants.INTENT_COMMENT_URL, expertInfo.commentUrl) .withString(IntentConstants.INTENT_COMMENT_URL, expertInfo.commentUrl)
.withString(IntentConstants.INTENT_LISTEN_ID, confideId.toString()) .withString(IntentConstants.INTENT_LISTEN_ID, confideId.toString())
.withBoolean(IntentConstants.INTENT_ISSHOWAXB,isShowAXB)
.navigation(activity) .navigation(activity)
} }
} }
......
...@@ -62,8 +62,9 @@ import org.json.JSONObject ...@@ -62,8 +62,9 @@ import org.json.JSONObject
import java.util.concurrent.Executors import java.util.concurrent.Executors
@Route(path = "/consult/list") @Route(path = "/consult/list")
class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPresenter>(), View.OnClickListener, IExpertSearchView, class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPresenter>(),
OnCategoriesSelectedListener, OnSortItemSelectedListener, OnFilterConfirmListener, View.OnClickListener, IExpertSearchView,
OnCategoriesSelectedListener, OnSortItemSelectedListener, OnFilterConfirmListener,
SwipeRefreshLayout.OnRefreshListener { SwipeRefreshLayout.OnRefreshListener {
override fun showImage(url: String?, imgView: ImageView) { override fun showImage(url: String?, imgView: ImageView) {
...@@ -74,7 +75,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -74,7 +75,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
YDLImageCacheManager.showImage(ExpertSearchActivity@ this, url, imgView, ops) YDLImageCacheManager.showImage(ExpertSearchActivity@ this, url, imgView, ops)
} }
override fun showImage(url: String?, imgView: ImageView, width: Int, heigh: Int, ops: SimpleImageOpConfiger) { override fun showImage(
url: String?,
imgView: ImageView,
width: Int,
heigh: Int,
ops: SimpleImageOpConfiger
) {
YDLImageCacheManager.showImage(ExpertSearchActivity@ this, url, imgView, width, heigh, ops) YDLImageCacheManager.showImage(ExpertSearchActivity@ this, url, imgView, width, heigh, ops)
} }
...@@ -89,7 +96,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -89,7 +96,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
override fun getStatusViewOptions(): StatusBarOptions { override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(true,true) return StatusBarOptions(true, true)
} }
companion object { companion object {
...@@ -109,7 +116,12 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -109,7 +116,12 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
const val FROM_ONLINE_EXPERT = 2 const val FROM_ONLINE_EXPERT = 2
const val PAGE_SIZE = 15 const val PAGE_SIZE = 15
fun newIntent(activity: Activity, category: Int, showType: Int, isInitShowHot: Boolean): Intent { fun newIntent(
activity: Activity,
category: Int,
showType: Int,
isInitShowHot: Boolean
): Intent {
val intent = Intent(activity, ExpertSearchActivity::class.java) val intent = Intent(activity, ExpertSearchActivity::class.java)
intent.putExtra(EXTRA_CATEGORY, category) intent.putExtra(EXTRA_CATEGORY, category)
intent.putExtra(EXTRA_SHOW_TYPE, showType) intent.putExtra(EXTRA_SHOW_TYPE, showType)
...@@ -192,11 +204,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -192,11 +204,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
btn_call.setOnClickListener(this) btn_call.setOnClickListener(this)
tv_guide.setOnClickListener(this) tv_guide.setOnClickListener(this)
rl_search.setOnClickListener(this) rl_search.setOnClickListener(this)
srlContainer.setColorSchemeColors(ContextCompat.getColor(this, R.color.platform_main_theme)) srlContainer.setColorSchemeColors(
ContextCompat.getColor(
this,
R.color.consultant_main_theme
)
)
srlContainer.setProgressViewOffset(false, 0, 200) srlContainer.setProgressViewOffset(false, 0, 200)
srlContainer.setOnRefreshListener(this) srlContainer.setOnRefreshListener(this)
recommendListView.addViewPagerScrollStateListener(object : RecommendListView.ViewPagerScrollStateCallback { recommendListView.addViewPagerScrollStateListener(object :
RecommendListView.ViewPagerScrollStateCallback {
override fun viewPagerScroll(isScrolling: Boolean) { override fun viewPagerScroll(isScrolling: Boolean) {
//如果viewpager正在滚动,则禁止下拉刷新 //如果viewpager正在滚动,则禁止下拉刷新
srlContainer.isEnabled = !isScrolling srlContainer.isEnabled = !isScrolling
...@@ -241,7 +259,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -241,7 +259,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) { } else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
//没有滚动 //没有滚动
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this@ExpertSearchActivity, "doctor_list", true) ConsultAssistantDialogUtils.INSTANCE.fitRequest(
this@ExpertSearchActivity,
"doctor_list",
true
)
if (sIsScrolling) { if (sIsScrolling) {
if (!this@ExpertSearchActivity.isFinishing) { if (!this@ExpertSearchActivity.isFinishing) {
// GlideApp.with(this@ExpertSearchActivity).resumeRequests() // GlideApp.with(this@ExpertSearchActivity).resumeRequests()
...@@ -255,7 +277,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -255,7 +277,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f) var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f) var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f) var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200) var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.GONE image_scroll_top.visibility = View.GONE
...@@ -272,7 +296,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -272,7 +296,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f) var alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f) var scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f) var scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200) var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.VISIBLE image_scroll_top.visibility = View.VISIBLE
...@@ -289,7 +315,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -289,7 +315,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f) var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f) var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f) var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200) var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.GONE image_scroll_top.visibility = View.GONE
...@@ -378,9 +406,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -378,9 +406,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
v_loading.visibility = View.VISIBLE v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null) v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
if (fromPageType != -1) { doctorAdapter.setEntrance( 1)
doctorAdapter.setEntrance(fromPages[fromPageType],1)
}
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
...@@ -456,7 +482,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -456,7 +482,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
val popWidth = RxDeviceTool.getScreenWidth(mContext) val popWidth = RxDeviceTool.getScreenWidth(mContext)
val mWidth = (popWidth - RxImageTool.dp2px(10f)) / hotData.size val mWidth = (popWidth - RxImageTool.dp2px(10f)) / hotData.size
for ((index, hot) in hotData!!.withIndex()) { for ((index, hot) in hotData!!.withIndex()) {
val tv = View.inflate(mContext, R.layout.consultant_item_filter_online, null) as TextView val tv =
View.inflate(mContext, R.layout.consultant_item_filter_online, null) as TextView
val textView = tv.tvFree val textView = tv.tvFree
val params = LinearLayout.LayoutParams(0, RxImageTool.dp2px(22f)) val params = LinearLayout.LayoutParams(0, RxImageTool.dp2px(22f))
params.weight = 1f params.weight = 1f
...@@ -596,7 +623,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -596,7 +623,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
when { when {
allFilter.reorder.value.equals("综合排序") -> tvSort.text = "排序" allFilter.reorder.value.equals("综合排序") -> tvSort.text = "排序"
allFilter.reorder.value?.length ?: 0 > 4 -> tvSort.text = allFilter.reorder.value?.substring(0, 3) + "..." allFilter.reorder.value?.length ?: 0 > 4 -> tvSort.text =
allFilter.reorder.value?.substring(0, 3) + "..."
else -> tvSort.text = allFilter.reorder.value else -> tvSort.text = allFilter.reorder.value
} }
} }
...@@ -700,7 +728,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -700,7 +728,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
bean.key = hotData.id bean.key = hotData.id
bean.value = hotData.value bean.value = hotData.value
for (headBean in headData!!.region) { for (headBean in headData!!.region) {
if (TextUtils.equals(headBean.key!!.substring(0, 2), bean.key!!.substring(0, 2))) { if (TextUtils.equals(
headBean.key!!.substring(0, 2),
bean.key!!.substring(0, 2)
)
) {
allFilter.region = headBean allFilter.region = headBean
break break
} }
...@@ -752,7 +784,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -752,7 +784,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
//服务列表数据获取到后的回调 //服务列表数据获取到后的回调
override fun onServiceListFetched(data: MutableList<DoctorServiceItem>, page: Int, totalPage: Int) { override fun onServiceListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onServiceListFetched") LogUtil.d("onServiceListFetched")
// if (rvExperts.adapter != serviceAdapter) { // if (rvExperts.adapter != serviceAdapter) {
// rvExperts.adapter = serviceAdapter // rvExperts.adapter = serviceAdapter
...@@ -790,7 +826,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -790,7 +826,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
//专家列表数据获取到后的回调 //专家列表数据获取到后的回调
override fun onDoctorListFetched(data: MutableList<DoctorServiceItem>, page: Int, totalPage: Int) { override fun onDoctorListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onDoctorListFetched") LogUtil.d("onDoctorListFetched")
if (rvExperts.adapter != doctorAdapter) { if (rvExperts.adapter != doctorAdapter) {
rvExperts.adapter = doctorAdapter rvExperts.adapter = doctorAdapter
...@@ -833,7 +873,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -833,7 +873,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
isRecommend = false isRecommend = false
if (curPage == 1) { if (curPage == 1) {
v_loading.setViewType(LogoLoadingView.TYPE_NET_LOSS, getString(R.string.consultant_reload_hint)) v_loading.setViewType(
LogoLoadingView.TYPE_NET_LOSS,
getString(R.string.consultant_reload_hint)
)
v_loading.visibility = View.VISIBLE v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE ll_network_error.visibility = View.GONE
...@@ -864,7 +907,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -864,7 +907,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (msg != null) { if (msg != null) {
ToastUtil.toastShort(msg) ToastUtil.toastShort(msg)
} }
v_loading.setViewType(LogoLoadingView.TYPE_NET_LOSS, getString(R.string.consultant_reload_hint)) v_loading.setViewType(
LogoLoadingView.TYPE_NET_LOSS,
getString(R.string.consultant_reload_hint)
)
v_loading.visibility = View.VISIBLE v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE ll_network_error.visibility = View.GONE
...@@ -923,7 +969,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -923,7 +969,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
R.id.tv_guide -> { R.id.tv_guide -> {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CONSULT_GUIDE_CLICK) ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CONSULT_GUIDE_CLICK)
val h5param = H5Params(HttpConfig.H5_URL+ "help/consultation/", "咨询指南") val h5param = H5Params(HttpConfig.H5_URL + "help/consultation/", "咨询指南")
h5param.isShowMenu = true h5param.isShowMenu = true
NewH5Activity.start(this, h5param) NewH5Activity.start(this, h5param)
} }
...@@ -934,9 +980,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -934,9 +980,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
R.id.rl_search -> { R.id.rl_search -> {
ARouter.getInstance() ARouter.getInstance()
.build("/consult/hot_search") .build("/consult/hot_search")
.withString(HOT_SEARCH_DOCTOR_NAME, tv_search_content.text.toString()) .withString(HOT_SEARCH_DOCTOR_NAME, tv_search_content.text.toString())
.navigation() .navigation()
} }
} }
} }
...@@ -974,12 +1020,15 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -974,12 +1020,15 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
filterPopupWindow.setOnDismissListener { filterPopupWindow.setOnDismissListener {
// viewDim.visibility = View.INVISIBLE // viewDim.visibility = View.INVISIBLE
viewDim_filter.visibility = View.GONE viewDim_filter.visibility = View.GONE
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size > 0 || !TextUtils.isEmpty(allFilter.priceRanges?.minPrice) || !TextUtils.isEmpty(allFilter.priceRanges?.maxPrice)) { if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size > 0 || !TextUtils.isEmpty(
allFilter.priceRanges?.minPrice
) || !TextUtils.isEmpty(allFilter.priceRanges?.maxPrice)
) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED) updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else { } else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL) updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
} }
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true) ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true)
} }
filterPopupWindow.isClippingEnabled = false filterPopupWindow.isClippingEnabled = false
filterPopupWindow.showAtLocation(viewSep2.rootView, Gravity.TOP + Gravity.RIGHT, 0, 0) filterPopupWindow.showAtLocation(viewSep2.rootView, Gravity.TOP + Gravity.RIGHT, 0, 0)
...@@ -997,8 +1046,19 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -997,8 +1046,19 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//筛选确认回调 //筛选确认回调
override fun onFilterConfirmed() { override fun onFilterConfirmed() {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN) updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
LogUtil.d("filter: " + tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(",")) LogUtil.d(
props1.put("filtrate_second", tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(",")) "filter: " + tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(
","
) + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(
","
)
)
props1.put(
"filtrate_second",
tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(
","
) + "," + tempFilter.others.map { it.value }.joinToString(",")
)
BuryPointUtils.buryPoint("Filtrate", props1) BuryPointUtils.buryPoint("Filtrate", props1)
...@@ -1025,7 +1085,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1025,7 +1085,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textview.paint.isFakeBoldText = false textview.paint.isFakeBoldText = false
} }
for (bean in allFilter.enquiries) { for (bean in allFilter.enquiries) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) { if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
this@ExpertSearchActivity.runOnUiThread { this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true textview.isSelected = true
textview.paint.isFakeBoldText = true textview.paint.isFakeBoldText = true
...@@ -1041,7 +1105,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1041,7 +1105,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textview.paint.isFakeBoldText = false textview.paint.isFakeBoldText = false
} }
for (bean in allFilter.ages) { for (bean in allFilter.ages) {
if (TextUtils.equals(bean.value.toString(), headData!!.highlighter[index].id)) { if (TextUtils.equals(
bean.value.toString(),
headData!!.highlighter[index].id
)
) {
this@ExpertSearchActivity.runOnUiThread { this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true textview.isSelected = true
textview.paint.isFakeBoldText = true textview.paint.isFakeBoldText = true
...@@ -1057,7 +1125,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1057,7 +1125,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textview.paint.isFakeBoldText = false textview.paint.isFakeBoldText = false
} }
for (bean in allFilter.others) { for (bean in allFilter.others) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) { if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
this@ExpertSearchActivity.runOnUiThread { this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true textview.isSelected = true
textview.paint.isFakeBoldText = true textview.paint.isFakeBoldText = true
...@@ -1074,7 +1146,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1074,7 +1146,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textview.paint.isFakeBoldText = false textview.paint.isFakeBoldText = false
} }
for (bean in allFilter.title) { for (bean in allFilter.title) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) { if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
this@ExpertSearchActivity.runOnUiThread { this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true textview.isSelected = true
textview.paint.isFakeBoldText = true textview.paint.isFakeBoldText = true
...@@ -1148,8 +1224,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1148,8 +1224,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//排序选择回调 //排序选择回调
override fun onSortItemSelected(sortItem: ReorderItem) { override fun onSortItemSelected(sortItem: ReorderItem) {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_SORT_CLICK, sortItem.value ActionCountUtils.count(
?: "") ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_SORT_CLICK, sortItem.value
?: ""
)
if (sortItem.value.equals("综合排序")) { if (sortItem.value.equals("综合排序")) {
tvSort.text = "排序" tvSort.text = "排序"
...@@ -1189,8 +1267,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1189,8 +1267,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//显示地区弹窗 //显示地区弹窗
private fun showAreaPopupWindow() { private fun showAreaPopupWindow() {
if (headData?.region != null) { if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow(this, headData?.region val regionPopupWindow = AreaPopupWindow(
?: ArrayList(), allFilter.region, allFilter.sub) this, headData?.region
?: ArrayList(), allFilter.region, allFilter.sub
)
regionPopupWindow.showAsDropDown(viewSep2) regionPopupWindow.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE viewDim.visibility = View.VISIBLE
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN) updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
...@@ -1202,69 +1282,73 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1202,69 +1282,73 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL) updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
} }
} }
regionPopupWindow.onRegionSelectedListener = object : AreaPopupWindow.OnRegionSelectedListener { regionPopupWindow.onRegionSelectedListener =
override fun onRegionSelected(region: RegionItem, sub: SubItem) { object : AreaPopupWindow.OnRegionSelectedListener {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN) override fun onRegionSelected(region: RegionItem, sub: SubItem) {
allFilter.region = region updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
allFilter.sub = sub allFilter.region = region
if (region.key == null && sub.key == null) { allFilter.sub = sub
if (region.key == null && sub.key == null) {
// LogUtil.d("onRegionSelected: " + region.value) // LogUtil.d("onRegionSelected: " + region.value)
// props1.put("filtrate_second", region.value) // props1.put("filtrate_second", region.value)
// BuryPointUtils.buryPoint("Filtrate", props1) // BuryPointUtils.buryPoint("Filtrate", props1)
tvArea.text = "地区" tvArea.text = "地区"
} else if (region.key != null && sub.key == null) { } else if (region.key != null && sub.key == null) {
// LogUtil.d("onRegionSelected: " + region.value) // LogUtil.d("onRegionSelected: " + region.value)
// props1.put("filtrate_second", region.value) // props1.put("filtrate_second", region.value)
// BuryPointUtils.buryPoint("Filtrate", props1) // BuryPointUtils.buryPoint("Filtrate", props1)
if (region.value?.length ?: 0 > 4) { if (region.value?.length ?: 0 > 4) {
tvArea.text = region.value?.substring(0, 3) + "..." tvArea.text = region.value?.substring(0, 3) + "..."
} else {
tvArea.text = region.value
}
} else { } else {
tvArea.text = region.value
}
} else {
// LogUtil.d("onRegionSelected: " + sub.value) // LogUtil.d("onRegionSelected: " + sub.value)
// props1.put("filtrate_second", sub.value) // props1.put("filtrate_second", sub.value)
// BuryPointUtils.buryPoint("Filtrate", props1) // BuryPointUtils.buryPoint("Filtrate", props1)
if (sub.value?.length ?: 0 > 4) { if (sub.value?.length ?: 0 > 4) {
tvArea.text = sub.value?.substring(0, 3) + "..." tvArea.text = sub.value?.substring(0, 3) + "..."
} else { } else {
tvArea.text = sub.value tvArea.text = sub.value
}
} }
} ActionCountUtils.count(
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_AREA_CLICK, region.value + "|" + sub.value) ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_AREA_CLICK,
region.value + "|" + sub.value
//更新热门搜索显示状态 )
if (headData!!.highlighter.size > 0) {
for ((index, hot) in headData!!.highlighter!!.withIndex()) { //更新热门搜索显示状态
if (hot.type == "2" || hot.type == "8") { if (headData!!.highlighter.size > 0) {
var textview = lin_filter2.getChildAt(index) as TextView for ((index, hot) in headData!!.highlighter!!.withIndex()) {
//有选择城市 if (hot.type == "2" || hot.type == "8") {
if (!TextUtils.isEmpty(sub.key)) { var textview = lin_filter2.getChildAt(index) as TextView
if (TextUtils.equals(sub.key, hot.id)) { //有选择城市
textview.isSelected = true if (!TextUtils.isEmpty(sub.key)) {
textview.paint.isFakeBoldText = true if (TextUtils.equals(sub.key, hot.id)) {
hasSelectedArea = true textview.isSelected = true
} else { textview.paint.isFakeBoldText = true
textview.isSelected = false hasSelectedArea = true
textview.paint.isFakeBoldText = false } else {
} textview.isSelected = false
} else { textview.paint.isFakeBoldText = false
if (TextUtils.equals(region.key, hot.id)) { }
textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
} else { } else {
textview.isSelected = false if (TextUtils.equals(region.key, hot.id)) {
textview.paint.isFakeBoldText = false textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
} else {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
} }
} }
} }
} }
regionPopupWindow.dismiss()
refresh()
} }
regionPopupWindow.dismiss()
refresh()
} }
}
} else { } else {
ToastUtil.toastShort("数据初始化失败,请重试") ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead() getPresenter().fetchListHead()
...@@ -1304,7 +1388,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1304,7 +1388,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
* 新增逻辑:当主题选择后,需要判断热门筛选中是否也有该主题,如果有,也需要同步更新选中状态 * 新增逻辑:当主题选择后,需要判断热门筛选中是否也有该主题,如果有,也需要同步更新选中状态
*/ */
override fun onCategoriesSelected(categories: ArrayList<CateItem>) { override fun onCategoriesSelected(categories: ArrayList<CateItem>) {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK, categories.map { it.cateName }.joinToString("|")) ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK,
categories.map { it.cateName }.joinToString("|")
)
if (categories.size == 1 && "全部" != categories[0].cateName) { if (categories.size == 1 && "全部" != categories[0].cateName) {
//显示选中标题 //显示选中标题
tvSubject.text = categories[0].cateName tvSubject.text = categories[0].cateName
...@@ -1323,7 +1410,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1323,7 +1410,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textview.paint.isFakeBoldText = false textview.paint.isFakeBoldText = false
} }
for (bean in categories) { for (bean in categories) {
if (TextUtils.equals(bean.cateName, headData!!.highlighter[index].value)) { if (TextUtils.equals(
bean.cateName,
headData!!.highlighter[index].value
)
) {
this@ExpertSearchActivity.runOnUiThread { this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true textview.isSelected = true
textview.paint.isFakeBoldText = true textview.paint.isFakeBoldText = true
...@@ -1380,7 +1471,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1380,7 +1471,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
// return // return
// } // }
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK, keyWord ?: "") ActionCountUtils.count(
ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,
keyWord ?: ""
)
isDoSearch = true isDoSearch = true
resetFilter() resetFilter()
refresh() refresh()
...@@ -1416,17 +1510,32 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1416,17 +1510,32 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
FILTER_STATUS_NORMAL -> { FILTER_STATUS_NORMAL -> {
tv.typeface = Typeface.defaultFromStyle(Typeface.NORMAL) tv.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault)) tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_un, 0) tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.platform_ic_arrow_drop_down_grey_500_18dp,
0
)
} }
FILTER_STATUS_FILTERED -> { FILTER_STATUS_FILTERED -> {
tv.typeface = Typeface.DEFAULT_BOLD tv.typeface = Typeface.DEFAULT_BOLD
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_main_theme)) tv.setTextColor(ContextCompat.getColor(this, R.color.consultant_main_theme))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_un, 0) tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.platform_ic_arrow_drop_down_grey_500_18dp,
0
)
} }
FILTER_STATUS_OPEN -> { FILTER_STATUS_OPEN -> {
tv.typeface = Typeface.DEFAULT_BOLD tv.typeface = Typeface.DEFAULT_BOLD
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault)) tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_en, 0) tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.consultant_ic_arrow_drop_down,
0
)
} }
} }
} }
...@@ -1444,11 +1553,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1444,11 +1553,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
*/ */
fun bury(keyworks: String, isResult: Boolean, isRecommend: Boolean, location: String) { fun bury(keyworks: String, isResult: Boolean, isRecommend: Boolean, location: String) {
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("keyWord", keyworks) .put("keyWord", keyworks)
.put("hasResult", isResult) .put("hasResult", isResult)
.put("isRecommend", isRecommend) .put("isRecommend", isRecommend)
.put("location", location) .put("location", location)
.burryPoint("search") .burryPoint("search")
} }
override fun onResume() { override fun onResume() {
......
...@@ -361,9 +361,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -361,9 +361,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
v_loading.visibility = View.VISIBLE v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null) v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
if (fromPageType != -1) { doctorAdapter.setEntrance(0)
doctorAdapter.setEntrance(fromPages[fromPageType], 0)
}
} }
/** /**
......
...@@ -59,11 +59,9 @@ class ExpertSearchAdapter( ...@@ -59,11 +59,9 @@ class ExpertSearchAdapter(
var hasMore = true var hasMore = true
var entranceName: String? = null
var pageIndex: Int = 0 var pageIndex: Int = 0
fun setEntrance(entranceName: String, pageIndex: Int) { fun setEntrance( pageIndex: Int) {
this.entranceName = entranceName
this.pageIndex = pageIndex this.pageIndex = pageIndex
} }
...@@ -466,14 +464,6 @@ class ExpertSearchAdapter( ...@@ -466,14 +464,6 @@ class ExpertSearchAdapter(
} else { } else {
ToastHelper.show("请联系客服,专家参数错误!") ToastHelper.show("请联系客服,专家参数错误!")
} }
if (!TextUtils.isEmpty(entranceName)) {
LogUtil.d("entrance name: $entranceName")
BuryPointUtils.getInstance().createMap()
.put("expert_entrance", entranceName ?: "")
.put("expert_ID", doctor.doctorId ?: 0)
.put("expert_name", doctor.name ?: "")
.burryPoint("Chat_click")
}
} }
} }
} }
......
...@@ -12,10 +12,13 @@ import com.netease.nimlib.sdk.msg.MsgServiceObserve ...@@ -12,10 +12,13 @@ import com.netease.nimlib.sdk.msg.MsgServiceObserve
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
import com.netease.nimlib.sdk.msg.model.CustomNotification
import com.netease.nimlib.sdk.msg.model.IMMessage 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.utils.LogUtil
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.event.AccountChangeEvent import com.yidianling.im.api.event.AccountChangeEvent
import com.yidianling.im.api.event.MsgPushEvent import com.yidianling.im.api.event.MsgPushEvent
import com.yidianling.im.event.TeamRemoveEvent import com.yidianling.im.event.TeamRemoveEvent
...@@ -38,6 +41,10 @@ import java.util.concurrent.Executors ...@@ -38,6 +41,10 @@ import java.util.concurrent.Executors
* Des: * Des:
*/ */
class ImObserversHelper { class ImObserversHelper {
var imCustomNotificationCallBack: IMRegisterObserverCustomNotificationCallBack? = null
set(value) {
field = value
}
companion object { companion object {
fun getInstance(): ImObserversHelper { fun getInstance(): ImObserversHelper {
...@@ -45,23 +52,22 @@ class ImObserversHelper { ...@@ -45,23 +52,22 @@ class ImObserversHelper {
} }
} }
private object Holder { private object Holder {
val INSTANCE = ImObserversHelper() val INSTANCE = ImObserversHelper()
} }
fun registerObserver(register: Boolean) { fun registerObserver(register: Boolean) {
//注册`在线状态变化`观察者 //注册`在线状态变化`观察者
NIMClient.getService(AuthServiceObserver::class.java) NIMClient.getService(AuthServiceObserver::class.java).observeOnlineStatus(userStatusObserver, register)
.observeOnlineStatus(userStatusObserver, register)
//注册`消息撤回`观察者 //注册`消息撤回`观察者
NIMClient.getService(MsgServiceObserve::class.java) NIMClient.getService(MsgServiceObserve::class.java).observeRevokeMessage(messageRevokeObserver, register)
.observeRevokeMessage(messageRevokeObserver, register)
//注册`消息接收`观察者 //注册`消息接收`观察者
NIMClient.getService(MsgServiceObserve::class.java) NIMClient.getService(MsgServiceObserve::class.java).observeReceiveMessage(incomingMessageObserver, register)
.observeReceiveMessage(incomingMessageObserver, register)
//注册`移出群`观察者通知 //注册`移出群`观察者通知
NIMClient.getService(TeamServiceObserver::class.java) NIMClient.getService(TeamServiceObserver::class.java).observeTeamRemove(teamObserver, register)
.observeTeamRemove(teamObserver, register) NIMClient.getService(MsgServiceObserve::class.java).observeCustomNotification(receiveSystemMessageObserver, register)
//注册`未读消息改变数量`观察者 //注册`未读消息改变数量`观察者
registerMsgUnreadInfoObserver(register) registerMsgUnreadInfoObserver(register)
if (register) { if (register) {
...@@ -76,15 +82,13 @@ class ImObserversHelper { ...@@ -76,15 +82,13 @@ class ImObserversHelper {
if (register) { if (register) {
ReminderManager.getInstance().registerUnreadNumChangedCallback(unreadNumChangedCallback) ReminderManager.getInstance().registerUnreadNumChangedCallback(unreadNumChangedCallback)
} else { } else {
ReminderManager.getInstance() ReminderManager.getInstance().unregisterUnreadNumChangedCallback(unreadNumChangedCallback)
.unregisterUnreadNumChangedCallback(unreadNumChangedCallback)
} }
} }
private var unreadNumChangedCallback: ReminderManager.UnreadNumChangedCallback = private var unreadNumChangedCallback: ReminderManager.UnreadNumChangedCallback = ReminderManager.UnreadNumChangedCallback() {
ReminderManager.UnreadNumChangedCallback() { MsgReceiveHelper.onMessageReceived()
MsgReceiveHelper.onMessageReceived() }
}
private var userStatusObserver: Observer<StatusCode> = Observer { code -> private var userStatusObserver: Observer<StatusCode> = Observer { code ->
if (code.wontAutoLoginForever()) { if (code.wontAutoLoginForever()) {
...@@ -95,9 +99,7 @@ class ImObserversHelper { ...@@ -95,9 +99,7 @@ class ImObserversHelper {
private var messageRevokeObserver: Observer<RevokeMsgNotification> = NimMessageRevokeObserver() private var messageRevokeObserver: Observer<RevokeMsgNotification> = NimMessageRevokeObserver()
private var teamObserver: Observer<Team> = Observer<Team> { t -> private var teamObserver: Observer<Team> = Observer<Team> { t ->
EventBus.getDefault().post( EventBus.getDefault().post(TeamRemoveEvent(1, t.id))
TeamRemoveEvent(1, t.id)
)
} }
private var incomingMessageObserver = Observer<List<IMMessage>> { messages -> private var incomingMessageObserver = Observer<List<IMMessage>> { messages ->
...@@ -150,7 +152,7 @@ class ImObserversHelper { ...@@ -150,7 +152,7 @@ class ImObserversHelper {
event.headUrl = userInfo.avatar event.headUrl = userInfo.avatar
} }
// LogUtil.e("发送事件:$event") // LogUtil.e("发送事件:$event")
EventBus.getDefault().post(event) EventBus.getDefault().post(event)
} }
} }
...@@ -170,12 +172,13 @@ class ImObserversHelper { ...@@ -170,12 +172,13 @@ class ImObserversHelper {
false false
} }
private var receiveSystemMessageObserver: Observer<CustomNotification> = Observer<CustomNotification> {
LogUtil.e(it.content)
imCustomNotificationCallBack?.onObserverCustomNotification(it.fromAccount, it.sessionId, it.content)
}
private var msgRevokeFilter = MsgRevokeFilter { message -> private var msgRevokeFilter = MsgRevokeFilter { message ->
if (message.attachment != null if (message.attachment != null && message.attachment is AVChatAttachment && message.attachment is CustomAttachRedPacket) {
&& message.attachment is AVChatAttachment
&& message.attachment is CustomAttachRedPacket
) {
// 视频通话消息和白板消息 不允许撤回 // 视频通话消息和白板消息 不允许撤回
return@MsgRevokeFilter true return@MsgRevokeFilter true
} else if (IMCache.getAccount() != null && IMCache.getAccount() == message.sessionId) { } else if (IMCache.getAccount() != null && IMCache.getAccount() == message.sessionId) {
...@@ -188,39 +191,36 @@ class ImObserversHelper { ...@@ -188,39 +191,36 @@ class ImObserversHelper {
//如果是收款提醒消息 则更新历史收款消息的状态 //如果是收款提醒消息 则更新历史收款消息的状态
fun flushReceivedMoney(m: IMMessage) { fun flushReceivedMoney(m: IMMessage) {
//跟新收款消息 //跟新收款消息
NIMClient.getService(MsgService::class.java) NIMClient.getService(MsgService::class.java).queryMessageListByType(MsgTypeEnum.custom, m, 100).setCallback(object : RequestCallback<List<IMMessage>> {
.queryMessageListByType(MsgTypeEnum.custom, m, 100) override fun onSuccess(imMessages: List<IMMessage>) {
.setCallback(object : RequestCallback<List<IMMessage>> { for (im in imMessages) {
override fun onSuccess(imMessages: List<IMMessage>) { if (im.attachment is CustomAttachReceivedMoney) {
for (im in imMessages) { val money = im.attachment as CustomAttachReceivedMoney
if (im.attachment is CustomAttachReceivedMoney) {
val money = im.attachment as CustomAttachReceivedMoney if (money.orPay == 1) return
val status = m.attachment as CustomAttachmentReceivedSuccess
if (money.orPay == 1) return if (money.orderId == null || status.orderid == null) return
val status = m.attachment as CustomAttachmentReceivedSuccess if (money.orderId == status.orderid) {
if (money.orderId == null || status.orderid == null) return
if (money.orderId == status.orderid) { money.orPay = 1 //设置为已支付
im.attachment = money
money.orPay = 1//设置为已支付 //更新此消息到sdk
im.attachment = money NIMClient.getService(MsgService::class.java).updateIMMessageStatus(im)
//更新此消息到sdk //更新私聊界面聊天信息
NIMClient.getService(MsgService::class.java) MessageListPanelHelper.getInstance().notifyModifyMessage(im)
.updateIMMessageStatus(im) return
//更新私聊界面聊天信息
MessageListPanelHelper.getInstance().notifyModifyMessage(im)
return
}
} }
} }
} }
}
override fun onFailed(i: Int) { override fun onFailed(i: Int) {
// Log.e("hzs","跟新收款消息失败"); // Log.e("hzs","跟新收款消息失败");
} }
override fun onException(throwable: Throwable) { override fun onException(throwable: Throwable) {
// Log.e("hzs","跟新收款消息异常:"+throwable); // Log.e("hzs","跟新收款消息异常:"+throwable);
} }
}) })
} }
} }
...@@ -14,6 +14,8 @@ import com.netease.nimlib.sdk.auth.LoginInfo ...@@ -14,6 +14,8 @@ import com.netease.nimlib.sdk.auth.LoginInfo
import com.netease.nimlib.sdk.msg.MessageBuilder import com.netease.nimlib.sdk.msg.MessageBuilder
import com.netease.nimlib.sdk.msg.MsgService import com.netease.nimlib.sdk.msg.MsgService
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
import com.netease.nimlib.sdk.msg.model.CustomNotification
import com.netease.nimlib.sdk.msg.model.CustomNotificationConfig
import com.ydl.ydlcommon.router.YdlCommonOut import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.utils.StringUtils import com.ydl.ydlcommon.utils.StringUtils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
...@@ -22,13 +24,16 @@ import com.yidianling.common.tools.ToastUtil ...@@ -22,13 +24,16 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R import com.yidianling.im.R
import com.yidianling.im.api.bean.IMInitConfigBean import com.yidianling.im.api.bean.IMInitConfigBean
import com.yidianling.im.api.bean.IMLoginInfo import com.yidianling.im.api.bean.IMLoginInfo
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.bean.IMRequestCallback import com.yidianling.im.api.bean.IMRequestCallback
import com.yidianling.im.api.listener.ApiStringResponseCallback import com.yidianling.im.api.listener.ApiStringResponseCallback
import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import com.yidianling.im.api.service.IImService import com.yidianling.im.api.service.IImService
import com.yidianling.im.bridge.P2PCustomActionHandlerImpl import com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import com.yidianling.im.config.NimApplication import com.yidianling.im.config.NimApplication
import com.yidianling.im.helper.IMChatUtil import com.yidianling.im.helper.IMChatUtil
import com.yidianling.im.helper.LogoutHelper import com.yidianling.im.helper.LogoutHelper
import com.yidianling.im.helper.ImObserversHelper
import com.yidianling.im.helper.MsgReceiveHelper import com.yidianling.im.helper.MsgReceiveHelper
import com.yidianling.im.http.ImRetrofitApi import com.yidianling.im.http.ImRetrofitApi
import com.yidianling.im.preference.IMCache import com.yidianling.im.preference.IMCache
...@@ -68,9 +73,7 @@ class IMServiceImpl : IImService { ...@@ -68,9 +73,7 @@ class IMServiceImpl : IImService {
context.startActivity(ImIn.loginWayIntent(context)) context.startActivity(ImIn.loginWayIntent(context))
return return
} }
SessionHelper.startP2PSession(context, -1, "14", null, SessionHelper.startP2PSession(context, -1, "14", null, P2PCustomActionHandlerImpl("14", "客服小壹", "https://static.ydlcdn.com/mobile/images/avatar_girl_app.png"))
P2PCustomActionHandlerImpl("14",
"客服小壹", "https://static.ydlcdn.com/mobile/images/avatar_girl_app.png"))
} }
override fun imLogin(info: IMLoginInfo) { override fun imLogin(info: IMLoginInfo) {
...@@ -124,43 +127,39 @@ class IMServiceImpl : IImService { ...@@ -124,43 +127,39 @@ class IMServiceImpl : IImService {
override fun createTextMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>) { override fun createTextMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>) {
val message = MessageBuilder.createTextMessage(sessionId, SessionTypeEnum.P2P, content) val message = MessageBuilder.createTextMessage(sessionId, SessionTypeEnum.P2P, content)
NIMClient.getService(MsgService::class.java) NIMClient.getService(MsgService::class.java).sendMessage(message, false).setCallback(object : RequestCallback<Void> {
.sendMessage(message, false) override fun onSuccess(param: Void?) {
.setCallback(object : RequestCallback<Void> { callback.onSuccess(param)
override fun onSuccess(param: Void?) { MessageListPanelHelper.getInstance().notifyAddMessage(message)
callback.onSuccess(param) }
MessageListPanelHelper.getInstance().notifyAddMessage(message)
}
override fun onException(exception: Throwable?) { override fun onException(exception: Throwable?) {
callback.onException(exception) callback.onException(exception)
} }
override fun onFailed(code: Int) { override fun onFailed(code: Int) {
callback.onFailed(code) callback.onFailed(code)
} }
}) })
} }
override fun sendSubscriptionTimeMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>) { override fun sendSubscriptionTimeMessage(sessionId: String?, content: String, callback: IMRequestCallback<Void>) {
val customTime = CustomAttachSubScriptTime(content) val customTime = CustomAttachSubScriptTime(content)
val message = MessageBuilder.createCustomMessage(sessionId, SessionTypeEnum.P2P, content, customTime) val message = MessageBuilder.createCustomMessage(sessionId, SessionTypeEnum.P2P, content, customTime)
NIMClient.getService(MsgService::class.java) NIMClient.getService(MsgService::class.java).sendMessage(message, false).setCallback(object : RequestCallback<Void> {
.sendMessage(message, false) override fun onSuccess(param: Void?) {
.setCallback(object : RequestCallback<Void> { callback.onSuccess(param)
override fun onSuccess(param: Void?) { MessageListPanelHelper.getInstance().notifyAddMessage(message)
callback.onSuccess(param) }
MessageListPanelHelper.getInstance().notifyAddMessage(message)
}
override fun onException(exception: Throwable?) { override fun onException(exception: Throwable?) {
callback.onException(exception) callback.onException(exception)
} }
override fun onFailed(code: Int) { override fun onFailed(code: Int) {
callback.onFailed(code) callback.onFailed(code)
} }
}) })
} }
...@@ -172,20 +171,13 @@ class IMServiceImpl : IImService { ...@@ -172,20 +171,13 @@ class IMServiceImpl : IImService {
option.crop = false option.crop = false
option.cropOutputImageWidth = 720 option.cropOutputImageWidth = 720
option.cropOutputImageHeight = 720 option.cropOutputImageHeight = 720
// option.outputPath = StorageUtil.getWritePath(StringUtils.get32UUID() + ".jpg", StorageType.TYPE_TEMP) // option.outputPath = StorageUtil.getWritePath(StringUtils.get32UUID() + ".jpg", StorageType.TYPE_TEMP)
option.outputPath = YdlCommonOut.getApp().externalCacheDir.absolutePath + "/" + StringUtils.get32UUID() + ".jpg" option.outputPath = YdlCommonOut.getApp().externalCacheDir.absolutePath + "/" + StringUtils.get32UUID() + ".jpg"
PickImageHelper.pickImage(activity, requestCode, option) PickImageHelper.pickImage(activity, requestCode, option)
} }
override fun sendTestResultMessage(uid: String, content: String, title: String?, head: String?, url: String?, id: Int, share_url: String?, callback: IMRequestCallback<Void>) { override fun sendTestResultMessage(uid: String, content: String, title: String?, head: String?, url: String?, id: Int, share_url: String?, callback: IMRequestCallback<Void>) {
val customAttachmentTest = CustomAttachmentTest( val customAttachmentTest = CustomAttachmentTest(CustomAttachmentTest.FLAG_RESULT, title, head, url, id, share_url)
CustomAttachmentTest.FLAG_RESULT,
title,
head,
url,
id,
share_url
)
val message = MessageBuilder.createCustomMessage(uid, SessionTypeEnum.P2P, "测试结果", customAttachmentTest) val message = MessageBuilder.createCustomMessage(uid, SessionTypeEnum.P2P, "测试结果", customAttachmentTest)
NIMClient.getService(MsgService::class.java).sendMessage(message, false).setCallback(object : RequestCallback<Void> { NIMClient.getService(MsgService::class.java).sendMessage(message, false).setCallback(object : RequestCallback<Void> {
...@@ -226,6 +218,38 @@ class IMServiceImpl : IImService { ...@@ -226,6 +218,38 @@ class IMServiceImpl : IImService {
return MsgReceiveHelper.getAllUnNum() return MsgReceiveHelper.getAllUnNum()
} }
/**
* 发送自定义通知: 不推送、不计入未读消息
*/
override fun sendCustomNotification(toUid: String, content: String, callback: IMSendCustomNotificationResultCallBack) {
val config = CustomNotificationConfig()
config.enablePush = false
config.enablePushNick = false
config.enableUnreadCount = false
val customNotification = CustomNotification()
customNotification.sessionType = SessionTypeEnum.P2P
customNotification.sessionId = toUid
customNotification.config = config
customNotification.content = content
NIMClient.getService(MsgService::class.java).sendCustomNotification(customNotification).setCallback(object : RequestCallback<Void?> {
override fun onSuccess(param: Void?) {
callback.onSuccess()
}
override fun onFailed(code: Int) {
callback.onFailed(code)
}
override fun onException(exception: Throwable) {
callback.onException(exception)
}
})
}
override fun registerObserveCustomNotification(callback: IMRegisterObserverCustomNotificationCallBack) {
ImObserversHelper.getInstance().imCustomNotificationCallBack=callback
}
override fun getMultiMessageFragment(): Fragment { override fun getMultiMessageFragment(): Fragment {
return NewMultiMessageFragment() return NewMultiMessageFragment()
} }
......
package com.yidianling.im.api.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/21
*/
interface IMRegisterObserverCustomNotificationCallBack {
fun onObserverCustomNotification(fromUid:String,toUid:String,content: String)
}
\ No newline at end of file
package com.yidianling.im.api.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/4/21
*/
interface IMSendCustomNotificationResultCallBack {
fun onSuccess()
fun onFailed(code: Int)
fun onException(throwable: Throwable)
}
\ No newline at end of file
...@@ -7,7 +7,9 @@ import android.support.v4.app.Fragment ...@@ -7,7 +7,9 @@ import android.support.v4.app.Fragment
import com.alibaba.android.arouter.facade.template.IProvider import com.alibaba.android.arouter.facade.template.IProvider
import com.yidianling.im.api.bean.IMInitConfigBean import com.yidianling.im.api.bean.IMInitConfigBean
import com.yidianling.im.api.bean.IMLoginInfo import com.yidianling.im.api.bean.IMLoginInfo
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.bean.IMRequestCallback import com.yidianling.im.api.bean.IMRequestCallback
import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import com.yidianling.im.api.listener.ApiStringResponseCallback import com.yidianling.im.api.listener.ApiStringResponseCallback
/** /**
...@@ -29,7 +31,7 @@ interface IImService : IProvider { ...@@ -29,7 +31,7 @@ interface IImService : IProvider {
fun setChattingAccountNone() fun setChattingAccountNone()
fun isHasUnread():Boolean fun isHasUnread(): Boolean
fun login(info: IMLoginInfo, callback: IMRequestCallback<IMLoginInfo>?) fun login(info: IMLoginInfo, callback: IMRequestCallback<IMLoginInfo>?)
...@@ -54,7 +56,7 @@ interface IImService : IProvider { ...@@ -54,7 +56,7 @@ interface IImService : IProvider {
fun sendTestResultMessage(uid: String, content: String, title: String?, head: String?, url: String?, id: Int, share_url: String?, callback: IMRequestCallback<Void>) fun sendTestResultMessage(uid: String, content: String, title: String?, head: String?, url: String?, id: Int, share_url: String?, callback: IMRequestCallback<Void>)
fun startChat(context : Activity ,toUid : String ,flag : Int , canTalk : Int) fun startChat(context: Activity, toUid: String, flag: Int, canTalk: Int)
fun startChat(context : Activity ,toUid : String ,flag : Int , canTalk : Int, isFramQingsu: Int, isFromMessageList: Boolean) fun startChat(context : Activity ,toUid : String ,flag : Int , canTalk : Int, isFramQingsu: Int, isFromMessageList: Boolean)
...@@ -69,6 +71,17 @@ interface IImService : IProvider { ...@@ -69,6 +71,17 @@ interface IImService : IProvider {
*/ */
fun getAllUnReadNum(): Int fun getAllUnReadNum(): Int
/**
* 发送自定义通知
*/
fun sendCustomNotification(toUid: String, content: String, callback: IMSendCustomNotificationResultCallBack)
/**
* 注册自定通知接收器
*/
fun registerObserveCustomNotification(callback: IMRegisterObserverCustomNotificationCallBack)
fun getMultiMessageFragment(): Fragment fun getMultiMessageFragment(): Fragment
// 跳转下一个未读数 // 跳转下一个未读数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment