diff --git a/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data new file mode 100644 index 0000000000..4e4bb6709d Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data new file mode 100644 index 0000000000..3ce2c92d11 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data differ 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 3b05d79aa0..e5dd305e5b 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 @@ -159,7 +159,7 @@ class PM2DrivingModel private constructor() { object : OchCommonServiceCallback { override fun onSuccess(data: PM2OperationStatusResponse?) { if (data?.data == null) return - mDrivingInfoCallback?.changeOperationStatus(data.data.driverStatus === 1) + mDrivingInfoCallback?.changeOperationStatus(data.data.driverStatus == 1) mDrivingInfoCallback?.updatePlateNumber(data.data.plateNumber) } 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 825ee65c8d..1c9f06a422 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 @@ -54,11 +54,15 @@ class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) : } override fun changeOperationStatus(loginStatus: Boolean) { - TODO("Not yet implemented") + UiThreadHandler.post { + mView?.changeOperationStatus(loginStatus) + } } override fun showNoTaskView(isTrue: Boolean) { - TODO("Not yet implemented") + UiThreadHandler.post { + mView?.showNoTaskView(!isTrue) + } } override fun updateAutoStatus(isOpen: Boolean) { 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 d7dcdd3041..9b8c4737c8 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 @@ -1,12 +1,12 @@ package com.mogo.och.bus.passenger.ui import android.os.Bundle +import android.view.View import androidx.core.content.ContextCompat import com.mogo.commons.mvp.MvpFragment import com.mogo.eagle.core.utilcode.util.DateTimeUtils import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.presenter.PM2DrivingPresenter -import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.common.module.utils.DateTimeUtil.* import kotlinx.android.synthetic.m2.p_m2_driving_info_fragment.* @@ -30,6 +30,7 @@ class PM2DrivingInfoFragment : } override fun initViews() { + updateCurrentTime() } override fun initViews(savedInstanceState: Bundle?) { @@ -61,14 +62,14 @@ class PM2DrivingInfoFragment : } fun updateTaskName(name: String){ - task_name_tv.text = name + line_name_tv.text = name } fun updateTaskDuringTime(time : String){ - task_during_tv.text = time + line_during_tv.text = time } - fun updateCurrentTime(){ + private fun updateCurrentTime(){ current_time_tv.text = formatCalendarToString( DateTimeUtils.getCurrentDateTime(),HH_mm) @@ -76,15 +77,27 @@ class PM2DrivingInfoFragment : DateTimeUtils.getCurrentDateTime(), yyyy_MM_dd) val weekDay = DateTimeUtils.getWeekDayFromCalendar1(DateTimeUtils.getCurrentDateTime()) current_weekday_tv.text = "$date $weekDay" - + } fun changeOperationStatus(status:Boolean){ - if (!status){ //暂无路线 + setLineInfoView(status) + } + fun showNoTaskView(haveTask: Boolean){ + setLineInfoView(haveTask) + } + + private fun setLineInfoView(isShow: Boolean){ + if (isShow){ + line_name_tv.visibility = View.VISIBLE + 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 } } diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt new file mode 100644 index 0000000000..44bf647750 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt @@ -0,0 +1,179 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.function.api.v2x.IMoGoTrafficLightListener +import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.m2.m2_p_traffic_light_view.view.* + +/** + * bus乘客端:红绿灯view + * + * Created on 2022/3/14 + */ +class M2PTrafficLightView @JvmOverloads constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener { + + companion object { + private const val TAG = "M2PTrafficLightView" + } + + private var mCurrentLightId = TrafficLightEnum.BLACK + + init { + init(context) + } + + private fun init(context: Context?) { + LayoutInflater.from(context).inflate(R.layout.m2_p_traffic_light_view, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTrafficLightListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTrafficLightListenerManager.removeListener(TAG) + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + * @param lightSource 1:云端下发;2:自车感知 + */ + override fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) { + super.showTrafficLight(checkLightId, lightSource) + mCurrentLightId = checkLightId + updateTrafficLightIcon(checkLightId) + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + override fun disableTrafficLight() { + super.disableTrafficLight() + UiThreadHandler.post { + mCurrentLightId = TrafficLightEnum.BLACK + this@M2PTrafficLightView.visibility = GONE + } + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum) + resetView() + when (mCurrentLightId) { + TrafficLightEnum.RED -> changeCountdownRed(redNum) + TrafficLightEnum.YELLOW -> changeCountdownYellow(yellowNum) + TrafficLightEnum.GREEN -> changeCountdownGreen(greenNum) + else -> UiThreadHandler.post { m2_p_traffic_light_time_tv.text = "" } + } + } + + override fun changeCountdownRed(redNum: Int) { + super.changeCountdownRed(redNum) + UiThreadHandler.post { + if (redNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = redNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownGreen(greenNum: Int) { + super.changeCountdownGreen(greenNum) + UiThreadHandler.post { + if (greenNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = greenNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownYellow(yellowNum: Int) { + super.changeCountdownYellow(yellowNum) + UiThreadHandler.post { + if (yellowNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = yellowNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private fun updateTrafficLightIcon(lightId: TrafficLightEnum) { + UiThreadHandler.post { + when (lightId) { + TrafficLightEnum.RED -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_red_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.YELLOW -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_yellow_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.GREEN -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_green_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + else -> this@M2PTrafficLightView.visibility = GONE + } + } + } + + override fun disableTrafficLightCountDown() { + super.disableTrafficLightCountDown() + UiThreadHandler.post { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.dp_40).toInt() + setLayoutParams(lp) + m2_p_traffic_light_time_tv.visibility = GONE + m2_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.dp_40).toInt() + } + } + } + + private fun resetView() { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.m2_p_light_width).toInt() + setLayoutParams(lp) + m2_p_traffic_light_time_tv.visibility = VISIBLE + m2_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.m2_p_light_width).toInt() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png new file mode 100644 index 0000000000..3135524a79 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png new file mode 100644 index 0000000000..e873c2b85e Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png new file mode 100644 index 0000000000..8046782601 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml new file mode 100644 index 0000000000..7762402143 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml @@ -0,0 +1,37 @@ + + + + + + + + + + \ 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 6120ab8f89..05b1b51d32 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 @@ -5,6 +5,14 @@ android:layout_width="match_parent" android:layout_height="@dimen/dp_556"> + + + @@ -45,7 +53,7 @@ android:layout_height="@dimen/dp_38" android:background="@drawable/bg_p_m2_auto_bg" android:layout_marginTop="@dimen/dp_12" - android:text="Auto" + android:text="@string/m2_p_auto_tv" android:textSize="@dimen/dp_18" android:gravity="center" android:textColor="@color/m2_button_auto_tv_color" @@ -62,10 +70,9 @@ app:layout_constraintTop_toTopOf="@+id/auto_tv" /> - @@ -90,7 +97,7 @@ android:src="@drawable/m2_line_location_bg"/> + + - - - \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml index e17de7a855..19447f7f10 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml @@ -7,6 +7,8 @@ #0B1E38 #5D7199 #0B1E38 + #6B7EA6 + #2D3E5F #FFFFA28B #FFDA1100 diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml index e738022b0d..ca8e0dcfc1 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml @@ -1,61 +1,5 @@ - 700dp - 40dp - 40dp - 40dp - 40dp - 110dp - 224dp - 510dp - 3dp - - 158dp - 90dp - 45dp - 158dp - 90dp - 45dp - 90dp - 90dp - 3dp - - 224dp - 50dp - 50dp - 44dp - 130dp - 38dp - - 36dp - - 110dp - 42dp - - 4dp - 10dp - 20dp - 60dp - 30dp - 20dp - 50dp - 6dp - 50dp - 36dp - 80dp - 100dp - 80dp - 60dp - 6dp - - 685dp - 309dp - 50dp - 10dp - 44dp - 55dp - 40dp - - 584dp - 550dp + 60dp + 40dp \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml index e98feed5f5..47672a2416 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml @@ -1,8 +1,8 @@ - KM/H + KM/H 您已收车 - 暂无班次 + 暂无路线 到达站: @@ -10,4 +10,9 @@ 始发站: 请携带好随身物品下车。 欢迎乘坐蘑菇车联自动驾驶车。 + + src/m2/assets/m2_map_style.data + src/m2/assets/m2_map_style_extra.data + Auto + \ No newline at end of file