[M2] M2 UI 红绿灯,地图样式文件

This commit is contained in:
wangmingjun
2023-02-13 20:08:39 +08:00
parent 9f047648b7
commit d17c29d048
14 changed files with 284 additions and 89 deletions

View File

@@ -159,7 +159,7 @@ class PM2DrivingModel private constructor() {
object : OchCommonServiceCallback<PM2OperationStatusResponse> {
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)
}

View File

@@ -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) {

View File

@@ -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
}
}

View File

@@ -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()
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/m2_p_light_width"
android:layout_height="@dimen/m2_p_light_height"
android:visibility="visible">
<ImageView
android:id="@+id/m2_p_traffic_light_bg"
android:layout_width="@dimen/m2_p_light_width"
android:layout_height="@dimen/m2_p_light_height"
android:background="@drawable/bg_p_m2_auto_bg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/m2_p_traffic_light_iv"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_8"
android:scaleType="fitXY"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/m2_p_traffic_light_time_tv"
android:layout_width="@dimen/dp_12"
android:layout_height="match_parent"
android:textSize="@dimen/dp_22"
android:textStyle="bold"
android:textColor="@color/m2_light_tv_color"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -5,6 +5,14 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_556">
<!-- 全览地图带站点-->
<com.mogo.eagle.core.function.view.OverMapView
android:id="@+id/overMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapStyleExtraPath="@string/m2_over_map_style_extra_path"
app:mapStylePath="@string/m2_over_map_style_path" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img_drive_bg"
android:layout_width="@dimen/dp_290"
@@ -34,8 +42,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:textSize="@dimen/dp_18"
android:text="KM/H"
android:layout_marginBottom="@dimen/dp_16"
android:text="@string/m2_p_speed_unit_txt"
android:layout_marginBottom="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="@+id/speed_tv"
app:layout_constraintLeft_toRightOf="@+id/speed_tv" />
@@ -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" />
<!-- 红绿灯-->
<com.mogo.eagle.core.function.hmi.ui.widget.SingleTrafficLightView
android:id="@+id/traffic_light_view"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_38"
<com.mogo.och.bus.passenger.ui.widget.M2PTrafficLightView android:id="@+id/traffic_light_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@+id/turn_light_view"
app:layout_constraintTop_toTopOf="@+id/auto_tv" />
@@ -90,7 +97,7 @@
android:src="@drawable/m2_line_location_bg"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/task_name_tv"
android:id="@+id/line_name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
@@ -101,14 +108,26 @@
android:textColor="@color/m2_line_name_tv_color"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/task_during_tv"
android:id="@+id/no_line_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/m2_p_no_line"
android:textSize="@dimen/dp_24"
app:layout_constraintTop_toTopOf="@+id/img_line_location_bg"
app:layout_constraintBottom_toBottomOf="@+id/img_line_location_bg"
app:layout_constraintLeft_toLeftOf="@+id/speed_tv"
android:textColor="@color/m2_no_line_tv_color"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/line_during_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:textSize="@dimen/dp_18"
android:text="--"
app:layout_constraintLeft_toLeftOf="@+id/task_name_tv"
app:layout_constraintTop_toBottomOf="@+id/task_name_tv"
app:layout_constraintLeft_toLeftOf="@+id/line_name_tv"
app:layout_constraintTop_toBottomOf="@+id/line_name_tv"
android:textColor="@color/m2_line_during_tv_color"/>
<androidx.appcompat.widget.AppCompatImageView
@@ -151,12 +170,4 @@
android:text="--"
android:textColor="@color/m2_line_during_tv_color"/>
<!-- 全览地图带站点-->
<com.mogo.eagle.core.function.view.OverMapView
android:id="@+id/overMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -7,6 +7,8 @@
<color name="m2_line_name_tv_color">#0B1E38</color>
<color name="m2_line_during_tv_color">#5D7199</color>
<color name="m2_current_time_tv_color">#0B1E38</color>
<color name="m2_no_line_tv_color">#6B7EA6</color>
<color name="m2_light_tv_color">#2D3E5F</color>
<color name="bus_traffic_light_red_color_up">#FFFFA28B</color>
<color name="bus_traffic_light_red_color_down">#FFDA1100</color>

View File

