From f8cb2e4389fbcf62eb2317fc8badf9eb49299d80 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Mon, 6 Feb 2023 16:14:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[M2]=20M2=20=E5=AE=9A=E4=BD=8D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/och/bus/passenger/model/PM2DrivingModel.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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..7957587ced 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 @@ -33,7 +33,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 @@ -83,14 +83,15 @@ class PM2DrivingModel private constructor() { } private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = - object : IMoGoChassisLocationGCJ02Listener { - override fun onChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) { - if (null == gnssInfo) return - mLocation = gnssInfo + object : IMoGoChassisLocationGCJ02Listener{ + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + if (null == mogoLocation) return + mLocation = mogoLocation updateSpeed() } - } + + } private fun updateSpeed() { //todo 传入速度 mDrivingInfoCallback?.updateSpeed(0) From eb929dec0043d866a52745d23047c124e09572e3 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Mon, 6 Feb 2023 19:38:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[M2]=20M2=20=E8=A1=8C=E7=A8=8B=E4=BF=A1?= =?UTF-8?q?=E6=81=AFUI=E5=88=9D=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bus/passenger/model/PM2DrivingModel.kt | 25 ++- .../presenter/PM2DrivingPresenter.kt | 56 ++++++- .../passenger/ui/PM2DrivingInfoFragment.kt | 24 +++ .../res/layout/p_m2_driving_info_fragment.xml | 144 ++++++++++++++++-- 4 files changed, 224 insertions(+), 25 deletions(-) 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 From bf171e25bd0761ff4d0ff23386d965bedab5cd13 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Mon, 6 Feb 2023 21:01:23 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[M2]=20M2=20=E5=9B=BE=E7=89=87+=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=BD=AE=E6=92=ADopt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bus/passenger/model/PM2DrivingModel.kt | 3 +- .../ui/widget/video/AdvanceImageView.kt | 31 ++++++++++++++ .../ui/widget/video/AdvancePagerAdapter.kt | 30 +++++++++++++ .../ui/widget/video/ImageAndVideoRotation.kt | 42 +++++++++++++++++++ .../passenger/ui/widget/video/RotationItem.kt | 7 ++++ 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt create mode 100644 OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt create mode 100644 OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt create mode 100644 OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt 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 be227c4148..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 @@ -96,9 +96,8 @@ class PM2DrivingModel private constructor() { mLocation = mogoLocation updateSpeed(mogoLocation) } - - } + private fun updateSpeed(mogoLocation: MogoLocation) { // km/h val speedKM = (abs(mogoLocation.gnssSpeed) * 3.6f).toInt() 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