[Bus/Taxi d 2.6.5]Bus/Taxi:更新红绿灯呈现(同Taxi乘客屏)

This commit is contained in:
pangfan
2022-03-29 16:24:02 +08:00
parent d9acd80761
commit a1ceff95d9
42 changed files with 766 additions and 5 deletions

View File

@@ -39,6 +39,7 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.och.bus.R;
import com.mogo.och.bus.ui.BusTrafficLightView;
import com.mogo.och.bus.view.BusArcView;
import com.mogo.och.bus.view.SlidePanelView;
@@ -69,6 +70,7 @@ public abstract class BaseOchBusTabFragment<V extends IView, P extends Presenter
private FrameLayout flSpeed;
private BusArcView mouduleArc;
private ImageView mUpgradeTipIv;
private BusTrafficLightView mTrafficLightView;
public static final String TYPE_ENTRANCE = "entrance";
@@ -105,6 +107,9 @@ public abstract class BaseOchBusTabFragment<V extends IView, P extends Presenter
ctvAutopilotStatusTv = findViewById(R.id.bus_autopolot_btn_tv);
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
mTrafficLightView = findViewById(R.id.bus_traffic_light_view);
CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);

View File

@@ -0,0 +1,165 @@
package com.mogo.och.bus.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.bus.R;
import org.jetbrains.annotations.Nullable;
/**
* Bus司机端红绿灯view
*
* Created on 2022/3/29
*/
public class BusTrafficLightView extends IViewTrafficLight {
private ImageView mLightIconIV;
private GradientTextView mLightTimeTV;
private int mCurrentLightId;
public BusTrafficLightView(@Nullable Context context) {
this(context, null, 0);
}
public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
LayoutInflater.from(context).inflate(R.layout.bus_traffic_light_view, this, true);
mLightIconIV = findViewById(R.id.bus_traffic_light_iv);
mLightTimeTV = findViewById(R.id.bus_traffic_light_time_tv);
}
/**
* 展示红绿灯预警
*
* @param checkLightId 0-都是默认1-红2-黄3-绿
*/
@Override
public void showWarningTrafficLight(int checkLightId) {
super.showWarningTrafficLight(checkLightId);
mCurrentLightId = checkLightId;
updateTrafficLightIcon(checkLightId);
}
/**
* 关闭红绿灯预警展示,并重制灯态
*/
@Override
public void disableWarningTrafficLight() {
super.disableWarningTrafficLight();
UiThreadHandler.post(() -> {
mCurrentLightId = 0;
BusTrafficLightView.this.setVisibility(GONE);
});
}
/**
* @param redNum 红灯倒计时
* @param yellowNum 黄灯倒计时
* @param greenNum 绿灯倒计时
*/
@Override
public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) {
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum);
switch (mCurrentLightId) {
case 1:
changeCountdownRed(redNum);
break;
case 2:
changeCountdownYellow(yellowNum);
break;
case 3:
changeCountdownGreen(greenNum);
break;
default:
UiThreadHandler.post(() -> {
mLightTimeTV.setText("");
});
break;
}
}
@Override
public void changeCountdownRed(int redNum) {
super.changeCountdownRed(redNum);
UiThreadHandler.post(() -> {
if (redNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_red_color_up),
getResources().getColor(R.color.bus_traffic_light_red_color_down)});
mLightTimeTV.setText(String.valueOf(redNum));
} else {
mLightTimeTV.setText("");
}
});
}
@Override
public void changeCountdownGreen(int greenNum) {
super.changeCountdownGreen(greenNum);
UiThreadHandler.post(() -> {
if (greenNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_green_color_up),
getResources().getColor(R.color.bus_traffic_light_green_color_down)});
mLightTimeTV.setText(String.valueOf(greenNum));
} else {
mLightTimeTV.setText("");
}
});
}
@Override
public void changeCountdownYellow(int yellowNum) {
super.changeCountdownYellow(yellowNum);
UiThreadHandler.post(() -> {
if (yellowNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_yellow_color_up),
getResources().getColor(R.color.bus_traffic_light_yellow_color_down)});
mLightTimeTV.setText(String.valueOf(yellowNum));
} else {
mLightTimeTV.setText("");
}
});
}
/**
* 更新红绿灯icon
*
* @param lightId 0-都是默认1-红2-黄3-绿
*/
private void updateTrafficLightIcon(int lightId) {
UiThreadHandler.post(() -> {
switch (lightId) {
case 1:
mLightIconIV.setBackgroundResource(R.drawable.bus_light_red_nor);
BusTrafficLightView.this.setVisibility(VISIBLE);
break;
case 2:
mLightIconIV.setBackgroundResource(R.drawable.bus_lightyellow_nor);
BusTrafficLightView.this.setVisibility(VISIBLE);
break;
case 3:
mLightIconIV.setBackgroundResource(R.drawable.bus_light_green_nor);
BusTrafficLightView.this.setVisibility(VISIBLE);
break;
default:
BusTrafficLightView.this.setVisibility(GONE);
break;
}
});
}
}

