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 7957587ced..be227c4148 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 @@ -25,6 +25,7 @@ import com.mogo.och.bus.passenger.network.PM2ModelLoopManager import com.mogo.och.common.module.biz.network.OchCommonServiceCallback import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil import mogo.telematics.pad.MessagePad +import kotlin.math.abs /** * @author: wangmingjun @@ -73,12 +74,18 @@ class PM2DrivingModel private constructor() { CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener) // 定位监听 - CallerChassisLocationGCJ20ListenerManager.addListener(TAG, - mMapLocationListener - ) + CallerChassisLocationGCJ20ListenerManager.addListener(TAG, mMapLocationListener) } - fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback){ + public fun releaseListener(){ + //自动驾驶状态监听 + CallerAutoPilotStatusListenerManager.removeListener(TAG) + + // 定位监听 + CallerChassisLocationGCJ20ListenerManager.removeListener(TAG) + } + + fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){ mDrivingInfoCallback = drivingInfoCallback } @@ -87,14 +94,16 @@ class PM2DrivingModel private constructor() { override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { if (null == mogoLocation) return mLocation = mogoLocation - updateSpeed() + updateSpeed(mogoLocation) } } - private fun updateSpeed() { - //todo 传入速度 - mDrivingInfoCallback?.updateSpeed(0) + private fun updateSpeed(mogoLocation: MogoLocation) { + // km/h + val speedKM = (abs(mogoLocation.gnssSpeed) * 3.6f).toInt() + + mDrivingInfoCallback?.updateSpeed(speedKM) } private val mAutoPilotStatusListener: IMoGoAutopilotStatusListener = diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt index 617813db9b..78d188a64e 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt @@ -1,7 +1,61 @@ package com.mogo.och.bus.passenger.presenter +import androidx.lifecycle.LifecycleOwner import com.mogo.commons.mvp.Presenter +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.callback.DrivingInfoCallback +import com.mogo.och.bus.passenger.model.PM2DrivingModel import com.mogo.och.bus.passenger.ui.PM2DrivingInfoFragment class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) : - Presenter(view) \ No newline at end of file + Presenter(view), DrivingInfoCallback { + + init { + PM2DrivingModel.INSTANCE.init(context) + initListener() + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + PM2DrivingModel.INSTANCE.releaseListener() + } + + private fun initListener(){ + PM2DrivingModel.INSTANCE.setDrivingInfoCallback(this) + } + + private fun destroyListener(){ + PM2DrivingModel.INSTANCE.setDrivingInfoCallback(null) + } + + override fun updateSpeed(speed: Int) { + UiThreadHandler.post { + mView?.updateSpeed(speed) + } + } + + override fun updatePlateNumber(carNum: String) { + UiThreadHandler.post { + mView?.updateCarPlateNum(carNum) + } + } + + override fun updateLine(lineName: String, lineDuring: String) { + UiThreadHandler.post { + mView?.updateTaskName(lineName) + mView?.updateTaskDuringTime(lineDuring) + } + } + + override fun updateRemainMT(meters: Long, timeInSecond: Long) { + TODO("Not yet implemented") + } + + override fun changeOperationStatus(loginStatus: Boolean) { + TODO("Not yet implemented") + } + + override fun showNoTaskView(isTrue: Boolean) { + TODO("Not yet implemented") + } +} \ No newline at end of file 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 e26df7d504..066aeec53a 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 @@ -48,6 +48,30 @@ class PM2DrivingInfoFragment : overMapView.onDestroy() } + fun updateSpeed(speed: Int){ + speed_tv.text = speed.toString() + } + + fun updateCarPlateNum(plateNum : String){ + car_plate_tv.text = plateNum + } + + fun updateTaskName(name: String){ + task_name_tv.text = name + } + + fun updateTaskDuringTime(time : String){ + task_during_tv.text = time + } + + fun updateCurrentTime(){ +// current_time_tv.text = +// current_weekday_tv.text = + } + + fun changeOperationStatus(status:Boolean){ + } + override fun createPresenter(): PM2DrivingPresenter { return PM2DrivingPresenter(this) } diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml index f6f684c318..8f1e26ea45 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml @@ -4,29 +4,141 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + android:padding="@dimen/dp_30"> - - + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_width="0dp" + android:layout_height="@dimen/dp_600" + app:layout_constraintLeft_toRightOf="@+id/driving_view" + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file