Commit b10cd886 by 万齐军

Merge branch 'feat/yk/new_nim2' into 'feat/qj/arch3'

audioim抽取

See merge request app_android_lib/YDL-Component!270
parents c5b52439 f9b0977b
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../publish.gradle"
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.audioim.api">
</manifest>
\ No newline at end of file
package com.ydl.audioim.api
import android.app.Activity
import android.content.Context
import com.alibaba.android.arouter.facade.template.IProvider
/**
* Created by Ykai on 2022/7/26.
*/
interface IAudioImService : IProvider{
/**
* YDLavManager初始化方法
*/
fun yDLAvManagerInit(context: Context, appId: String)
/**
* 获取rtm是否在线
*/
fun getIsOnlineRtm(): Boolean
/**
* rtm登录返回并登录状态
*/
fun loginRtm(userId:String?,event: (isSuccess: Boolean, msg: String?) -> Unit)
/**
* rtm登录
*/
fun loginRtm(userId:String?)
/**
* 拨打语音电话转axb弹窗
*/
fun openAxbDialog(activity: Activity?, type:Int, phoneNumber: String?)
/**
* 事件上报
*/
fun callEventSave(status: String, res: String, session: String?, line: String)
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ public class ExpertInfoBean {
public String listenerIsOpen;
public String listenOrderStatus;
public String channelId;
public ExpertInfoBean.ListenRemainingTime remainingTime;
public ListenRemainingTime remainingTime;
public String totalDuration;
public String commentUrl;
......
......@@ -75,4 +75,5 @@ dependencies {
api project(':ydl-webview')
implementation project(":api:user")
implementation project(":api:im")
implementation project(":api:audioim")
}
......@@ -32,6 +32,7 @@ import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.listener.IntentConstants
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.router.AudioImIn
......
......@@ -398,7 +398,7 @@ class YDLavManager {
@SuppressLint("CheckResult")
fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") {
if (TextUtils.isEmpty(userId) || (userId ?: "0") <= "0") {
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
LogUtil.e("[agora]login-uid:$userId")
AliYunRichLogsHelper.getInstance()
......
package com.ydl.audioim.modular
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.widget.AxbConfirmDialog
/**
* Created by Ykai on 2022/7/26.
*/
@Route(path = "/audioim/AudioImService")
class AudioImServiceImp : IAudioImService {
override fun yDLAvManagerInit(context: Context, appId: String) {
YDLavManager.instances.init(context, appId)
}
override fun getIsOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
}
override fun loginRtm(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
YDLavManager.instances.login(userId, event)
}
override fun loginRtm(userId: String?) {
YDLavManager.instances.login(userId)
}
override fun openAxbDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$phoneNumber"))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
}
override fun callEventSave(status: String, res: String, session: String?, line: String) {
YDLavManager.instances.callEventSave(status, res, session, line)
}
override fun init(context: Context?) {
}
}
\ No newline at end of file
# 声网module
\ No newline at end of file
......@@ -71,10 +71,10 @@ dependencies {
api rootProject.ext.dependencies["ydl-user-router"]
api project(':ydl-media')
api project(':ydl-platform')
api project(':m-audioim')
api project(":ydl-pay")
api project(':ydl-webview')
api project(':ydl-utils')
implementation project(":api:audioim")
implementation project(":api:im")
implementation project(":api:user")
implementation project(":api:consultant")
......
......@@ -24,7 +24,7 @@ import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.jcodecraeer.xrecyclerview.ProgressStyle
import com.jcodecraeer.xrecyclerview.XRecyclerView
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.home.adapter.ConfideHomeAdapter
......@@ -248,10 +248,8 @@ class ConfideHomeActivity :
}
if (!confidedId.isNullOrBlank() && !doctorId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { _: Boolean, _ ->
showPayOrDetail(confidedId, doctorId)
}
} else {
......
......@@ -4,14 +4,12 @@ import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.ConfideBottomSheetDialogFragment
import com.ydl.confide.home.ConfideHomeActivity
......@@ -20,6 +18,7 @@ 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
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.YDLCacheUtils
/**
......@@ -73,7 +72,7 @@ class ConfdieServiceImpl : IConfideService {
override fun ydlAvManagerLogin(uid: String?) {
YDLavManager.instances.login(uid)
findRouteService(IAudioImService::class.java).loginRtm(uid)
}
override fun startCondifeHomePage(context: Context, isSplash: Boolean) {
......@@ -91,17 +90,17 @@ class ConfdieServiceImpl : IConfideService {
//debug包根据url判断使用正式或者测试key
val cacheAppEnv = YDLCacheUtils.getCacheApi()
if (!TextUtils.isEmpty(cacheAppEnv)) {
avManagerKey = if (!TextUtils.isEmpty(cacheAppEnv)) {
if (YDLConstants.ENV_TEST == cacheAppEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
} else {
if (YDLConstants.ENV_TEST == appEnv || YDLConstants.ENV_AUTO_TEST == appEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
}
} else {
......@@ -109,27 +108,15 @@ class ConfdieServiceImpl : IConfideService {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
}
YDLavManager.instances.init(app, avManagerKey)
findRouteService(IAudioImService::class.java).yDLAvManagerInit(app, avManagerKey)
}
override fun isOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
return findRouteService(IAudioImService::class.java).getIsOnlineRtm()
}
override fun showAxbConfirmDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber!!))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
findRouteService(IAudioImService::class.java).openAxbDialog(activity, type, phoneNumber)
}
override fun closePlayer() {
......
......@@ -3,15 +3,12 @@ package com.ydl.confide.home.modular.service
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.bean.ExpertInfoBean
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.listener.IntentConstants
import com.ydl.confide.home.ConfidePermissionDialog
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConnectParamJava
......@@ -109,7 +106,7 @@ class ConfideWebServiceImpl {
data: ConfideConnectResponse?
) {
val expertInfo = data?.dialDetail?.agoraExpertInfo ?: return
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001")
return
}
......@@ -128,21 +125,9 @@ class ConfideWebServiceImpl {
* axb 通话
* */
fun axb(activity: Activity, phone: String?) {
if (phone.isNullOrEmpty()) return
val dialog = AxbConfirmDialog(
activity,
1,
object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${phone}"))
activity.startActivity(phoneIntent)
}
override fun onClose() {
}
})
dialog.show()
if (phone.isNullOrEmpty())
return
findRouteService(IAudioImService::class.java).openAxbDialog(activity,1,phone)
}
//java版axb和声网接口
......@@ -154,8 +139,8 @@ class ConfideWebServiceImpl {
tellData: TellData?,
callType: String?
) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
toDial(id, type, callType, activity, tellData)
} else {
......@@ -340,7 +325,7 @@ class ConfideWebServiceImpl {
expertInfo.remainingTime =
ExpertInfoBean.ListenRemainingTime(expertInfo.totalDuration);
}
YDLavManager.instances.callEventSave("10", "用户点击拨打", expertInfo.channelId, "7")
findRouteService(IAudioImService::class.java).callEventSave("10", "用户点击拨打", expertInfo.channelId, "7")
Loading.close()
ARouter.getInstance().build("/av/AudioHomeActivity")
.withString(IntentConstants.INTENT_EXPERT_HEAD_URL, expertInfo.expertHeadUrl)
......
......@@ -16,7 +16,7 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.dou361.ijkplayer.widget.IjkVideoView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.databinding.ItemExpertIntroBinding
......@@ -36,7 +36,6 @@ 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.confide_home_activity.*
import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.io.UnsupportedEncodingException
import java.net.URLDecoder
......@@ -123,8 +122,8 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
else -> {
if (!item.confideId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
showPayOrDetail(item, it)
......
......@@ -6,3 +6,4 @@ include ':app',
":m-im",":m-dynamic",":m-article",":m-audioim",":m-user", ":m-confide"
include ':ydl-tuicore', ':api:confide', ':api:dynamic', ':api:fm', ':api:consultant',
':api:course', ':api:user', ':api:tests', ':api:im',':api:home'
include ':api:audioim'
......@@ -28,7 +28,7 @@ import okio.BufferedSource;
* Des: 解析框架中的网络请求和响应结果并打印
*/
public class RequestLogInterceptor implements Interceptor {
private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
// private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
private boolean mIsDebug;
private RequestHandler mRequestHandler;
......@@ -40,18 +40,18 @@ public class RequestLogInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//打印请求信息
if (request.body() != null && isParseable(request.body().contentType())) {
mPrinter.printJsonRequest(request, parseParams(request));
} else {
mPrinter.printFileRequest(request);
}
if (mRequestHandler != null) {
request = mRequestHandler.onHttpRequestBefore(chain, request);
}
long t1 = System.nanoTime();
//
// //打印请求信息
// if (request.body() != null && isParseable(request.body().contentType())) {
// mPrinter.printJsonRequest(request, parseParams(request));
// } else {
// mPrinter.printFileRequest(request);
// }
//
// if (mRequestHandler != null) {
// request = mRequestHandler.onHttpRequestBefore(chain, request);
// }
// long t1 = System.nanoTime();
Response originalResponse;
try {
originalResponse = chain.proceed(request);
......@@ -59,35 +59,35 @@ public class RequestLogInterceptor implements Interceptor {
NetLogUtils.debugInfo("Http Error: " + e);
throw e;
}
long t2 = System.nanoTime();
// long t2 = System.nanoTime();
ResponseBody responseBody = originalResponse.body();
// ResponseBody responseBody = originalResponse.body();
//打印响应结果
String bodyString = null;
if (responseBody != null && isParseable(responseBody.contentType())) {
bodyString = printResult(request, originalResponse);
if (mRequestHandler != null) {
mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
}
}
if (mIsDebug) {
final List<String> segmentList = request.url().encodedPathSegments();
final String header = originalResponse.headers().toString();
final int code = originalResponse.code();
final boolean isSuccessful = originalResponse.isSuccessful();
final String message = originalResponse.message();
final String url = originalResponse.request().url().toString();
if (responseBody != null && isParseable(responseBody.contentType())) {
mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful,
code, header, responseBody.contentType(), bodyString, segmentList, message, url);
} else {
mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header, segmentList, message, url);
}
}
// String bodyString = null;
// if (responseBody != null && isParseable(responseBody.contentType())) {
// bodyString = printResult(request, originalResponse);
// if (mRequestHandler != null) {
// mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
// }
// }
//
// if (mIsDebug) {
// final List<String> segmentList = request.url().encodedPathSegments();
// final String header = originalResponse.headers().toString();
// final int code = originalResponse.code();
// final boolean isSuccessful = originalResponse.isSuccessful();
// final String message = originalResponse.message();
// final String url = originalResponse.request().url().toString();
//
// if (responseBody != null && isParseable(responseBody.contentType())) {
// mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful,
// code, header, responseBody.contentType(), bodyString, segmentList, message, url);
// } else {
// mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
// isSuccessful, code, header, segmentList, message, url);
// }
// }
return originalResponse;
}
......
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