diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt index 0daac0e268..1da862dc25 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt @@ -1,7 +1,12 @@ package com.mogo.och.bus.passenger.model import android.content.Context +import android.net.ConnectivityManager import android.os.Handler +import com.mogo.commons.module.intent.IMogoIntentListener +import com.mogo.commons.module.intent.IntentManager +import com.mogo.commons.voice.AIAssist +import com.mogo.commons.voice.IMogoVoiceCmdCallBack import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.MogoLocation @@ -17,7 +22,6 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManage import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.CoordinateUtils import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.NetworkUtils @@ -34,7 +38,6 @@ import com.mogo.och.bus.passenger.network.PM2ModelLoopManager import com.mogo.och.common.module.bean.AppConnectMsg import com.mogo.och.common.module.biz.network.OchCommonServiceCallback import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil -import com.mogo.och.common.module.voice.VoiceNotice.showNotice import mogo.telematics.pad.MessagePad import kotlin.math.abs @@ -103,6 +106,9 @@ class PM2DrivingModel private constructor() { //自动驾驶轨迹监听 CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener) + //网络监听 + IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener) + } fun releaseListener(){ @@ -126,6 +132,14 @@ class PM2DrivingModel private constructor() { mAutoStatusCallback = autoPilotStatusCallback } + private val mNetWorkIntentListener = IMogoIntentListener { intentStr, _ -> + if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) { + if (NetworkUtils.isConnected(mContext)) { + queryDriverOperationStatus() + } + } + } + private val mReceivedMsgListener: IReceivedMsgListener = object : IReceivedMsgListener{ override fun onReceivedMsg(type: Int, byteArray: ByteArray) {//接收司机端发来的信息 @@ -133,12 +147,40 @@ class PM2DrivingModel private constructor() { val msg = GsonUtils.fromJson(String(byteArray),AppConnectMsg::class.java) as AppConnectMsg Logger.d(TAG,"onReceivedMsg = "+GsonUtils.toJson(msg)) if (msg.isPlay){ //播报 - showNotice(msg.msg) + speakTTS(msg.msg) } } } } + private fun speakTTS(msg: String) { + +// var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager +// var mAudioAttributes = AudioAttributes.Builder() +// .setUsage(AudioAttributes.USAGE_MEDIA) //设置声音的用途 +// .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) //设置声音的类型 +// .build() +// var mAudioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) //设置焦点类型 +// .setAudioAttributes(mAudioAttributes) //设置声音属性 +// .setAcceptsDelayedFocusGain(false) //设置接受延迟获取焦点,需要设置OnAudioFocusChangeListener来监听焦点的获取 +// .build() +// mAudioManager.requestAudioFocus(mAudioFocusRequest) //抢占焦点 + + AIAssist.getInstance(mContext).speakTTSVoiceWithLevel(msg,AIAssist.LEVEL0,object : IMogoVoiceCmdCallBack{ + override fun onSpeakEnd(speakText: String?) { +// mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest) + } + + override fun onSpeakError(speakText: String?, errorMsg: String?) { +// mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest) + } + + override fun onSpeakSelectTimeOut(speakText: String?) { +// mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest) + } + }) + } + private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = object : IMoGoChassisLocationGCJ02Listener{ override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { @@ -293,6 +335,7 @@ class PM2DrivingModel private constructor() { && station.isLeaving && i + 1 < stations.size) { mDrivingInfoCallback?.updateStationsInfo(stations as MutableList, i + 1, false) if (mNextStationIndex != i + 1) { + d(TAG,"轨迹排查--开始行程") mTwoStationsRouts.clear() startRemainRouteInfo() } @@ -300,9 +343,6 @@ class PM2DrivingModel private constructor() { mNextStationIndex = i + 1 return } else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) { - if (i == 0) { -// startOrStopRouteAndWipe(false) - } mPreRouteIndex = 0 isGoingToNextStation = false startOrStopCalculateRouteInfo(false) @@ -419,17 +459,6 @@ class PM2DrivingModel private constructor() { } } } - if (mTwoStationsRouts.size > 0) { - val sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength( - mTwoStationsRouts - ) - mContext?.let { - SharedPrefsMgr.getInstance(it).putInt( - BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS, - sumLength.toInt() - ) - } - } } } diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt index 111a83ad40..9539d68dec 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt @@ -118,7 +118,9 @@ class PM2DrivingInfoFragment : } fun changeOperationStatus(status:Boolean){ - setLineInfoView(status) + if (!status){ + updateNoOrderUI() + } } fun showNoTaskView(haveTask: Boolean){ @@ -131,15 +133,19 @@ class PM2DrivingInfoFragment : line_during_tv.visibility = View.VISIBLE no_line_tv.visibility = View.GONE }else{ - line_name_tv.visibility = View.GONE - line_during_tv.visibility = View.GONE - no_line_tv.visibility = View.VISIBLE - updateNoStationView() - overMapView.clearSiteMarkers() - overMapView.clearCustomPolyline() + updateNoOrderUI() } } + private fun updateNoOrderUI() { + line_name_tv.visibility = View.GONE + line_during_tv.visibility = View.GONE + no_line_tv.visibility = View.VISIBLE + updateNoStationView() + overMapView.clearSiteMarkers() + overMapView.clearCustomPolyline() + } + private fun updateNoStationView(){ station_name_tv.setTextColor(resources.getColor(R.color.m2_no_line_tv_color)) station_name_title_tv.text = resources.getString(R.string.m2_p_station_title_tv) diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt index d800e4c770..393619a920 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -84,7 +84,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private fun addView(item: RotationItem) { if (item.type == 1) { // 表示视频 val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path) + videoView.setVideoPath(item.path,item.cacheImgPath) viewList.add(videoView) } else { // 表示图片 val imageView = AdvanceImageView(mContext) diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt index ceffd532b9..78d562a7c9 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt @@ -35,6 +35,7 @@ class AdvanceVideoView @JvmOverloads constructor( private var mOnCompletionListener: GSYSampleCallBack? = null private var downloadVideoName = "" private var fileNetPath: String? = "" + private var cacheImageUrl: String? = "" init { initView() @@ -69,10 +70,11 @@ class AdvanceVideoView @JvmOverloads constructor( videoRelativeLayout?.addView(videoViewPlayer, layoutParams) } - fun setVideoPath(path: String) { + fun setVideoPath(path: String,cacheImageUrl: String) { // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 this.fileNetPath = path + this.cacheImageUrl = cacheImageUrl val pathList = path.split("/") if (pathList.isNotEmpty()){ this.downloadVideoName = pathList[pathList.size - 1] @@ -83,22 +85,37 @@ class AdvanceVideoView @JvmOverloads constructor( private fun loadCacheImg() { // BitmapHelper.getVideoThumbnail(path) /*获取第一帧图*/ + cacheImage?.setImageResource(R.drawable.m2_p_video_holder) setCacheImageViewVisible() - Thread{ - var bitmap = BitmapHelper.getVideoThumbnail(fileNetPath) + Thread { + var bitmap = BitmapHelper.getVideoThumbnail(fileNetPath) Logger.d(ImageAndVideoRotation.TAG, "setVideoPath") ThreadUtils.runOnUiThread { Logger.d(ImageAndVideoRotation.TAG, "bitmap加载") cacheImage?.let { Glide.with(context).load(bitmap) .apply( - RequestOptions().placeholder(R.drawable.m2_p_video_holder).centerCrop() + RequestOptions().placeholder(R.drawable.m2_p_video_holder) + .error(R.drawable.m2_p_video_holder) + .fallback(R.drawable.m2_p_video_holder) + .centerCrop() ) .into(it) } - videoViewPlayer?.thumbImageView = cacheImage } }.start() +// Logger.d(ImageAndVideoRotation.TAG, "bitmap加载") +// cacheImage?.let { +// Glide.with(context).load(cacheImageUrl) +// .apply( +// RequestOptions().placeholder(R.drawable.m2_p_video_holder) +// .error(R.drawable.m2_p_video_holder) +// .fallback(R.drawable.m2_p_video_holder) +// .centerCrop() +// ) +// .into(it) +// } +// videoViewPlayer?.thumbImageView = cacheImage } fun clearLocalErrorVideo(){ @@ -110,11 +127,13 @@ class AdvanceVideoView @JvmOverloads constructor( @SuppressLint("CheckResult") fun setCacheImageViewVisible() { + videoViewPlayer?.thumbImageView = cacheImage videoViewPlayer?.setCacheImageViewVisible() } fun setCacheImageViewGone() { videoViewPlayer?.setCacheImageViewGone() + videoViewPlayer?.clearThumbImageView() } fun setVideo(onCompletionListener: GSYSampleCallBack) {