@@ -1,61 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="bus_p_route_info_panel_width">700dp</dimen>
<dimen name="bus_p_auto_icon_margin_top">40dp</dimen>
<dimen name="bus_p_route_info_margin_right">40dp</dimen>
<dimen name="bus_p_route_info_margin_left">40dp</dimen>
<dimen name="bus_p_route_info_margin_bottom">40dp</dimen>
<dimen name="bus_p_route_info_margin_top">110dp</dimen>
<dimen name="bus_p_route_line_info_height">224dp</dimen>
<dimen name="bus_p_route_line_map_view_height">510dp</dimen>
<dimen name="bus_p_route_line_dividing_view_height">3dp</dimen>
<dimen name="bus_p_route_traffic_light_view_width">158dp</dimen>
<dimen name="bus_p_route_traffic_light_view_height">90dp</dimen>
<dimen name="bus_p_route_traffic_light_view_corner">45dp</dimen>
<dimen name="bus_p_traffic_light_bg_width">158dp</dimen>
<dimen name="bus_p_traffic_light_bg_height">90dp</dimen>
<dimen name="bus_p_traffic_light_time_size">45dp</dimen>
<dimen name="bus_p_traffic_light_time_view_width">90dp</dimen>
<dimen name="bus_p_traffic_light_icon_size">90dp</dimen>
<dimen name="bus_p_traffic_light_bg_stroke_width">3dp</dimen>
<dimen name="bus_p_route_dividing_line2_margin_top">224dp</dimen>
<dimen name="bus_p_driver_number_plate_margin_top">50dp</dimen>
<dimen name="bus_p_driver_number_plate_margin_bottom">50dp</dimen>
<dimen name="bus_p_driver_number_plate_size">44dp</dimen>
<dimen name="bus_p_line_operation_time_margin_top">130dp</dimen>
<dimen name="bus_p_line_operation_time_size">38dp</dimen>
<dimen name="bus_p_no_data_size">36dp</dimen>
<dimen name="bus_p_speed_txt_size">110dp</dimen>
<dimen name="bus_p_speed_unit_txt_size">42dp</dimen>
<dimen name="bus_p_station_circle_borner_size">4dp</dimen>
<dimen name="bus_p_station_circle_radius_size">10dp</dimen>
<dimen name="bus_p_station_circle_width_height">20dp</dimen>
<dimen name="bus_p_station_tag_width_height">60dp</dimen>
<dimen name="bus_p_station_tag_radius_size">30dp</dimen>
<dimen name="bus_p_cur_station_circle_width">20dp</dimen>
<dimen name="bus_p_cur_station_circle_height">50dp</dimen>
<dimen name="bus_p_mid_station_circle_cor">6dp</dimen>
<dimen name="bus_p_station_txt_size">50dp</dimen>
<dimen name="bus_p_station_tag_txt_size">36dp</dimen>
<dimen name="bus_p_station_item_height">80dp</dimen>
<dimen name="bus_p_station_item_middle_height">100dp</dimen>
<dimen name="bus_p_station_tag_line_height">80dp</dimen>
<dimen name="bus_p_station_tag_line_height1">60dp</dimen>
<dimen name="bus_p_station_tag_line_width">6dp</dimen>
<dimen name="bus_p_curent_station_panel_width">685dp</dimen>
<dimen name="bus_p_curent_station_panel_height">309dp</dimen>
<dimen name="bus_p_curent_station_panel_margin">50dp</dimen>
<dimen name="bus_p_curent_station_panel_margin_left">10dp</dimen>
<dimen name="bus_p_curent_station_txt_size">44dp</dimen>
<dimen name="bus_p_curent_station_txt_size1">55dp</dimen>
<dimen name="bus_p_curent_station_tip_size1">40dp</dimen>
<dimen name="bus_p_curent_station_txt_width">584dp</dimen>
<dimen name="bus_p_station_txt_width">550dp</dimen>
<dimen name="m2_p_light_width">60dp</dimen>
<dimen name="m2_p_light_height">40dp</dimen>
</resources>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="bus_p_speed_unit_txt">KM/H</string>
<string name="m2_p_speed_unit_txt">KM/H</string>
<string name="bus_p_no_out">您已收车</string>
<string name="bus_p_no_task">暂无班次</string>
<string name="m2_p_no_line">暂无路线</string>
<string name="bus_p_start_station_txt_tag"></string>
<string name="bus_p_end_station_txt_tag"></string>
<string name="bus_p_cur_station_title">到达站:</string>
@@ -10,4 +10,9 @@
<string name="bus_p_cur_station_title_init">始发站:</string>
<string name="bus_p_cur_station_arrived_tip">请携带好随身物品下车。</string>
<string name="bus_p_cur_station_arrived_tip_init">欢迎乘坐蘑菇车联自动驾驶车。</string>
<string name="m2_over_map_style_path">src/m2/assets/m2_map_style.data</string>
<string name="m2_over_map_style_extra_path">src/m2/assets/m2_map_style_extra.data</string>
<string name="m2_p_auto_tv">Auto</string>
</resources>