View File

@@ -0,0 +1,113 @@
package com.mogo.och.bus.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
/**
* @author: wangmingjun
* @date: 2022/3/22
*/
public class GradientTextView extends AppCompatTextView {
private LinearGradient mLinearGradient;
private Paint mPaint;
private int mViewWidth = 0;//文字的宽度
private int mViewHeight = 0;//文字的高度
private Rect mTextBound = new Rect();
private int[] mColorList;//存放颜色的数组
private boolean isVertrial;//默认是横向
private float mRadius;
private float mdx;
private float mdy;
private int mColor;
public GradientTextView(Context context) {
this(context, null);
}
public GradientTextView(Context context,
AttributeSet attrs) {
super(context, attrs);
//设置默认的颜色
mColorList = new int[]{0xFFFFFFFF, 0xFFFFFFF};
}
@Override
protected void onDraw(Canvas canvas) {
if (isVertrial) {
mViewHeight = getMeasuredHeight();
} else {
mViewWidth = getMeasuredWidth();
}
mPaint = getPaint();
String mTipText = getText().toString();
setStyle();
mPaint.getTextBounds(mTipText, 0, mTipText.length(), mTextBound);
mPaint.setShadowLayer(mRadius, mdx, mdy, mColor);
//画出文字
canvas.drawText(mTipText, getMeasuredWidth() / 2 - mTextBound.width() / 2, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint);
}
/**
* true表示纵向渐变,false变身横向渐变
*
* @param vertrial
*/
public void setVertrial(boolean vertrial) {
isVertrial = vertrial;
}
/**
* 设置渐变的颜色
*
* @param mColorList
*/
public void setmColorList(int[] mColorList) {
if (mColorList != null && mColorList.length < 2) {
throw new RuntimeException("ClorList's length must be > 2");
} else {
this.mColorList = mColorList;
}
}
public void setStyle() {
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setFilterBitmap(true);
//前面4个参数分别表示渐变的开始x轴,开始y轴,结束的x轴,结束的y轴,mcolorList表示渐变的颜色数组
mLinearGradient = new LinearGradient(0, 0, mViewWidth, mViewHeight, mColorList, null, Shader.TileMode.CLAMP);
mPaint.setShader(mLinearGradient);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
/**
* 设置投影层
* @param radius
* @param dx
* @param dy
* @param color
*/
public void setShadowLayerCustom(float radius, float dx, float dy, int color) {
this.mRadius = radius;
this.mdx = dx;
this.mdy = dy;
this.mColor = color;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff000000"/>
<corners android:radius="@dimen/bus_traffic_light_layout_corner"/>
</shape>

View File

@@ -230,4 +230,13 @@
app:constraint_referenced_ids="btnAutopilotArrive,btnAutopilotDisable,btnAutopilotEnable,btnAutopilotRunning"
tools:visibility="visible" />
<com.mogo.och.bus.ui.BusTrafficLightView
android:id="@+id/bus_traffic_light_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="@dimen/bus_traffic_light_layout_margin_right"
android:layout_marginTop="@dimen/bus_traffic_light_layout_margin_top"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,35 @@
<?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/bus_traffic_light_layout_width"
android:layout_height="@dimen/bus_traffic_light_layout_height"
android:visibility="visible">
<ImageView
android:layout_width="@dimen/bus_traffic_light_bg_width"
android:layout_height="@dimen/bus_traffic_light_bg_height"
android:background="@drawable/bg_bus_traffic_light_background"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="@dimen/bus_traffic_light_bg_margin_left"
android:layout_marginTop="@dimen/bus_traffic_light_bg_margin_top"/>
<ImageView
android:id="@+id/bus_traffic_light_iv"
android:layout_width="@dimen/bus_traffic_light_icon_size"
android:layout_height="@dimen/bus_traffic_light_icon_size"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.mogo.och.bus.ui.GradientTextView
android:id="@+id/bus_traffic_light_time_tv"
android:layout_width="@dimen/bus_traffic_light_time_view_width"
android:layout_height="match_parent"
android:textSize="@dimen/bus_traffic_light_time_size"
android:textStyle="bold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -124,4 +124,16 @@
<dimen name="bus_switch_line_btn_margin_b">20px</dimen>
<dimen name="bus_traffic_light_layout_width">225px</dimen>
<dimen name="bus_traffic_light_layout_height">154px</dimen>
<dimen name="bus_traffic_light_layout_corner">60px</dimen>
<dimen name="bus_traffic_light_layout_margin_right">40px</dimen>
<dimen name="bus_traffic_light_layout_margin_top">23px</dimen>
<dimen name="bus_traffic_light_bg_width">210px</dimen>
<dimen name="bus_traffic_light_bg_height">120px</dimen>
<dimen name="bus_traffic_light_bg_margin_left">15px</dimen>
<dimen name="bus_traffic_light_bg_margin_top">17px</dimen>
<dimen name="bus_traffic_light_icon_size">154px</dimen>
<dimen name="bus_traffic_light_time_view_width">130px</dimen>
<dimen name="bus_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -121,4 +121,17 @@
<dimen name="bus_switch_line_btn_height">120px</dimen>
<dimen name="bus_switch_line_btn">86px</dimen>
<dimen name="bus_switch_line_btn_margin_b">50px</dimen>
<dimen name="bus_traffic_light_layout_width">225px</dimen>
<dimen name="bus_traffic_light_layout_height">154px</dimen>
<dimen name="bus_traffic_light_layout_corner">60px</dimen>
<dimen name="bus_traffic_light_layout_margin_right">40px</dimen>
<dimen name="bus_traffic_light_layout_margin_top">23px</dimen>
<dimen name="bus_traffic_light_bg_width">210px</dimen>
<dimen name="bus_traffic_light_bg_height">120px</dimen>
<dimen name="bus_traffic_light_bg_margin_left">15px</dimen>
<dimen name="bus_traffic_light_bg_margin_top">17px</dimen>
<dimen name="bus_traffic_light_icon_size">154px</dimen>
<dimen name="bus_traffic_light_time_view_width">130px</dimen>
<dimen name="bus_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -38,4 +38,10 @@
<color name="bus_switch_btn_bg_half">#19FFFFFF</color>
<color name="bus_white">#FFFFFF</color>
<color name="bus_traffic_light_red_color_up">#FFFFA28B</color>
<color name="bus_traffic_light_red_color_down">#FFDA1100</color>
<color name="bus_traffic_light_green_color_up">#FF60FFD3</color>
<color name="bus_traffic_light_green_color_down">#FF006D43</color>
<color name="bus_traffic_light_yellow_color_up">#FFFFE198</color>
<color name="bus_traffic_light_yellow_color_down">#FFFF9B00</color>
</resources>

View File

@@ -137,4 +137,17 @@
<dimen name="bus_switch_line_btn_height">72px</dimen>
<dimen name="bus_switch_line_btn">52px</dimen>
<dimen name="bus_switch_line_btn_margin_b">20px</dimen>
<dimen name="bus_traffic_light_layout_width">225px</dimen>
<dimen name="bus_traffic_light_layout_height">154px</dimen>
<dimen name="bus_traffic_light_layout_corner">60px</dimen>
<dimen name="bus_traffic_light_layout_margin_right">40px</dimen>
<dimen name="bus_traffic_light_layout_margin_top">23px</dimen>
<dimen name="bus_traffic_light_bg_width">210px</dimen>
<dimen name="bus_traffic_light_bg_height">120px</dimen>
<dimen name="bus_traffic_light_bg_margin_left">15px</dimen>
<dimen name="bus_traffic_light_bg_margin_top">17px</dimen>
<dimen name="bus_traffic_light_icon_size">154px</dimen>
<dimen name="bus_traffic_light_time_view_width">130px</dimen>
<dimen name="bus_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -28,7 +28,6 @@
android:layout_height="match_parent"
android:textSize="@dimen/taxi_p_traffic_light_time_size"
android:textStyle="bold"
android:text="300"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center" />

View File

@@ -37,7 +37,7 @@
<dimen name="taxi_p_traffic_light_bg_margin_left">15px</dimen>
<dimen name="taxi_p_traffic_light_bg_margin_top">17px</dimen>
<dimen name="taxi_p_traffic_light_icon_size">154px</dimen>
<dimen name="taxi_p_traffic_light_time_view_width">127px</dimen>
<dimen name="taxi_p_traffic_light_time_view_width">130px</dimen>
<dimen name="taxi_p_traffic_light_time_size">60px</dimen>
<dimen name="taxi_p_v2x_notification_view_margin_left">31px</dimen>

View File

@@ -106,7 +106,7 @@
<dimen name="taxi_p_traffic_light_bg_margin_left">15px</dimen>
<dimen name="taxi_p_traffic_light_bg_margin_top">17px</dimen>
<dimen name="taxi_p_traffic_light_icon_size">154px</dimen>
<dimen name="taxi_p_traffic_light_time_view_width">127px</dimen>
<dimen name="taxi_p_traffic_light_time_view_width">130px</dimen>
<dimen name="taxi_p_traffic_light_time_size">60px</dimen>
<dimen name="taxi_p_v2x_notification_view_margin_left">31px</dimen>

View File

@@ -77,6 +77,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
protected ImageView mBadcaseBtn;
protected ImageView mUpgradeTipIv;
protected OCHNaviFragment ochNaviFragment = null;
protected TaxiTrafficLightView mTrafficLightView;
private Handler mHandler = new Handler(Looper.getMainLooper());
@@ -95,6 +96,12 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
mAutopilotImage = findViewById(R.id.module_och_autopilot_iv);
mAutopilotTv = findViewById(R.id.module_och_autopilot_tv);
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
mTrafficLightView = findViewById(R.id.taxi_traffic_light_view);
CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
mTrafficLightView.showWarningTrafficLight(3);
mTrafficLightView.changeCountdownTrafficLightNum(1, 2, 21);
mPersonalBtn = findViewById(R.id.module_och_taxi_personal_layout);
mSpeedView = findViewById(R.id.module_mogo_och_speed_tv);
mCloseNaviIcon = findViewById(R.id.taxi_close_navi_icon);

View File

@@ -0,0 +1,114 @@
package com.mogo.och.taxi.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
/**
* @author: wangmingjun
* @date: 2022/3/22
*/
public class GradientTextView extends AppCompatTextView {
private LinearGradient mLinearGradient;
private Paint mPaint;
private int mViewWidth = 0;//文字的宽度
private int mViewHeight = 0;//文字的高度
private Rect mTextBound = new Rect();
private int[] mColorList;//存放颜色的数组
private boolean isVertrial;//默认是横向
private float mRadius;
private float mdx;
private float mdy;
private int mColor;
public GradientTextView(Context context) {
this(context, null);
}
public GradientTextView(Context context,
AttributeSet attrs) {
super(context, attrs);
//设置默认的颜色
mColorList = new int[]{0xFFFFFFFF, 0xFFFFFFF};
}
@Override
protected void onDraw(Canvas canvas) {
if (isVertrial) {
mViewHeight = getMeasuredHeight();
} else {
mViewWidth = getMeasuredWidth();
}
mPaint = getPaint();
String mTipText = getText().toString();
setStyle();
mPaint.getTextBounds(mTipText, 0, mTipText.length(), mTextBound);
mPaint.setShadowLayer(mRadius, mdx, mdy, mColor);
//画出文字
canvas.drawText(mTipText, getMeasuredWidth() / 2 - mTextBound.width() / 2, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint);
}
/**
* true表示纵向渐变,false变身横向渐变
*
* @param vertrial
*/
public void setVertrial(boolean vertrial) {
isVertrial = vertrial;
}
/**
* 设置渐变的颜色
*
* @param mColorList
*/
public void setmColorList(int[] mColorList) {
if (mColorList != null && mColorList.length < 2) {
throw new RuntimeException("ClorList's length must be > 2");
} else {
this.mColorList = mColorList;
}
}
public void setStyle() {
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setFilterBitmap(true);
//前面4个参数分别表示渐变的开始x轴,开始y轴,结束的x轴,结束的y轴,mcolorList表示渐变的颜色数组
mLinearGradient = new LinearGradient(0, 0, mViewWidth, mViewHeight, mColorList, null, Shader.TileMode.CLAMP);
mPaint.setShader(mLinearGradient);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
/**
* 设置投影层
* @param radius
* @param dx
* @param dy
* @param color
*/
public void setShadowLayerCustom(float radius, float dx, float dy, int color) {
this.mRadius = radius;
this.mdx = dx;
this.mdy = dy;
this.mColor = color;
}
}

View File

@@ -0,0 +1,165 @@
package com.mogo.och.taxi.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.taxi.R;
import org.jetbrains.annotations.Nullable;
/**
* Taxi司机端红绿灯view
*
* Created on 2022/3/29
*/
public class TaxiTrafficLightView extends IViewTrafficLight {
private ImageView mLightIconIV;
private GradientTextView mLightTimeTV;
private int mCurrentLightId;
public TaxiTrafficLightView(@Nullable Context context) {
this(context, null, 0);
}
public TaxiTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public TaxiTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
LayoutInflater.from(context).inflate(R.layout.taxi_traffic_light_view, this, true);
mLightIconIV = findViewById(R.id.taxi_traffic_light_iv);
mLightTimeTV = findViewById(R.id.taxi_traffic_light_time_tv);
}
/**
* 展示红绿灯预警
*
* @param checkLightId 0-都是默认1-红2-黄3-绿
*/
@Override
public void showWarningTrafficLight(int checkLightId) {
super.showWarningTrafficLight(checkLightId);
mCurrentLightId = checkLightId;
updateTrafficLightIcon(checkLightId);
}
/**
* 关闭红绿灯预警展示,并重制灯态
*/
@Override
public void disableWarningTrafficLight() {
super.disableWarningTrafficLight();
UiThreadHandler.post(() -> {
mCurrentLightId = 0;
TaxiTrafficLightView.this.setVisibility(GONE);
});
}
/**
* @param redNum 红灯倒计时
* @param yellowNum 黄灯倒计时
* @param greenNum 绿灯倒计时
*/
@Override
public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) {
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum);
switch (mCurrentLightId) {
case 1:
changeCountdownRed(redNum);
break;
case 2:
changeCountdownYellow(yellowNum);
break;
case 3:
changeCountdownGreen(greenNum);
break;
default:
UiThreadHandler.post(() -> {
mLightTimeTV.setText("");
});
break;
}
}
@Override
public void changeCountdownRed(int redNum) {
super.changeCountdownRed(redNum);
UiThreadHandler.post(() -> {
if (redNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_traffic_light_red_color_up),
getResources().getColor(R.color.taxi_traffic_light_red_color_down)});
mLightTimeTV.setText(String.valueOf(redNum));
} else {
mLightTimeTV.setText("");
}
});
}
@Override
public void changeCountdownGreen(int greenNum) {
super.changeCountdownGreen(greenNum);
UiThreadHandler.post(() -> {
if (greenNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_traffic_light_green_color_up),
getResources().getColor(R.color.taxi_traffic_light_green_color_down)});
mLightTimeTV.setText(String.valueOf(greenNum));
} else {
mLightTimeTV.setText("");
}
});
}
@Override
public void changeCountdownYellow(int yellowNum) {
super.changeCountdownYellow(yellowNum);
UiThreadHandler.post(() -> {
if (yellowNum > 0) {
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_traffic_light_yellow_color_up),
getResources().getColor(R.color.taxi_traffic_light_yellow_color_down)});
mLightTimeTV.setText(String.valueOf(yellowNum));
} else {
mLightTimeTV.setText("");
}
});
}
/**
* 更新红绿灯icon
*
* @param lightId 0-都是默认1-红2-黄3-绿
*/
private void updateTrafficLightIcon(int lightId) {
UiThreadHandler.post(() -> {
switch (lightId) {
case 1:
mLightIconIV.setBackgroundResource(R.drawable.taxi_light_red_nor);
TaxiTrafficLightView.this.setVisibility(VISIBLE);
break;
case 2:
mLightIconIV.setBackgroundResource(R.drawable.taxi_lightyellow_nor);
TaxiTrafficLightView.this.setVisibility(VISIBLE);
break;
case 3:
mLightIconIV.setBackgroundResource(R.drawable.taxi_light_green_nor);
TaxiTrafficLightView.this.setVisibility(VISIBLE);
break;
default:
TaxiTrafficLightView.this.setVisibility(GONE);
break;
}
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff000000"/>
<corners android:radius="@dimen/taxi_traffic_light_layout_corner"/>
</shape>

View File

@@ -269,4 +269,14 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/taxi_close_navi_icon"/>
<com.mogo.och.taxi.ui.TaxiTrafficLightView
android:id="@+id/taxi_traffic_light_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="@dimen/taxi_traffic_light_layout_margin_right"
android:layout_marginTop="@dimen/taxi_traffic_light_layout_margin_top"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,35 @@
<?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/taxi_traffic_light_layout_width"
android:layout_height="@dimen/taxi_traffic_light_layout_height"
android:visibility="visible">
<ImageView
android:layout_width="@dimen/taxi_traffic_light_bg_width"
android:layout_height="@dimen/taxi_traffic_light_bg_height"
android:background="@drawable/bg_taxi_traffic_light_background"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="@dimen/taxi_traffic_light_bg_margin_left"
android:layout_marginTop="@dimen/taxi_traffic_light_bg_margin_top"/>
<ImageView
android:id="@+id/taxi_traffic_light_iv"
android:layout_width="@dimen/taxi_traffic_light_icon_size"
android:layout_height="@dimen/taxi_traffic_light_icon_size"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.mogo.och.taxi.ui.GradientTextView
android:id="@+id/taxi_traffic_light_time_tv"
android:layout_width="@dimen/taxi_traffic_light_time_view_width"
android:layout_height="match_parent"
android:textSize="@dimen/taxi_traffic_light_time_size"
android:textStyle="bold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -88,4 +88,17 @@
<dimen name="taxi_tab_autoaploit_height">220px</dimen>
<dimen name="taxi_diver_role_size">16px</dimen>
<dimen name="taxi_traffic_light_layout_width">225px</dimen>
<dimen name="taxi_traffic_light_layout_height">154px</dimen>
<dimen name="taxi_traffic_light_layout_corner">60px</dimen>
<dimen name="taxi_traffic_light_layout_margin_right">40px</dimen>
<dimen name="taxi_traffic_light_layout_margin_top">23px</dimen>
<dimen name="taxi_traffic_light_bg_width">210px</dimen>
<dimen name="taxi_traffic_light_bg_height">120px</dimen>
<dimen name="taxi_traffic_light_bg_margin_left">15px</dimen>
<dimen name="taxi_traffic_light_bg_margin_top">17px</dimen>
<dimen name="taxi_traffic_light_icon_size">154px</dimen>
<dimen name="taxi_traffic_light_time_view_width">130px</dimen>
<dimen name="taxi_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -89,4 +89,16 @@
<dimen name="taxi_diver_role_size">16px</dimen>
<dimen name="taxi_traffic_light_layout_width">225px</dimen>
<dimen name="taxi_traffic_light_layout_height">154px</dimen>
<dimen name="taxi_traffic_light_layout_corner">60px</dimen>
<dimen name="taxi_traffic_light_layout_margin_right">40px</dimen>
<dimen name="taxi_traffic_light_layout_margin_top">23px</dimen>
<dimen name="taxi_traffic_light_bg_width">210px</dimen>
<dimen name="taxi_traffic_light_bg_height">120px</dimen>
<dimen name="taxi_traffic_light_bg_margin_left">15px</dimen>
<dimen name="taxi_traffic_light_bg_margin_top">17px</dimen>
<dimen name="taxi_traffic_light_icon_size">154px</dimen>
<dimen name="taxi_traffic_light_time_view_width">130px</dimen>
<dimen name="taxi_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -15,4 +15,11 @@
<color name="taxi_autopilot_text_color_checked">#FF52BBFF</color>
<color name="taxi_role_text_color">#4DFFFFFF</color>
<color name="taxi_traffic_light_red_color_up">#FFFFA28B</color>
<color name="taxi_traffic_light_red_color_down">#FFDA1100</color>
<color name="taxi_traffic_light_green_color_up">#FF60FFD3</color>
<color name="taxi_traffic_light_green_color_down">#FF006D43</color>
<color name="taxi_traffic_light_yellow_color_up">#FFFFE198</color>
<color name="taxi_traffic_light_yellow_color_down">#FFFF9B00</color>
</resources>

View File

@@ -87,4 +87,16 @@
<dimen name="taxi_diver_role_size">16px</dimen>
<dimen name="taxi_traffic_light_layout_width">225px</dimen>
<dimen name="taxi_traffic_light_layout_height">154px</dimen>
<dimen name="taxi_traffic_light_layout_corner">60px</dimen>
<dimen name="taxi_traffic_light_layout_margin_right">40px</dimen>
<dimen name="taxi_traffic_light_layout_margin_top">23px</dimen>
<dimen name="taxi_traffic_light_bg_width">210px</dimen>
<dimen name="taxi_traffic_light_bg_height">120px</dimen>
<dimen name="taxi_traffic_light_bg_margin_left">15px</dimen>
<dimen name="taxi_traffic_light_bg_margin_top">17px</dimen>
<dimen name="taxi_traffic_light_icon_size">154px</dimen>
<dimen name="taxi_traffic_light_time_view_width">130px</dimen>
<dimen name="taxi_traffic_light_time_size">60px</dimen>
</resources>

View File

@@ -107,9 +107,13 @@ public class MogoApplication extends MainMoGoApplication {
if (DebugConfig.getProductFlavor().equals("fPadLenovoOchTaxi")
|| DebugConfig.getProductFlavor().equals("fPadLenovoOchTaxiPassenger")) {
HdMapBuildConfig.currentCarVrIconRes = R.raw.chuzuche;
//是否显示 红绿等
HmiBuildConfig.isShowTrafficLightView = false;
} else if (DebugConfig.getProductFlavor().equals("fPadLenovoOchBus")
|| DebugConfig.getProductFlavor().equals("fPadLenovoOchBusPassenger")) {
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaobache;
//是否显示 红绿等
HmiBuildConfig.isShowTrafficLightView = false;
HmiBuildConfig.isShowBrakeLightView = false;
HmiBuildConfig.isShowTurnLightView = false;
}
@@ -117,8 +121,6 @@ public class MogoApplication extends MainMoGoApplication {
if (DebugConfig.getProductFlavor().equals("fPadLenovoOchTaxiPassenger")) {
//是否显示 限速UI
HmiBuildConfig.isShowLimitingVelocityView = false;
//是否显示 红绿等
HmiBuildConfig.isShowTrafficLightView = false;
//是否显示 路侧监控
HmiBuildConfig.isShowCameraView = false;
}