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 00f84ecbd1..6ed8a78a8a 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 @@ -33,7 +34,7 @@ import mogo.telematics.pad.MessagePad class PM2DrivingModel private constructor() { private var mContext: Context? = null - private var mLocation: MessagePad.GnssInfo? = null + private var mLocation: MogoLocation? = null private var mRoutePoints = mutableListOf() private var routesResult: PM2RoutesResult? = null @@ -73,27 +74,35 @@ 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 } private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = - object : IMoGoChassisLocationGCJ02Listener { - override fun onChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) { - if (null == gnssInfo) return - mLocation = gnssInfo - updateSpeed() + object : IMoGoChassisLocationGCJ02Listener{ + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + if (null == mogoLocation) return + mLocation = mogoLocation + 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/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt new file mode 100644 index 0000000000..481fc4b080 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt @@ -0,0 +1,31 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.content.Context +import android.util.AttributeSet +import android.widget.ImageView +import android.widget.RelativeLayout +import com.bumptech.glide.Glide + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class AdvanceImageView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + private var imageView: ImageView? = null + + init { + initView() + } + + private fun initView() { + imageView = ImageView(context) + imageView?.scaleType = ImageView.ScaleType.FIT_XY + addView(imageView, LayoutParams(-1,-1)) + } + + public fun setImagePath(path: String){ + imageView?.let { Glide.with(context).load(path).into(it) } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..496460d091 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -0,0 +1,30 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.view.View +import androidx.viewpager.widget.PagerAdapter + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class AdvancePagerAdapter: PagerAdapter() { + override fun getCount(): Int { + TODO("Not yet implemented") + } + + override fun isViewFromObject(view: View, `object`: Any): Boolean { + TODO("Not yet implemented") + } + + public fun setData(list: MutableList){ + + } + + public fun setPause(){ + + } + + public fun setResume(){ + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt new file mode 100644 index 0000000000..b323b4795d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt @@ -0,0 +1,42 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.content.Context +import android.util.AttributeSet +import android.widget.RelativeLayout +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class ImageAndVideoRotation @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var viewPager: ViewPager? = null + private var pagerAdapter: AdvancePagerAdapter? = null + + init { + initView() + } + + private fun initView() { + viewPager = ViewPager(context) + pagerAdapter = AdvancePagerAdapter() + viewPager?.adapter = pagerAdapter + addView(viewPager, LayoutParams(-1,-1)) + } + + public fun setData(list: MutableList){ + pagerAdapter?.setData(list) + } + + public fun setPause(){ + pagerAdapter?.setPause() + } + + public fun setResume(){ + pagerAdapter?.setResume() + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt new file mode 100644 index 0000000000..14479133a8 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +data class RotationItem(var path: String, var type: String) \ No newline at end of file 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