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