Commit bbda772e by 刘鹏

feat:倾诉dial接口拆分

parent 8cefa85d
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../maven_push_api.gradle"
version = '1.0.0'
version = '1.0.1'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
......
......@@ -20,6 +20,9 @@ interface IConfideService : IProvider {
fun connectionJava(id: Int, type: Int, activity: Activity, tellData: String?, callType:String?)
//直接拨打倾诉或者axb电话
fun confideDial(id: Int, data: String, activity: Activity)
fun ydlAvManagerLogin(uid: String?)
fun startCondifeHomePage(context: Context, isSplash: Boolean)
......
package com.ydl.component.service.web
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.hjq.permissions.Permission
import com.hjq.permissions.XXPermissions
import com.tencent.smtt.sdk.WebView
import com.ydl.audioim.YDLavManager
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.ui.Loading
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.UserHelper
import de.greenrobot.event.EventBus
......@@ -68,6 +72,29 @@ class JsMethod(private val webView: WebView?) {
webView?.loadUrl("javascript:$callback(${if (grantedPermission) 1 else 0})")
return true
}
"confide_dial" -> {
//倾诉链接 java接口,支持axb和声网
val id = param.getAsJsonPrimitive("id").asInt
val data = param.getAsJsonPrimitive("data").asString
val topActivity = BaseActivityMgr.INST.topActivity
if (!YDLavManager.isOnlineRtm) {
//异常退出或者账号被顶掉,重新登录并拨打
YDLavManager.instances.login(UserHelper.getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
(ARouter.getInstance().build("/confide/ConfideService")
.navigation() as IConfideService).confideDial(id, data, topActivity)
} else {
ToastUtil.toastShort("请重新拨打")
}
}
} else {
(ARouter.getInstance().build("/confide/ConfideService")
.navigation() as IConfideService).confideDial(id, data, topActivity)
}
return true
}
else -> {
return false
}
......
......@@ -236,7 +236,7 @@ ext {
"ydl-m-home-api" : "com.ydl:m-home-api:${ydlPublishVersion["m-home-api"]}",
"ydl-m-consultant-api" : "com.ydl:m-consultant-api:1.0.0",
"ydl-m-dynamic-api" : "com.ydl:m-dynamic-api:1.0.0",
"ydl-m-confide-api" : "com.ydl:m-confide-api:1.0.0",
"ydl-m-confide-api" : "com.ydl:m-confide-api:1.0.1",
"ydl-m-course-api" : "com.ydl:m-course-api:1.0.0",
]
......
......@@ -35,6 +35,11 @@ interface ConfideHomeApi {
@GET("auth/listen/dial")
fun connectJava(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>>
//拨打前 下单支付接口
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("auth/listen/submitOrderAndPay")
fun submitOrderAndPay(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>>
// 1=在线 3-通话中 2-离线
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
@GET("auth/listen/dialchangestatus")
......
......@@ -70,4 +70,11 @@ class ConfideHomeHttpImpl private constructor() : IConfideHomeHttp {
YDLHttpUtils.obtainApi(ConfideHomeApi::class.java).connectJava(it)
}
}
override fun submitOrderAndPay(connectParam: ConnectParamJava): Observable<BaseAPIResponse<ConfideConnectResponse>> {
return RxUtils.mapObservable(connectParam)
.flatMap { it ->
YDLHttpUtils.obtainApi(ConfideHomeApi::class.java).submitOrderAndPay(it)
}
}
}
\ No newline at end of file
......@@ -24,6 +24,13 @@ interface IConfideHomeHttp {
*/
fun recommendList(param: ConfideRecommendParam): Observable<BaseAPIResponse<ConfideHomeDataBean>>
//倾诉链接,java接口,支持axb和声网
/**
* 倾诉链接,java接口,支持axb和声网
*/
fun connectionJava(connectParam: ConnectParamJava): Observable<BaseAPIResponse<ConfideConnectResponse>>
/**
* 拨打前 下单支付接口
* */
fun submitOrderAndPay(connectParam: ConnectParamJava): Observable<BaseAPIResponse<ConfideConnectResponse>>
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.ConfideBottomSheetDialogFragment
import com.ydl.confide.home.ConfideHomeActivity
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.webview.TellData
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
......@@ -58,6 +59,20 @@ class ConfdieServiceImpl : IConfideService {
ConfideWebServiceImpl().connectionJava(id, type, activity, myTellData, callType)
}
/**
* 直接拨打
* */
override fun confideDial(id: Int, data: String, activity: Activity) {
val gson = Gson()
val bean = gson.fromJson(data, ConfideConnectResponse::class.java)
if (bean?.dialDetail?.callConnectType == 3) {
ConfideWebServiceImpl().agora(id, activity, bean)
} else {
ConfideWebServiceImpl().axb(activity, bean?.dialDetail?.phoneNu)
}
}
override fun ydlAvManagerLogin(uid: String?) {
YDLavManager.instances.login(uid)
}
......
......@@ -7,6 +7,8 @@ import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter
import com.hjq.permissions.OnPermissionCallback
import com.hjq.permissions.XXPermissions
import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.bean.ExpertInfoBean
......@@ -20,6 +22,8 @@ import com.ydl.webview.NewH5Activity
import com.ydl.webview.TellData
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.ui.Loading
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.ToastUtil
......@@ -97,13 +101,11 @@ class ConfideWebServiceImpl {
.show()
}
private fun agora(
fun agora(
id: Int,
type: Int,
activity: Context,
callType: String?,
tellData: TellData?,
data: ConfideConnectResponse?){
data: ConfideConnectResponse?
) {
val expertInfo = data?.dialDetail?.agoraExpertInfo ?: return
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001")
......@@ -115,14 +117,16 @@ class ConfideWebServiceImpl {
expertInfo,
data.callId ?: "0",
data.listenOrderId ?: 0L,
tellData,
data.isShowAxb,
data.dialDetail?.dialStatus.toString()
)
}
private fun axb(activity: Activity,phone:String?){
if(phone.isNullOrEmpty())return
/**
* axb 通话
* */
fun axb(activity: Activity, phone: String?) {
if (phone.isNullOrEmpty()) return
val dialog = AxbConfirmDialog(
activity,
1,
......@@ -149,7 +153,7 @@ class ConfideWebServiceImpl {
callType: String?
) {
ConfideHomeDataManager.getHttp()
.connectionJava(ConnectParamJava("" + id, "" + type, callType))
.submitOrderAndPay(ConnectParamJava("" + id, "" + type, callType))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
......@@ -157,9 +161,11 @@ class ConfideWebServiceImpl {
when (it.data?.dialDetail?.dialStatus) {
0 -> {//连接成功
if (it.data?.dialDetail?.callConnectType == 3) {
agora(id, type, activity, callType, tellData, it.data)
//checkpermission
checkPermission(id, type, activity,callType)
} else {
axb(activity, it.data?.dialDetail?.phoneNu)
//axb
listenDial(id, type, activity,"1")
}
}
100007 -> {
......@@ -179,6 +185,71 @@ class ConfideWebServiceImpl {
ToastHelper.show(it.message ?: "连接失败")
})
}
/**
* 检查权限
* */
private fun checkPermission(id: Int, type: Int, activity: Activity, callType: String?) {
try {
//申请音频权限
XXPermissions.with(activity) // 申请单个权限
.permission(com.hjq.permissions.Permission.RECORD_AUDIO)
.request(object : OnPermissionCallback {
override fun onGranted(p0: MutableList<String>?, p1: Boolean) {
listenDial(id, type, activity,callType)
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "请求音频权限通过")
}
override fun onDenied(permissions: MutableList<String>?, never: Boolean) {
listenDial(id, type, activity,"1");
// 拒绝权限操作发送给服务端
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "拒绝请求音频权限")
}
})
} catch (e: Exception) {
listenDial(id, type, activity,"1");
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "请求音频权限异常${e.message}")
}
}
@SuppressLint("CheckResult")
fun listenDial(
id: Int,
type: Int,
activity: Activity,
callType: String?
) {
ConfideHomeDataManager.getHttp()
.connectionJava(ConnectParamJava("" + id, "" + type, callType))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if ("200" == it.code) {
when (it.data?.dialDetail?.dialStatus) {
0 -> {//连接成功
if (it.data?.dialDetail?.callConnectType == 3) {
agora(id, activity, it.data)
} else {
axb(activity, it.data?.dialDetail?.phoneNu)
}
}
else -> {
ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败")
}
}
} else {
ToastHelper.show(it.msg)
}
}, {
ToastHelper.show(it.message ?: "连接失败")
})
}
fun connectionJava(
id: Int,
......@@ -189,7 +260,7 @@ class ConfideWebServiceImpl {
): Disposable {
Loading.show(activity)
return ConfideHomeDataManager.getHttp()
.connectionJava(ConnectParamJava("" + id, "" + type, callType))
.submitOrderAndPay(ConnectParamJava("" + id, "" + type, callType))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
......@@ -198,7 +269,11 @@ class ConfideWebServiceImpl {
when (it.data?.dialDetail?.dialStatus) {
0 -> {//连接成功
if (it.data?.dialDetail?.callConnectType == 3) {
agora(id, type, activity, callType, null, it.data)
//检查音频权限
checkPermission(id, type, activity as Activity,callType)
}else{
//axb
listenDial(id, type, activity as Activity,"1");
}
}
100007 -> {
......@@ -228,7 +303,6 @@ class ConfideWebServiceImpl {
expertInfo: ExpertInfoBean,
call_id: String,
relation_id: Long,
tellData: TellData?,
isShowAXB: Boolean,
dialStatus: String
) {
......
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