This commit is contained in:
zhongchao
2021-11-05 22:59:09 +08:00
parent a4938ccd8c
commit 6c094debd8
96 changed files with 671 additions and 3266 deletions

View File

@@ -7,7 +7,9 @@ import com.google.gson.Gson
import com.mogo.chat.constant.CALL_TYPE_VEHICLE_TEAM
import com.mogo.chat.model.bean.TeammateInfo
import com.mogo.chat.service.IMService
import com.mogo.chat.util.UserInfoHelper
import com.mogo.chat.util.UserInfoHelper.currentCallType
import com.mogo.chat.util.log
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_SERVICE_APIS
import com.mogo.module.carchatting.R
@@ -30,7 +32,7 @@ import com.mogo.utils.logger.Logger
import com.zhidao.carchattingprovider.MogoDriverInfo
class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCommandListener,
IVoiceIntentListener {
IVoiceIntentListener {
companion object {
const val TAG: String = "CallChatCenter"
@@ -87,14 +89,14 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
this.serviceApi = mogoService
}
serviceApi?.statusManagerApi?.registerStatusChangedListener(
MODULE_NAME,
StatusDescriptor.MAIN_PAGE_RESUME,
statusChangedListener
MODULE_NAME,
StatusDescriptor.MAIN_PAGE_RESUME,
statusChangedListener
)
serviceApi?.statusManagerApi?.registerStatusChangedListener(
MODULE_NAME,
StatusDescriptor.VR_MODE,
statusChangedListener
MODULE_NAME,
StatusDescriptor.VR_MODE,
statusChangedListener
)
}
@@ -105,7 +107,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
if (status) {
VoiceUtil.registerAll(context!!, this, this)
syncInitStatus()
Logger.i(TAG, "MAIN_PAGE_RESUME callType: $currentCallType , status : ${callChatManager.isCalling()}")
Logger.i(
TAG,
"MAIN_PAGE_RESUME callType: $currentCallType , status : ${callChatManager.isCalling()}"
)
if (currentCallType == CALL_TYPE_VEHICLE_TEAM && callChatManager.isCalling()) {
callWindowShowCallBack()
callingWindowManager.showVehicleTeamView()
@@ -122,7 +127,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
}
}
StatusDescriptor.VR_MODE -> {
Logger.i(TAG, "VR_MODE callType: $currentCallType , status : ${callChatManager.isCalling()}")
Logger.i(
TAG,
"VR_MODE callType: $currentCallType , status : ${callChatManager.isCalling()}"
)
updateCallingWindowInVRMode()
}
else -> {
@@ -217,8 +225,8 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
private fun match(matchType: Int, from: Int = 1) {
LogUtil.i(TAG, "startMatch")
AnalyticsUtil.track(
INVOKE_TRACK_MATCH_SHOW,
mutableMapOf("matchatype" to matchType, "source" to 2, "from" to from)
INVOKE_TRACK_MATCH_SHOW,
mutableMapOf("matchatype" to matchType, "source" to 2, "from" to from)
)
callChatManager.match()
}
@@ -234,8 +242,8 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
LogUtil.i(TAG, "CARD_MATCH_FAILED matchFailed")
val type = if (isTTS) 1 else 2
AnalyticsUtil.track(
INVOKE_TRACK_MATCH_FAIL_CLOSE_CLICK,
hashMapOf("type" to type)
INVOKE_TRACK_MATCH_FAIL_CLOSE_CLICK,
hashMapOf("type" to type)
)
cancelMatchToDefault(isTTS)
}
@@ -244,19 +252,24 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
private fun showVehicleTeamFragment() {
LogUtil.i(TAG, "showVehicleTeamFragment")
activity?.supportFragmentManager
?.beginTransaction()
?.replace(containerId!!, VehicleTeamFragment.newInstance(), VehicleTeamFragment::class.simpleName)
?.commitNowAllowingStateLoss()
?.beginTransaction()
?.replace(
containerId!!,
VehicleTeamFragment.newInstance(),
VehicleTeamFragment::class.simpleName
)
?.commitNowAllowingStateLoss()
}
fun closeVehicleTeamFragment() {
activity?.let {
it.supportFragmentManager.let { fragmentManager ->
fragmentManager.findFragmentByTag(VehicleTeamFragment::class.simpleName)?.let { fragment ->
fragmentManager.beginTransaction()
fragmentManager.findFragmentByTag(VehicleTeamFragment::class.simpleName)
?.let { fragment ->
fragmentManager.beginTransaction()
.remove(fragment)
.commitNowAllowingStateLoss()
}
}
}
}
}
@@ -390,6 +403,20 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
refreshViewByType()
}
override fun answerCall() {
Logger.d(TAG, "answerCall")
taskMainLaunch {
callingWindowManager.hideIncomingView()
}
}
override fun answerCallError(errorMsg: String) {
Logger.d(TAG, "answerCallError")
taskMainLaunch {
TipToast.shortTip(errorMsg)
}
}
override fun call(userInfo: UserInfo?) {
Logger.d(TAG, "call===userInfo: $userInfo")
if (userInfo != null) {
@@ -450,7 +477,7 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
private fun resetCallingView() {
showCallWindowFromDefault = false
hideLauncherCallingView()
mapViewManager.resetMarkerStatus()
mapViewManager.resetMarkerStatus(serviceApi)
}
override fun callInvokeError(msg: String) {
@@ -458,6 +485,25 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
resetCallingView()
}
/**
* 收到来电消息
* 1.如果当前已经打来电话,再次接收到,则拒绝
* 2.如果当前正在打电话中,则拒绝
*/
override fun showIncomingCall(userInfo: UserInfo) {
if (callChatManager.isCalling() || callingWindowManager.isIncomingWindowShow()) {
log(TAG, "已在通话进程中,准备拒绝他 ---> ")
refuseCall(userInfo.sn)
} else {
log(TAG, "有人打来电话,准备显示 ---> ${UserInfoHelper.currentRoomId}")
callingWindowManager.showIncomingView({
callChatManager.answerInvoke(userInfo.sn)
}, {
refuseCall(userInfo.sn)
})
}
}
override fun match(userInfo: UserInfo) {
Logger.d(TAG, "match===userInfo: $userInfo")
currentUserInfo = userInfo
@@ -465,7 +511,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
}
override fun matchInvokeResult(invokeResult: Boolean, userInfo: UserInfo?, errorMsg: String) {
Logger.d(TAG, "matchInvokeResult===$invokeResult, msg: $errorMsg, callStatus: ${callChatManager.getStatusName()}")
Logger.d(
TAG,
"matchInvokeResult===$invokeResult, msg: $errorMsg, callStatus: ${callChatManager.getStatusName()}"
)
if (invokeResult) {
// 开始匹配成功
currentUserInfo = userInfo
@@ -526,7 +575,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
*/
override fun vehicleTeamMemberChange(teamMember: List<TeammateInfo>?) {
try {
Logger.d(TAG, "vehicleTeamMemberChange:" + teamMember?.size + ":" + teamMember.toString())
Logger.d(
TAG,
"vehicleTeamMemberChange:" + teamMember?.size + ":" + teamMember.toString()
)
this.teamMember = teamMember
callingWindowManager.updateVehicleTeamHeadView(teamMember)
mapViewManager.updateTeamMarker(context!!, teamMember)
@@ -600,11 +652,11 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
teamInvitationWindowManager.hideTeamInvitationView()
AnalyticsUtil.track(INVOKE_TRACK_CHATTING)
mapViewManager.showLocationOnMap(
context!!,
serviceApi,
currentUserInfo?.lat?.toDouble(),
currentUserInfo?.lon?.toDouble(),
currentUserInfo?.userHead
context!!,
serviceApi,
currentUserInfo?.lat?.toDouble(),
currentUserInfo?.lon?.toDouble(),
currentUserInfo?.userHead
)
refreshViewByType()
}
@@ -625,7 +677,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
* 邀请加入车队
*/
fun inviteJoinVehicleTeam(sn: String) {
Logger.i(TAG, "isCalling():" + callChatManager.isCalling() + ",currentCallType:" + currentCallType)
Logger.i(
TAG,
"isCalling():" + callChatManager.isCalling() + ",currentCallType:" + currentCallType
)
if (callChatManager.isCalling() && currentCallType != CALL_TYPE_VEHICLE_TEAM) {
toast(R.string.module_car_chat_in_call)
return
@@ -654,7 +709,10 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
}
private fun onPause() {
Logger.i(TAG, "onPause currentCallType : $currentCallType , status: ${callChatManager.isCalling()}")
Logger.i(
TAG,
"onPause currentCallType : $currentCallType , status: ${callChatManager.isCalling()}"
)
userWindowManager.hideUserView()
callWindowHideCallBack()
if (currentCallType == CALL_TYPE_VEHICLE_TEAM && callChatManager.isCalling()) {
@@ -668,14 +726,14 @@ class CallChatCenter private constructor() : IBizCallChat.IBizCallBack, IVoiceCo
fun onDestroy() {
serviceApi?.statusManagerApi?.unregisterStatusChangedListener(
MODULE_NAME,
StatusDescriptor.MAIN_PAGE_RESUME,
statusChangedListener
MODULE_NAME,
StatusDescriptor.MAIN_PAGE_RESUME,
statusChangedListener
)
serviceApi?.statusManagerApi?.unregisterStatusChangedListener(
MODULE_NAME,
StatusDescriptor.VR_MODE,
statusChangedListener
MODULE_NAME,
StatusDescriptor.VR_MODE,
statusChangedListener
)
teamInvitationWindowManager.onDestroy()
flag = null

View File

@@ -8,7 +8,9 @@ import com.mogo.chat.callcenter.CallTypeManager.Companion.callTypeManager
import com.mogo.chat.constant.CALL_TYPE_MATCHING
import com.mogo.chat.constant.CALL_TYPE_VEHICLE_TEAM
import com.mogo.chat.constant.CALL_TYPE_VOICE
import com.mogo.chat.model.bean.Message
import com.mogo.chat.model.bean.TeammateInfo
import com.mogo.chat.model.bean.toSns
import com.mogo.chat.util.CallTimer.Companion.callTimer
import com.mogo.chat.util.UserInfoHelper.currentCallType
import com.mogo.chat.util.UserInfoHelper.tmpSenderInfo
@@ -18,6 +20,7 @@ import com.mogo.module.carchatting.bean.EnthusiasmIndex
import com.mogo.module.carchatting.bean.Result
import com.mogo.module.carchatting.bean.UserInfo
import com.mogo.module.carchatting.bean.toUserInfo
import com.mogo.module.carchatting.card.CallChatConstant.Companion.TAG
import com.mogo.module.carchatting.net.Repository
import com.mogo.module.carchatting.net.request
import com.mogo.utils.logger.Logger
@@ -27,7 +30,6 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
companion object {
const val TAG: String = "CallChatManager"
const val METHOD_FLAG = "CAR_CALL_TO_DEFAULT"
}
@@ -47,6 +49,16 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
iBizCallBack?.invokeCallData(toUserInfo(tmpSenderInfo))
}
override fun receiverCalling(message: Message) {
super.receiverCalling(message)
iBizCallBack?.showIncomingCall(toUserInfo(message.toSns()))
}
override fun refuseMatchToShowCalling(message: Message) {
super.refuseMatchToShowCalling(message)
iBizCallBack?.showIncomingCall(toUserInfo(message.toSns()))
}
override fun receiverCallingAgree() {
super.receiverCallingAgree()
iBizCallBack?.call(toUserInfo(tmpSenderInfo))
@@ -142,6 +154,11 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
})
}
fun answerInvoke(sn: String) {
Logger.i(TAG, "answerInvoke")
IMCallManager.answer(sn, this)
}
fun callToSomeone(sn: String) {
Logger.i(TAG, "callToSomeone")
IMCallManager.call(METHOD_FLAG, sn, this)
@@ -204,9 +221,9 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
}
fun getEnthusiasmIndex(
sn: String,
onSuccess: (EnthusiasmIndex) -> Unit,
onError: (String) -> Unit
sn: String,
onSuccess: (EnthusiasmIndex) -> Unit,
onError: (String) -> Unit
) {
request<BaseResponse<Result>> {
loader {
@@ -238,7 +255,7 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
override fun invokeCallData(invokeData: String) {
super.invokeCallData(invokeData)
if (!invokeData.isBlank()) {
if (invokeData.isNotBlank()) {
val userInfo = Gson().fromJson(invokeData, UserInfo::class.java)
iBizCallBack?.invokeCallData(userInfo)
} else {
@@ -246,10 +263,22 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
}
}
override fun answer() {
super.answer()
Logger.i(TAG, "answer")
iBizCallBack?.answerCall()
}
override fun answerCallError(errorMsg: String) {
super.answerCallError(errorMsg)
Logger.i(TAG, "answerCallError errorMsg : $errorMsg")
iBizCallBack?.answerCallError(errorMsg)
}
override fun call(data: String) {
super.call(data)
Logger.i(TAG, "call data: $data")
if (!data.isBlank()) {
if (data.isNotBlank()) {
val userInfo = Gson().fromJson(data, UserInfo::class.java)
iBizCallBack?.call(userInfo)
} else {
@@ -271,7 +300,11 @@ class CallChatManager(iBizCallChat: IBizCallChat.IBizCallBack) : ICallResponse {
override fun matchInvokeResult(invokeResult: Boolean, msg: String) {
super.matchInvokeResult(invokeResult, msg)
if (invokeResult) {
iBizCallBack?.matchInvokeResult(invokeResult, Gson().fromJson(msg, UserInfo::class.java), msg)
iBizCallBack?.matchInvokeResult(
invokeResult,
Gson().fromJson(msg, UserInfo::class.java),
msg
)
} else {
iBizCallBack?.matchInvokeResult(invokeResult, null, msg)
}

View File

@@ -9,12 +9,18 @@ interface IBizCallChat {
fun callTypeInit()
fun answerCall()
fun answerCallError(errorMsg: String)
fun call(userInfo: UserInfo?)
fun invokeCallData(userInfo: UserInfo?)
fun callInvokeError(msg: String)
fun showIncomingCall(userInfo: UserInfo)
fun match(userInfo: UserInfo)
fun matchInvokeResult(invokeResult: Boolean, userInfo: UserInfo?, errorMsg: String)

View File

@@ -1,6 +1,7 @@
package com.mogo.module.carchatting.biz
import com.google.gson.Gson
import com.mogo.chat.callcenter.CallController
import com.mogo.chat.callcenter.CallTypeManager.Companion.callTypeManager
import com.mogo.chat.callcenter.IMType
import com.mogo.chat.callcenter.SocketClientFactory
@@ -8,6 +9,7 @@ import com.mogo.chat.callcenter.isInit
import com.mogo.chat.common.gme.GMEApi
import com.mogo.chat.constant.OFFLINE_STATUS
import com.mogo.chat.constant.ONLINE_STATUS
import com.mogo.chat.model.control.ChatController
import com.mogo.chat.service.ChatServiceHandler
import com.mogo.chat.service.InvokeDataProxy
import com.mogo.chat.util.UserInfoHelper
@@ -15,6 +17,7 @@ import com.mogo.chat.util.UserInfoHelper.currentCallType
import com.mogo.chat.util.UserInfoHelper.tmpSenderInfo
import com.mogo.chat.util.log
import com.mogo.module.carchatting.card.CallChatConstant.Companion.PARAM_SN
import com.mogo.module.carchatting.card.CallChatConstant.Companion.TAG
import com.zhidao.carchattingprovider.ICallProviderResponse
import com.zhidao.carchattingprovider.ICallResponse
import kotlinx.coroutines.Dispatchers
@@ -24,17 +27,30 @@ import kotlinx.coroutines.launch
class IMCallManager private constructor() {
companion object {
const val TAG = "IMCallManager"
fun canCall(flag: String, response: ICallProviderResponse) {
log(TAG, "是否能拨打电话 flag --->: $flag")
response.canCall(callTypeManager.callStatus.isInit() && SocketClientFactory.socketClient.isOpen)
}
fun answer(sn: String, response: ICallResponse) {
ChatServiceHandler.answer(sn, UserInfoHelper.currentRoomId, {
log(TAG, "接听电话成功 ---> ")
response.answer()
ChatController.enterRoom(UserInfoHelper.currentRoomId)
CallController.callController.callingReceiver()
}, {
val errorMsg =
if (it.message != null) it.message else "answer call is error ,please try again"
response.answerCallError(errorMsg!!)
log(TAG, " answer call is error ,please try again")
})
}
fun call(
flag: String,
snReceiver: String,
response: ICallResponse
flag: String,
snReceiver: String,
response: ICallResponse
) {
log(TAG, "拨打电话 sn --->: $snReceiver , flag: $flag")
if (callTypeManager.callStatus.isInit() && SocketClientFactory.socketClient.isOpen) {
@@ -45,15 +61,17 @@ class IMCallManager private constructor() {
response.callInvokeError(exception.message!!)
})
} else {
log(TAG, "拨打电话出现异常 能否拨打 :${callTypeManager.callStatus.isInit()} " +
"长连状态:${SocketClientFactory.socketClient.isOpen}")
log(
TAG, "拨打电话出现异常 能否拨打 :${callTypeManager.callStatus.isInit()} " +
"长连状态:${SocketClientFactory.socketClient.isOpen}"
)
response.error("call: 正在通话中,请稍后再试")
}
}
fun match(
flag: String,
response: ICallResponse
flag: String,
response: ICallResponse
) {
log(TAG, "开始匹配 ---> flag: $flag ")
ChatServiceHandler.startMatch(flag, {
@@ -101,9 +119,9 @@ class IMCallManager private constructor() {
}
fun hangUp(
flag: String,
snReceiver: String,
response: ICallResponse
flag: String,
snReceiver: String,
response: ICallResponse
) {
log(TAG, "挂断电话 ---> flag: $flag , snReceiver : $snReceiver")
ChatServiceHandler.hangUp(snReceiver, {
@@ -114,9 +132,11 @@ class IMCallManager private constructor() {
})
}
fun refuseCall(flag: String,
snSender: String,
response: ICallResponse) {
fun refuseCall(
flag: String,
snSender: String,
response: ICallResponse
) {
log(TAG, "拒绝电话 / 取消打电话 ---> flag: $flag")
ChatServiceHandler.refuseCall(snSender, {
response.refuse(true, currentCallType)
@@ -164,9 +184,9 @@ class IMCallManager private constructor() {
}
fun invisibleUser(
flag: String,
visible: Boolean,
response: ICallResponse
flag: String,
visible: Boolean,
response: ICallResponse
) {
log(TAG, "用户隐身 ---> flag: $flag , visible : $visible")
val status: Int = if (visible) {
@@ -182,9 +202,9 @@ class IMCallManager private constructor() {
}
fun isOnLine(
flag: String,
sn: String,
response: ICallResponse
flag: String,
sn: String,
response: ICallResponse
) {
log(TAG, "车机是否在线 ---> flag: $flag , sn : $sn")
ChatServiceHandler.isOnLine(sn, { onLine: Boolean ->
@@ -195,9 +215,9 @@ class IMCallManager private constructor() {
}
fun getUserInfoForCall(
flag: String,
sn: String?,
response: ICallResponse
flag: String,
sn: String?,
response: ICallResponse
) {
val tmpSn = sn ?: ""
log(TAG, "获取用户信息 ---> flag: $flag , sn : $sn")

View File

@@ -0,0 +1,13 @@
package com.mogo.module.carchatting.biz
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.mogo.module.carchatting.bean.UserInfo
class Test:BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
CallChatCenter.callChatCenter.showIncomingCall(UserInfo("123",123,"","","","","","","",""))
}
}

View File

@@ -26,5 +26,7 @@ class CallChatConstant {
const val PARAM_MUTE = "PARAM_MUTE"
const val PARAM_VISIBLE = "PARAM_VISIBLE"
const val PARAM_END_TYPE = "PARAM_END_TYPE"
const val TAG = "CALL_CHATTING"
}
}

View File

@@ -1,105 +0,0 @@
package com.mogo.module.carchatting.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mogo.module.carchatting.R;
import com.mogo.module.common.utils.CarSeries;
import java.util.ArrayList;
public
/*
* @author congtaowang
* @since 2020/12/1
*
* 描述
*/
class CallUserView {
private CallUserView(){
}
private static ArrayList<Bitmap> sBitmaps;
public synchronized static ArrayList<Bitmap> inflateCallingBitmap(Context context) {
if (!CarSeries.isF8xxSeries()) {
return null;
}
if (sBitmaps != null && !sBitmaps.isEmpty()) {
return sBitmaps;
}
sBitmaps = new ArrayList<>();
for (int i = 0; i < calling.length; i++) {
sBitmaps.add(inflateView(context, i));
}
return sBitmaps;
}
private static final int[] calling = {
R.mipmap.module_callchat_green_cycle_00020,
// R.mipmap.module_callchat_green_cycle_00021,
// R.mipmap.module_callchat_green_cycle_00022,
R.mipmap.module_callchat_green_cycle_00023,
// R.mipmap.module_callchat_green_cycle_00024,
// R.mipmap.module_callchat_green_cycle_00025,
R.mipmap.module_callchat_green_cycle_00026,
// R.mipmap.module_callchat_green_cycle_00027,
// R.mipmap.module_callchat_green_cycle_00028,
R.mipmap.module_callchat_green_cycle_00029,
// R.mipmap.module_callchat_green_cycle_00030,
// R.mipmap.module_callchat_green_cycle_00031,
R.mipmap.module_callchat_green_cycle_00032,
// R.mipmap.module_callchat_green_cycle_00033,
// R.mipmap.module_callchat_green_cycle_00034,
R.mipmap.module_callchat_green_cycle_00035,
// R.mipmap.module_callchat_green_cycle_00036,
// R.mipmap.module_callchat_green_cycle_00037,
R.mipmap.module_callchat_green_cycle_00038,
// R.mipmap.module_callchat_green_cycle_00039,
// R.mipmap.module_callchat_green_cycle_00040,
R.mipmap.module_callchat_green_cycle_00041,
// R.mipmap.module_callchat_green_cycle_00042,
// R.mipmap.module_callchat_green_cycle_00043,
R.mipmap.module_callchat_green_cycle_00044,
// R.mipmap.module_callchat_green_cycle_00045,
// R.mipmap.module_callchat_green_cycle_00046,
R.mipmap.module_callchat_green_cycle_00047,
R.mipmap.module_callchat_green_cycle_00048
};
public static Bitmap inflateView(Context context, int index) {
View view = LayoutInflater.from(context).inflate(R.layout.module_car_chatting_calling_user_view, null);
view.setBackgroundResource(calling[index]);
return fromView(view);
}
private static Bitmap fromView(View view) {
view.setDrawingCacheEnabled(true);
processChildView(view);
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Bitmap bitmap;
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
}
private static void processChildView(View view) {
if (!(view instanceof ViewGroup)) {
if (view instanceof TextView) {
((TextView) view).setHorizontallyScrolling(false);
}
} else {
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
processChildView(((ViewGroup) view).getChildAt(var1));
}
}
}
}

View File

@@ -2,7 +2,10 @@ package com.mogo.module.carchatting.view
import android.annotation.SuppressLint
import android.content.Context
import android.media.AudioManager
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
@@ -10,9 +13,12 @@ import androidx.constraintlayout.widget.ConstraintLayout
import com.bumptech.glide.request.RequestOptions
import com.mogo.chat.constant.TAG
import com.mogo.chat.model.bean.TeammateInfo
import com.mogo.chat.util.MediaController
import com.mogo.chat.util.log
import com.mogo.chat.voice.IMVoiceClient
import com.mogo.chat.voice.IVoiceIntentListener
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.debug.DebugConfig.CAR_MACHINE_TYPE_BYD
import com.mogo.commons.debug.DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE
import com.mogo.module.carchatting.R
import com.mogo.module.carchatting.bean.UserInfo
import com.mogo.module.carchatting.biz.CallChatCenter
@@ -24,8 +30,9 @@ import com.mogo.utils.glide.GlideApp
import com.mogo.utils.glide.GlideRoundedCornersTransform
import com.mogo.utils.logger.Logger
import de.hdodenhof.circleimageview.CircleImageView
import kotlin.let as let
class CallingWindowManager private constructor() {
class CallingWindowManager private constructor() : IVoiceIntentListener {
companion object {
@@ -39,12 +46,19 @@ class CallingWindowManager private constructor() {
@Volatile
private var isLauncherCallingViewShown = false
@Volatile
private var isLauncherIncomingViewShown = false
private var launcherIncomingView: View? = null
private var launcherCallingView: View? = null
private var matchView: ConstraintLayout? = null
private var matchingView: ConstraintLayout? = null
private var callingView: ConstraintLayout? = null
private var callIncomingAnswer: ImageView? = null
private var callIncomingRefuse: ImageView? = null
private var cancelMatch: TextView? = null
private var callingHead: ImageView? = null
private var callingNickName: TextView? = null
@@ -68,14 +82,18 @@ class CallingWindowManager private constructor() {
private var showVehicleTeamView: (() -> Unit)? = null
private var quitVehicleTeam: (() -> Unit)? = null
private var moveToCenter: (() -> Unit)? = null
private var agreeIncomingBack: (() -> Unit)? = null
private var hangUpIncomingBack: (() -> Unit)? = null
@SuppressLint("InflateParams")
fun init(context: Context, serviceApi: IMogoServiceApis,
match: () -> Unit,
cancelMatch: () -> Unit,
showVehicleTeamView: () -> Unit,
quitVehicleTeam: () -> Unit,
moveToCenter: () -> Unit) {
fun init(
context: Context, serviceApi: IMogoServiceApis,
match: () -> Unit,
cancelMatch: () -> Unit,
showVehicleTeamView: () -> Unit,
quitVehicleTeam: () -> Unit,
moveToCenter: () -> Unit
) {
Logger.d(CallChatCenter.TAG, "CallingWindowManager init --->")
this.mContext = context
this.serviceApi = serviceApi
@@ -84,11 +102,7 @@ class CallingWindowManager private constructor() {
this.showVehicleTeamView = showVehicleTeamView
this.quitVehicleTeam = quitVehicleTeam
this.moveToCenter = moveToCenter
if (DebugConfig.getCarMachineType() == CAR_MACHINE_TYPE_BYD) {
Logger.d(CallChatCenter.TAG, "CallingWindowManager 展示匹配 addLeftFeatureView--->")
initView()
serviceApi.entranceButtonController?.addLeftFeatureView(launcherCallingView)
}
hideIncomingView()
}
private fun initView() {
@@ -119,8 +133,6 @@ class CallingWindowManager private constructor() {
matchView?.visibility = View.VISIBLE
}
matchView?.setOnClickListener {
match?.invoke()
matchView?.visibility = View.GONE
@@ -147,11 +159,15 @@ class CallingWindowManager private constructor() {
if (isLauncherCallingViewShown) {
return
}
if (DebugConfig.getCarMachineType() != CAR_MACHINE_TYPE_BYD) {
serviceApi?.windowManagerApi?.addView(launcherCallingView, vrModeHelper.getCallingWindowLayoutPosition(mContext!!), true)
} else {
serviceApi?.entranceButtonController?.addLeftFeatureView(launcherCallingView)
}
serviceApi?.windowManagerApi?.addView(
launcherCallingView,
vrModeHelper.getCallingWindowLayoutPosition(mContext!!),
true
)
}
fun isIncomingWindowShow(): Boolean {
return isLauncherIncomingViewShown
}
fun isCallingWindowShow(): Boolean {
@@ -184,9 +200,66 @@ class CallingWindowManager private constructor() {
}
}
fun showIncomingView(
agreeIncomingBack: () -> Unit,
hangUpIncomingBack: () -> Unit
) {
Logger.d(
CallChatCenter.TAG,
"展示Launcher来电浮窗 showIncomingView===$isLauncherCallingViewShown"
)
this.agreeIncomingBack = agreeIncomingBack
this.hangUpIncomingBack = hangUpIncomingBack
if (!isLauncherCallingViewShown) {
IMVoiceClient.speakAndRegisterCall({ _ ->
if (isLauncherCallingViewShown) {
log(TAG, "speakAndRegisterCall")
releaseAudioAndVoice()
}
}, {
log(TAG, "playFinish")
playAudioCall()
registerIntentInComingCall()
})
if (launcherIncomingView == null) {
launcherIncomingView = LayoutInflater.from(mContext)
.inflate(R.layout.module_car_chatting_launcher_incoming_hawk_eye_view, null)
launcherIncomingView?.setOnClickListener { }
launcherIncomingView?.let { view ->
callIncomingAnswer = view.findViewById(R.id.module_carchatting_incoming_answer)
callIncomingRefuse = view.findViewById(R.id.module_carchatting_incoming_hangUp)
callIncomingAnswer?.setOnClickListener {
releaseAudioAndVoice()
agreeIncomingBack.invoke()
}
callIncomingRefuse?.setOnClickListener {
releaseAudioAndVoice()
hangUpIncomingBack.invoke()
}
}
}
if (isLauncherIncomingViewShown) {
return
}
val params = FrameLayout.LayoutParams(
mContext!!.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_width)
.toInt(),
mContext!!.resources.getDimension(R.dimen.module_call_chat_state_incoming_hawk_eye_height)
.toInt()
)
val x = mContext!!.resources.getDimension(R.dimen.module_call_chat_state_location_hawk_eye_x)
val y = mContext!!.resources.getDimension(R.dimen.module_call_chat_state_location_hawk_eye_y)
params.leftMargin = x.toInt()
params.topMargin = y.toInt()
serviceApi?.windowManagerApi?.addView(launcherIncomingView, params, true)
isLauncherIncomingViewShown = true
Logger.d(CallChatCenter.TAG, "添加浮窗成功 addIncomingView===$isLauncherCallingViewShown")
}
}
fun showCallingView(
currentUserInfo: UserInfo?,
hangUpCallBack: () -> Unit
currentUserInfo: UserInfo?,
hangUpCallBack: () -> Unit
) {
Logger.d(CallChatCenter.TAG, "展示Launcher浮窗 showCallingView===$isLauncherCallingViewShown")
if (!isLauncherCallingViewShown) {
@@ -194,15 +267,18 @@ class CallingWindowManager private constructor() {
refreshCallWindowData(currentUserInfo)
}
} else {
Logger.d(CallChatCenter.TAG, "刷新Launcher浮窗数据 showCallingView===currentUserInfo :$currentUserInfo")
Logger.d(
CallChatCenter.TAG,
"刷新Launcher浮窗数据 showCallingView===currentUserInfo :$currentUserInfo"
)
refreshCallWindowData(currentUserInfo)
}
}
@SuppressLint("InflateParams")
private inline fun addCallWindowView(
crossinline hangUpCallBack: () -> Unit,
refreshData: (() -> Unit)
crossinline hangUpCallBack: () -> Unit,
refreshData: (() -> Unit)
) {
if (launcherCallingView == null) {
initView()
@@ -218,30 +294,51 @@ class CallingWindowManager private constructor() {
showCallingWindow()
refreshData.invoke()
isLauncherCallingViewShown = true
Logger.d(CallChatCenter.TAG, "添加浮窗成功 showCallingView===$isLauncherCallingViewShown")
Logger.d(CallChatCenter.TAG, "添加浮窗成功 addCallWindowView===$isLauncherCallingViewShown")
}
private fun refreshCallWindowData(currentUserInfo: UserInfo?) {
mContext?.let {
if (MogoApisHandler.getInstance().apis.statusManagerApi.isVrMode) {
GlideApp.with(it).load(currentUserInfo?.userHead)
.apply(RequestOptions.bitmapTransform(
GlideRoundedCornersTransform(20f, GlideRoundedCornersTransform.CornerType.LEFT)))
.placeholder(R.mipmap.module_carchatting_hawk_eye_default_head_img).into(callingHead!!)
.apply(
RequestOptions.bitmapTransform(
GlideRoundedCornersTransform(
20f,
GlideRoundedCornersTransform.CornerType.LEFT
)
)
)
.placeholder(R.mipmap.module_carchatting_hawk_eye_default_head_img)
.into(callingHead!!)
} else {
val options: RequestOptions =
RequestOptions()
.placeholder(R.mipmap.module_carchatting_default_head_img)
.error(R.mipmap.module_carchatting_default_head_img)
RequestOptions()
.placeholder(R.mipmap.module_carchatting_default_head_img)
.error(R.mipmap.module_carchatting_default_head_img)
GlideApp.with(it).asBitmap().load(currentUserInfo?.userHead)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(SkinAbleBitmapTarget(callingHead, options))
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(SkinAbleBitmapTarget(callingHead, options))
}
}
// callingNickName?.text = currentUserInfo?.userName ?: "蘑菇车主"
callingNickName?.text = "云平台" //todo 需要产品后面更改逻辑,避免写死造成困扰
}
fun hideIncomingView() {
if (!isLauncherIncomingViewShown) {
return
}
Logger.d(CallChatCenter.TAG, "隐藏Launcher来电浮窗===$isLauncherCallingViewShown")
releaseAudioAndVoice()
if (isLauncherIncomingViewShown) {
isLauncherIncomingViewShown = false
}
launcherIncomingView?.let {
serviceApi?.windowManagerApi?.removeView(it)
}
}
fun hideCallingView() {
Logger.d(CallChatCenter.TAG, "隐藏Launcher浮窗===$isLauncherCallingViewShown")
if (isLauncherCallingViewShown) {
@@ -259,9 +356,7 @@ class CallingWindowManager private constructor() {
}
private fun removeView() {
if (DebugConfig.getCarMachineType() != CAR_MACHINE_TYPE_BYD) {
serviceApi?.windowManagerApi?.removeView(launcherCallingView)
}
serviceApi?.windowManagerApi?.removeView(launcherCallingView)
}
fun updateTimer(timeStr: String) {
@@ -270,7 +365,10 @@ class CallingWindowManager private constructor() {
}
fun showVehicleTeamView() {
Logger.d(CallChatCenter.TAG, "showVehicleTeamView isLauncherCallingViewShown ===$isLauncherCallingViewShown")
Logger.d(
CallChatCenter.TAG,
"showVehicleTeamView isLauncherCallingViewShown ===$isLauncherCallingViewShown"
)
if (!isLauncherCallingViewShown) {
if (launcherCallingView == null) {
initView()
@@ -287,7 +385,10 @@ class CallingWindowManager private constructor() {
}
fun hideVehicleTeamView() {
Logger.d(CallChatCenter.TAG, "hideVehicleTeamView isLauncherCallingViewShown ===$isLauncherCallingViewShown")
Logger.d(
CallChatCenter.TAG,
"hideVehicleTeamView isLauncherCallingViewShown ===$isLauncherCallingViewShown"
)
callingView?.visibility = View.GONE
matchingView?.visibility = View.GONE
moduleCarchattingTeamRlView?.visibility = View.GONE
@@ -321,70 +422,90 @@ class CallingWindowManager private constructor() {
2 -> {
moduleCarchattingCivHead0?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[0].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead0!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead0!!)
moduleCarchattingCivHead1?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[1].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead1!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead1!!)
moduleCarchattingCivHead2?.visibility = View.GONE
moduleCarchattingCivHead3?.visibility = View.GONE
moduleCarchattingCivHead4?.visibility = View.GONE
val layoutParams: ConstraintLayout.LayoutParams = moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val layoutParams: ConstraintLayout.LayoutParams =
moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
layoutParams.bottomMargin = 0
moduleCarchattingTeamLlHead?.layoutParams = layoutParams
}
3 -> {
moduleCarchattingCivHead0?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[0].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead0!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead0!!)
moduleCarchattingCivHead1?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[1].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead1!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead1!!)
moduleCarchattingCivHead2?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[2].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead2!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead2!!)
moduleCarchattingCivHead3?.visibility = View.GONE
moduleCarchattingCivHead4?.visibility = View.GONE
val layoutParams: ConstraintLayout.LayoutParams = moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val layoutParams: ConstraintLayout.LayoutParams =
moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
layoutParams.bottomMargin = 0
moduleCarchattingTeamLlHead?.layoutParams = layoutParams
}
4 -> {
moduleCarchattingCivHead0?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[0].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead0!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead0!!)
moduleCarchattingCivHead1?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[1].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead1!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead1!!)
moduleCarchattingCivHead2?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[2].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead2!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead2!!)
moduleCarchattingCivHead3?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[3].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead3!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead3!!)
moduleCarchattingCivHead4?.visibility = View.INVISIBLE
val layoutParams: ConstraintLayout.LayoutParams = moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val margin = mContext!!.resources.getDimension(R.dimen.module_call_chat_team_head_view_top_margin)
val layoutParams: ConstraintLayout.LayoutParams =
moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val margin =
mContext!!.resources.getDimension(R.dimen.module_call_chat_team_head_view_top_margin)
layoutParams.bottomMargin = margin.toInt()
moduleCarchattingTeamLlHead?.layoutParams = layoutParams
}
else -> {
moduleCarchattingCivHead0?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[0].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead0!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead0!!)
moduleCarchattingCivHead1?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[1].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead1!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead1!!)
moduleCarchattingCivHead2?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[2].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead2!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead2!!)
moduleCarchattingCivHead3?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[3].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead3!!)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead3!!)
moduleCarchattingCivHead4?.visibility = View.VISIBLE
GlideApp.with(mContext!!).load(teamMember[4].headImgUrl)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop().into(moduleCarchattingCivHead4!!)
val layoutParams: ConstraintLayout.LayoutParams = moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val margin = mContext!!.resources.getDimension(R.dimen.module_call_chat_team_head_view_top_margin)
.placeholder(R.mipmap.module_carchatting_default_head_img).circleCrop()
.into(moduleCarchattingCivHead4!!)
val layoutParams: ConstraintLayout.LayoutParams =
moduleCarchattingTeamLlHead?.layoutParams as ConstraintLayout.LayoutParams
val margin =
mContext!!.resources.getDimension(R.dimen.module_call_chat_team_head_view_top_margin)
layoutParams.bottomMargin = margin.toInt()
moduleCarchattingTeamLlHead?.layoutParams = layoutParams
}
@@ -407,4 +528,37 @@ class CallingWindowManager private constructor() {
}
launcherCallingView = null
}
private fun releaseAudioAndVoice() {
stopAudioCall()
unRegisterVoice()
}
private fun playAudioCall() {
MediaController.startPlay(mContext!!, R.raw.call, true, AudioManager.STREAM_RING)
}
private fun stopAudioCall() {
log(TAG, "停止播放来电铃声======")
MediaController.release()
}
private fun registerIntentInComingCall() {
IMVoiceClient.registerIntentInComingCall(this)
}
private fun unRegisterVoice() {
IMVoiceClient.releaseSpeakAndRegisterCallback()
IMVoiceClient.unRegisterIntentInComingCall(this)
}
override fun onVoiceAnswerCall() {
releaseAudioAndVoice()
agreeIncomingBack?.invoke()
}
override fun onVoiceRefuseCall() {
releaseAudioAndVoice()
hangUpIncomingBack?.invoke()
}
}

View File

@@ -3,15 +3,12 @@ package com.mogo.module.carchatting.view
import android.content.Context
import android.graphics.Rect
import android.graphics.drawable.BitmapDrawable
import android.widget.ImageView
import com.mogo.chat.model.bean.TeammateInfo
import com.mogo.chat.provider.ServiceApi
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.map.marker.MogoMarkerOptions
import com.mogo.module.carchatting.R
import com.mogo.module.common.ModuleNames
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.entity.MarkerLocation
import com.mogo.module.common.entity.MarkerShowEntity
import com.mogo.service.IMogoServiceApis
@@ -51,11 +48,11 @@ class MapViewManager private constructor() {
}
fun showLocationOnMap(
context: Context,
serviceApi: IMogoServiceApis?,
lat: Double?,
lon: Double?,
userHead: String?
context: Context,
serviceApi: IMogoServiceApis?,
lat: Double?,
lon: Double?,
userHead: String?
) {
if (!hasMarked) {
hasMarked = true
@@ -65,23 +62,23 @@ class MapViewManager private constructor() {
private fun showLocation(
context: Context,
serviceApi: IMogoServiceApis?,
lat: Double?,
lon: Double?,
userHead: String?
context: Context,
serviceApi: IMogoServiceApis?,
lat: Double?,
lon: Double?,
userHead: String?
) {
//延时一分钟后获取大而全数据
serviceApi?.statusManagerApi?.setUserInteractionStatus(
CallChattingProviderConstant.CAR_CALL_PROVIDER,
true,
true
CallChattingProviderConstant.CAR_CALL_PROVIDER,
true,
true
)
//清除地图上所有Marker
serviceApi?.mapServiceApi?.getMarkerManager(context)?.removeMarkers()
//获取需要打点的经纬度
val userLoc =
serviceApi?.mapServiceApi?.getSingletonLocationClient(context)?.lastKnowLocation
serviceApi?.mapServiceApi?.getSingletonLocationClient(context)?.lastKnowLocation
val latlonList = mutableListOf<MogoLatLng>()
var currentLatLng: MogoLatLng? = null
userLoc?.let {
@@ -91,31 +88,31 @@ class MapViewManager private constructor() {
//打点传入type为在线车辆 并缩小地图区域
getMarkerEntity(context, lat, lon, userHead) { _: String, options: MogoMarkerOptions ->
val mapMarker =
serviceApi?.mapServiceApi?.getMarkerManager(context)?.addMarker(CALLING, options)
serviceApi?.mapServiceApi?.getMarkerManager(context)?.addMarker(CALLING, options)
mapMarker?.setClickable(false)
}
val mapUIController = serviceApi?.mapServiceApi?.mapUIController
mapUIController?.showBounds(
CallChattingProviderConstant.CAR_CALL_PROVIDER,
currentLatLng,
latlonList,
Rect(
context.resources.getDimension(R.dimen.dp_736).toInt(),
context.resources.getDimension(R.dimen.dp_198).toInt(),
context.resources.getDimension(R.dimen.dp_59).toInt(),
context.resources.getDimension(R.dimen.dp_59).toInt()
),
true
CallChattingProviderConstant.CAR_CALL_PROVIDER,
currentLatLng,
latlonList,
Rect(
context.resources.getDimension(R.dimen.dp_736).toInt(),
context.resources.getDimension(R.dimen.dp_198).toInt(),
context.resources.getDimension(R.dimen.dp_59).toInt(),
context.resources.getDimension(R.dimen.dp_59).toInt()
),
true
)
}
@Suppress("DEPRECATION")
private fun getMarkerEntity(
context: Context,
lat: Double?,
lon: Double?,
userHead: String?,
callBack: (markerType: String, options: MogoMarkerOptions) -> Unit
context: Context,
lat: Double?,
lon: Double?,
userHead: String?,
callBack: (markerType: String, options: MogoMarkerOptions) -> Unit
) {
val markerEntity = MarkerShowEntity()
val markerLoc = MarkerLocation()
@@ -129,16 +126,17 @@ class MapViewManager private constructor() {
markerLocation = markerLoc
}
val options = MogoMarkerOptions()
.`object`(markerEntity)
.icon((context.resources.getDrawable(R.mipmap.module_carchatting_caller) as BitmapDrawable).bitmap)
.latitude(markerEntity.markerLocation.lat)
.longitude(markerEntity.markerLocation.lon)
.`object`(markerEntity)
.icon((context.resources.getDrawable(R.mipmap.module_carchatting_caller) as BitmapDrawable).bitmap)
.latitude(markerEntity.markerLocation.lat)
.longitude(markerEntity.markerLocation.lon)
callBack.invoke(markerEntity.markerType, options)
}
fun resetMarkerStatus() {
fun resetMarkerStatus(serviceApi: IMogoServiceApis?) {
Logger.d(TAG, "resetMarkerStatus")
hasMarked = false
ServiceApi.mapService()?.getMarkerManager(AbsMogoApplication.getApp().applicationContext)?.removeMarkers(CALLING)
serviceApi?.mapServiceApi?.getMarkerManager(AbsMogoApplication.getApp().applicationContext)
?.removeMarkers(CALLING)
}
}

View File

@@ -1,29 +0,0 @@
package com.mogo.module.carchatting.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
public
/**
* @author congtaowang
* @since 2020/12/1
*
* 描述
*/
class UnSupportSkinFrameLayout extends FrameLayout {
public UnSupportSkinFrameLayout( Context context ) {
this( context, null );
}
public UnSupportSkinFrameLayout( Context context, @Nullable AttributeSet attrs ) {
this( context, attrs, 0 );
}
public UnSupportSkinFrameLayout( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
super( context, attrs, defStyleAttr );
}
}

View File

@@ -1,29 +0,0 @@
package com.mogo.module.carchatting.view;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
public
/**
* @author congtaowang
* @since 2020/12/1
*
* 描述
*/
class UnSupportSkinImageView extends AppCompatImageView {
public UnSupportSkinImageView( Context context ) {
this( context, null );
}
public UnSupportSkinImageView( Context context, @Nullable AttributeSet attrs ) {
this( context, attrs, 0 );
}
public UnSupportSkinImageView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
super( context, attrs, defStyleAttr );
}
}