wait
This commit is contained in:
@@ -2,17 +2,12 @@ package com.mogo.eagle.core.function.chat.facade.bridge
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
internal object BridgeApi {
|
||||
|
||||
private var contextHolder: WeakReference<Context>? = null
|
||||
|
||||
private val apis by lazy {
|
||||
MogoApisHandler.getInstance().apis
|
||||
}
|
||||
|
||||
internal fun init(context: Context?) {
|
||||
context?.let {
|
||||
contextHolder = WeakReference(context)
|
||||
@@ -21,5 +16,4 @@ internal object BridgeApi {
|
||||
|
||||
internal fun context(): Context = contextHolder?.get() ?: Utils.getApp()
|
||||
|
||||
internal fun floatViewManager() = apis?.windowManagerApi
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.api.chat.biz.HangUpState
|
||||
import com.mogo.eagle.core.function.api.chat.biz.IMoGoVoiceControlFacade.IMoGoVoiceCallback
|
||||
import com.mogo.eagle.core.function.api.chat.biz.RefuseState
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiFloatViewManager
|
||||
import com.mogo.eagle.core.function.chat.R
|
||||
import com.mogo.eagle.core.function.chat.facade.MoGoChatFacade
|
||||
import com.mogo.eagle.core.function.chat.facade.OnCallingInterrupt
|
||||
@@ -200,7 +201,7 @@ internal class CallChatWindowManager {
|
||||
log(TAG, "由于对方呼出又挂断,导致来电界面隐藏")
|
||||
d2.safeCancel()
|
||||
}
|
||||
2 -> {
|
||||
2 -> {
|
||||
log(TAG, "由于自己主动拒接,导致来电界面隐藏")
|
||||
d1.safeCancel()
|
||||
}
|
||||
@@ -252,8 +253,11 @@ internal class CallChatWindowManager {
|
||||
|
||||
private fun getInComingLayoutParams(context: Context): FrameLayout.LayoutParams {
|
||||
return FrameLayout.LayoutParams(
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_width).toInt(),
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_height).toInt())
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_width)
|
||||
.toInt(),
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_height)
|
||||
.toInt()
|
||||
)
|
||||
.also {
|
||||
it.gravity = Gravity.BOTTOM or Gravity.START
|
||||
it.marginStart = 40.PX
|
||||
@@ -264,7 +268,11 @@ internal class CallChatWindowManager {
|
||||
/**
|
||||
* 重新开始计时
|
||||
*/
|
||||
private fun CoroutineScope.resetInComingTimer(old: Job?, user: UserInfo, incomingView: View): Job {
|
||||
private fun CoroutineScope.resetInComingTimer(
|
||||
old: Job?,
|
||||
user: UserInfo,
|
||||
incomingView: View
|
||||
): Job {
|
||||
old?.safeCancel()
|
||||
return inComingTimer(user, incomingView)
|
||||
}
|
||||
@@ -284,13 +292,13 @@ internal class CallChatWindowManager {
|
||||
var callingView = LayoutInflater.from(context)
|
||||
.inflate(R.layout.module_car_chatting_launcher_calling_hawk_eye_view, null)
|
||||
callingView.isClickable = true
|
||||
var calling= callingView.findViewById<View>(R.id.module_carchatting_rl_call_view)
|
||||
var calling = callingView.findViewById<View>(R.id.module_carchatting_rl_call_view)
|
||||
var head = callingView.findViewById<ImageView>(R.id.module_carchatting_call_head)
|
||||
var hangUp = callingView.findViewById<View>(R.id.module_carchatting_call_hangUp)
|
||||
var name = callingView.findViewById<TextView>(R.id.module_carchatting_call_nickname)
|
||||
var timer = callingView.findViewById<TextView>(R.id.module_carchatting_call_time)
|
||||
calling.visibility = View.VISIBLE
|
||||
name.text = "云平台"
|
||||
name.text = "云平台"
|
||||
timer.text = context.resources.getString(R.string.module_car_chat_matching_wait)
|
||||
GlideApp.with(context).load(user.icon)
|
||||
.apply(
|
||||
@@ -353,7 +361,7 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
hide(callingView)
|
||||
facade.audioFocus().releaseAudioFocus()
|
||||
}.also { job = it }
|
||||
}.also { job = it }
|
||||
}
|
||||
if (itx == ON_DESTROY) {
|
||||
isCallingShow = false
|
||||
@@ -375,9 +383,9 @@ internal class CallChatWindowManager {
|
||||
|
||||
private fun getCallingLayoutParams(context: Context): FrameLayout.LayoutParams {
|
||||
return FrameLayout.LayoutParams(
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_hawk_eye_width).toInt(),
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_hawk_eye_height).toInt()
|
||||
)
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_hawk_eye_width).toInt(),
|
||||
context.resources.getDimension(R.dimen.module_call_chat_state_hawk_eye_height).toInt()
|
||||
)
|
||||
.also {
|
||||
it.gravity = Gravity.BOTTOM or Gravity.START
|
||||
it.marginStart = 40.PX
|
||||
@@ -393,17 +401,17 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
|
||||
private fun show(view: View, params: FrameLayout.LayoutParams) {
|
||||
BridgeApi.floatViewManager()?.addView(view, params, true)
|
||||
CallerHmiFloatViewManager.addView(view, params, true)
|
||||
}
|
||||
|
||||
private fun hide(view: View) {
|
||||
if (!ViewCompat.isAttachedToWindow(view)) {
|
||||
return
|
||||
}
|
||||
BridgeApi.floatViewManager()?.removeView(view)
|
||||
CallerHmiFloatViewManager.removeView(view)
|
||||
}
|
||||
|
||||
private fun playAudioCall(onPlay:(() -> Unit)? = null) {
|
||||
private fun playAudioCall(onPlay: (() -> Unit)? = null) {
|
||||
facade.also {
|
||||
it.audioFocus().requireAudioFocus {
|
||||
it.media().play(context, R.raw.call, true, AudioManager.STREAM_RING)
|
||||
@@ -474,7 +482,13 @@ internal class CallChatWindowManager {
|
||||
* @param onExit: 当前用户退房通知(当前用户主动挂断或对方挂断)
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private fun answer(user: UserInfo, onEnter: () -> Unit, onNewEnter: () -> Unit, onExit: () -> Unit, onError: (code: Int, msg: String, extra: Map<String, String>? ) -> Unit) {
|
||||
private fun answer(
|
||||
user: UserInfo,
|
||||
onEnter: () -> Unit,
|
||||
onNewEnter: () -> Unit,
|
||||
onExit: () -> Unit,
|
||||
onError: (code: Int, msg: String, extra: Map<String, String>?) -> Unit
|
||||
) {
|
||||
facade.also { itx ->
|
||||
if (hasAnswered) {
|
||||
return
|
||||
@@ -482,7 +496,7 @@ internal class CallChatWindowManager {
|
||||
hasAnswered = true
|
||||
itx.answer(user.sn)
|
||||
.onEach {
|
||||
when(it) {
|
||||
when (it) {
|
||||
is EnterRoomSuccess -> {
|
||||
onEnter.invoke()
|
||||
}
|
||||
@@ -507,7 +521,12 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun doRefuse(user: UserInfo, notify: Boolean = true, inComingView: View, isAnswerFail: Boolean) {
|
||||
private fun doRefuse(
|
||||
user: UserInfo,
|
||||
notify: Boolean = true,
|
||||
inComingView: View,
|
||||
isAnswerFail: Boolean
|
||||
) {
|
||||
refuse(user,
|
||||
onSuccess = {
|
||||
if (notify) {
|
||||
@@ -529,7 +548,11 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private fun refuse(user: UserInfo, onSuccess: () -> Unit, onError: (code: Int, msg: String, extra: Map<String, String>?) -> Unit){
|
||||
private fun refuse(
|
||||
user: UserInfo,
|
||||
onSuccess: () -> Unit,
|
||||
onError: (code: Int, msg: String, extra: Map<String, String>?) -> Unit
|
||||
) {
|
||||
facade.also {
|
||||
if (hasRefused) {
|
||||
return
|
||||
@@ -537,7 +560,7 @@ internal class CallChatWindowManager {
|
||||
hasRefused = true
|
||||
it.refuse(user.sn)
|
||||
.onEach { itx ->
|
||||
when(itx) {
|
||||
when (itx) {
|
||||
is RefuseState.Success -> {
|
||||
onSuccess.invoke()
|
||||
}
|
||||
@@ -591,13 +614,17 @@ internal class CallChatWindowManager {
|
||||
var counter = 1
|
||||
while (true) {
|
||||
delay(1000)
|
||||
emit(1000L * (counter ++))
|
||||
emit(1000L * (counter++))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private fun hangUp(user: UserInfo, onSuccess: () -> Unit, onError:(code: Int, msg: String, extra: Map<String, String>?) -> Unit) {
|
||||
private fun hangUp(
|
||||
user: UserInfo,
|
||||
onSuccess: () -> Unit,
|
||||
onError: (code: Int, msg: String, extra: Map<String, String>?) -> Unit
|
||||
) {
|
||||
facade.also {
|
||||
if (hasHangUpped) {
|
||||
return
|
||||
@@ -605,13 +632,16 @@ internal class CallChatWindowManager {
|
||||
hasHangUpped = true
|
||||
it.handUp(user.sn)
|
||||
.onEach { itx ->
|
||||
when(itx) {
|
||||
when (itx) {
|
||||
HangUpState.Success -> {
|
||||
onSuccess.invoke()
|
||||
}
|
||||
is HangUpState.Error -> {
|
||||
hasHangUpped = false
|
||||
log(TAG, "-- 挂断失败 --: code:: ${itx.code}; msg:: ${itx.msg}; extra:: ${itx.extra}")
|
||||
log(
|
||||
TAG,
|
||||
"-- 挂断失败 --: code:: ${itx.code}; msg:: ${itx.msg}; extra:: ${itx.extra}"
|
||||
)
|
||||
onError.invoke(itx.code, itx.msg, itx.extra)
|
||||
}
|
||||
else -> {
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewLayoutSet;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -14,8 +14,8 @@ import com.mogo.service.windowview.IMogoWindowManager;
|
||||
* <p>
|
||||
* 根据优先级控制显示 window view.
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_WINDOW_MANAGER )
|
||||
public class MogoWindowManager implements IMogoWindowManager {
|
||||
@Route( path = MogoServicePaths.PATH_FLOAT_VIEW_MANAGER )
|
||||
public class FloatViewManager implements IViewLayoutSet {
|
||||
|
||||
@Override
|
||||
public void addView( View view, int x, int y, boolean movable ) {
|
||||
@@ -6,12 +6,11 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.cloud.socket.entity.SocketDownData;
|
||||
import com.mogo.eagle.core.function.live.impl.AbsCameraScenario;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
|
||||
/**
|
||||
* 路边摄像头直播控制 V2XPushLiveCarScenario
|
||||
*/
|
||||
public class CameraLiveManager extends AbsCameraScenario<SocketDownData.CloudRoadDataProto> implements IMogoTopViewStatusListener {
|
||||
public class CameraLiveManager extends AbsCameraScenario<SocketDownData.CloudRoadDataProto> {
|
||||
private static final String TAG = "CameraLiveManager";
|
||||
private static CameraLiveManager mCameraLiveManager;
|
||||
private boolean isShowWindow;
|
||||
@@ -89,20 +88,4 @@ public class CameraLiveManager extends AbsCameraScenario<SocketDownData.CloudRoa
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.core.util.Pair
|
||||
import androidx.localbroadcastmanager.content.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.cloud.passport.*
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.module.ServiceConst.CARD_TYPE_ROAD_CONDITION
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
@@ -54,6 +55,7 @@ import com.mogo.eagle.core.utilcode.mogo.storage.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.listener.*
|
||||
import com.mogo.map.marker.*
|
||||
import com.mogo.v2x.*
|
||||
|
||||
Reference in New Issue
Block a user