[taxi/bus-d 270] bus/taxi 乘客屏红路灯无倒计时UI样式修改

This commit is contained in:
wangmingjun
2022-05-26 16:27:10 +08:00
parent bb8dcf313a
commit 66c223e352
4 changed files with 73 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package com.mogo.och.bus.passenger.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -22,6 +23,7 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
private ImageView mLightIconIV;
private TextView mLightTimeTV;
private int mCurrentLightId;
private ImageView mLightIconBG;
public BusPassengerTrafficLightView(@Nullable Context context) {
this(context, null, 0);
@@ -40,6 +42,7 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true);
mLightIconIV = findViewById(R.id.bus_p_traffic_light_iv);
mLightTimeTV = findViewById(R.id.bus_p_traffic_light_time_tv);
mLightIconBG = findViewById(R.id.bus_p_traffic_light_bg);
}
/**
@@ -74,6 +77,7 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
@Override
public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) {
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum);
resetView();
switch (mCurrentLightId) {
case 1:
changeCountdownRed(redNum);
@@ -97,8 +101,10 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownRed(redNum);
UiThreadHandler.post(() -> {
if (redNum > 0) {
resetView();
mLightTimeTV.setText(String.valueOf(redNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -109,8 +115,10 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownGreen(greenNum);
UiThreadHandler.post(() -> {
if (greenNum > 0) {
resetView();
mLightTimeTV.setText(String.valueOf(greenNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -121,8 +129,10 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownYellow(yellowNum);
UiThreadHandler.post(() -> {
if (yellowNum > 0) {
resetView();
mLightTimeTV.setText(String.valueOf(yellowNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -154,4 +164,30 @@ public class BusPassengerTrafficLightView extends IViewTrafficLight {
}
});
}
@Override
public void disableCountdown() {
super.disableCountdown();
UiThreadHandler.post(() ->{
ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams instanceof MarginLayoutParams){
MarginLayoutParams lp = (MarginLayoutParams) layoutParams;
lp.width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_icon_size);
setLayoutParams(lp);
mLightTimeTV.setVisibility(GONE);
mLightIconBG.getLayoutParams().width = (int)getResources().getDimension(R.dimen.dp_90);
}
});
}
private void resetView(){
ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams instanceof MarginLayoutParams) {
MarginLayoutParams lp = (MarginLayoutParams) layoutParams;
lp.width = (int) getResources().getDimension(R.dimen.bus_p_route_traffic_light_view_width);
setLayoutParams(lp);
mLightTimeTV.setVisibility(VISIBLE);
mLightIconBG.getLayoutParams().width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_bg_width);
}
}
}

View File

@@ -7,6 +7,7 @@
android:visibility="visible">
<ImageView
android:id="@+id/bus_p_traffic_light_bg"
android:layout_width="@dimen/bus_p_traffic_light_bg_width"
android:layout_height="@dimen/bus_p_traffic_light_bg_height"
android:background="@drawable/bg_bus_p_traffic_light_background"

View File

@@ -1,12 +1,10 @@
package com.mogo.och.taxi.passenger.ui;
import android.content.Context;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
@@ -25,6 +23,7 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
private ImageView mLightIconIV;
private OCHGradientTextView mLightTimeTV;
private int mCurrentLightId;
private ImageView mLightIconBG;
public TaxiPassengerTrafficLightView(@Nullable Context context) {
this(context, null, 0);
@@ -43,6 +42,7 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
LayoutInflater.from(context).inflate(R.layout.taxi_p_traffic_light_view, this, true);
mLightIconIV = findViewById(R.id.taxi_p_traffic_light_iv);
mLightTimeTV = findViewById(R.id.taxi_p_traffic_light_time_tv);
mLightIconBG = findViewById(R.id.taxi_p_traffic_light_bg);
}
/**
@@ -77,6 +77,7 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
@Override
public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) {
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum);
resetView();
switch (mCurrentLightId) {
case 1:
changeCountdownRed(redNum);
@@ -100,11 +101,13 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownRed(redNum);
UiThreadHandler.post(() -> {
if (redNum > 0) {
resetView();
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_traffic_light_red_color_up),
getResources().getColor(R.color.taxi_p_traffic_light_red_color_down)});
mLightTimeTV.setText(String.valueOf(redNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -115,11 +118,13 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownGreen(greenNum);
UiThreadHandler.post(() -> {
if (greenNum > 0) {
resetView();
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_traffic_light_green_color_up),
getResources().getColor(R.color.taxi_p_traffic_light_green_color_down)});
mLightTimeTV.setText(String.valueOf(greenNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -130,11 +135,13 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
super.changeCountdownYellow(yellowNum);
UiThreadHandler.post(() -> {
if (yellowNum > 0) {
resetView();
mLightTimeTV.setVertrial(true);
mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_traffic_light_yellow_color_up),
getResources().getColor(R.color.taxi_p_traffic_light_yellow_color_down)});
mLightTimeTV.setText(String.valueOf(yellowNum));
} else {
disableCountdown();
mLightTimeTV.setText("");
}
});
@@ -166,4 +173,29 @@ public class TaxiPassengerTrafficLightView extends IViewTrafficLight {
}
});
}
@Override
public void disableCountdown() {
super.disableCountdown();
UiThreadHandler.post(() ->{
ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams instanceof MarginLayoutParams){
MarginLayoutParams lp = (MarginLayoutParams) layoutParams;
lp.width = (int) getResources().getDimension(R.dimen.taxi_p_traffic_light_icon_size);
setLayoutParams(lp);
mLightTimeTV.setVisibility(GONE);
mLightIconBG.getLayoutParams().width = (int)getResources().getDimension(R.dimen.dp_124);
}
});
}
private void resetView(){
ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams instanceof MarginLayoutParams) {
MarginLayoutParams lp = (MarginLayoutParams) layoutParams;
lp.width = (int) getResources().getDimension(R.dimen.taxi_p_traffic_light_layout_width);
setLayoutParams(lp);
mLightTimeTV.setVisibility(VISIBLE);
mLightIconBG.getLayoutParams().width = (int) getResources().getDimension(R.dimen.taxi_p_traffic_light_bg_width);
}
}
}

View File

@@ -7,6 +7,7 @@
android:visibility="visible">
<ImageView
android:id="@+id/taxi_p_traffic_light_bg"
android:layout_width="@dimen/taxi_p_traffic_light_bg_width"
android:layout_height="@dimen/taxi_p_traffic_light_bg_height"
android:background="@drawable/bg_taxi_p_traffic_light_background"