fix bug of ui causing anr

This commit is contained in:
zhongchao
2022-07-29 12:14:02 +08:00
parent 42d3c94894
commit 6386fbbf5d
4 changed files with 44 additions and 41 deletions

View File

@@ -35,7 +35,6 @@ public class TapPositionView extends ConstraintLayout {
public TapPositionView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
Log.d(TAG, "2");
LayoutInflater.from(context).inflate(R.layout.hmi_tap_position, this);
tabP = findViewById(R.id.tap_p);
tabR = findViewById(R.id.tap_r);
@@ -48,7 +47,6 @@ public class TapPositionView extends ConstraintLayout {
if (tabP != null && tabR != null && tabN != null && tabD != null) {
int defaultColor = typedArray.getColor(R.styleable.TapPositionView_defaultColor, -1);
int selectColor = typedArray.getColor(R.styleable.TapPositionView_selectColor, -1);
Log.d(TAG, "gear:" + gear);
switch (gear) {
case GEAR_NONE:
tabP.setTextColor(defaultColor);

View File

@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateList
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
@@ -76,7 +77,9 @@ public class TrafficDataView extends ConstraintLayout {
*/
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
Log.d(TAG, "车辆转向灯:" + lightSwitch.toString());
if(lightSwitch != null){
CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString());
}
}
/**
@@ -85,7 +88,7 @@ public class TrafficDataView extends ConstraintLayout {
*/
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight));
CallerLogger.INSTANCE.d(TAG, "刹车灯:" + brakeLight);
}
/**
@@ -94,18 +97,11 @@ public class TrafficDataView extends ConstraintLayout {
*/
@Override
public void onAutopilotSteeringData(float steering) {
Log.d(TAG, "steering原始值====" + String.valueOf(steering));
CallerLogger.INSTANCE.d(TAG, "steering原始值====" + steering);
if (Math.abs(steering) < 1) {
steering = 0;
}
float steeringValue = steering;
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "steering忽略小数点后====" + String.valueOf((int) steeringValue));
}
});
CallerLogger.INSTANCE.d(TAG, "steering忽略小数点后====" + (int) steering);
}
/**
@@ -114,16 +110,12 @@ public class TrafficDataView extends ConstraintLayout {
*/
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "司机屏档位" + gear.toString());
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}
CallerLogger.INSTANCE.d(TAG, "司机屏档位" + gear.toString());
ThreadUtils.runOnUiThread(() -> {
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}
});
}
@Override
@@ -133,30 +125,36 @@ public class TrafficDataView extends ConstraintLayout {
@Override
public void onAutopilotAcc(float carAcc) {
Log.d(TAG, "司机屏加速度:" + carAcc);
java.text.DecimalFormat myformat = new java.text.DecimalFormat("0.00");
String accStr = myformat.format(carAcc);
accTextView.setText("a: " + String.valueOf(accStr));
CallerLogger.INSTANCE.d(TAG, "司机屏加速度:" + carAcc);
ThreadUtils.runOnUiThread(() -> {
java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00");
String accStr = mFormat.format(carAcc);
accTextView.setText("a: " + accStr);
});
}
@Override
public void onAutopilotBrake(float brake) {
Log.d(TAG, "刹车:" + String.valueOf(brake));
if (brake > 0){
brakeStatus.setImageResource(R.drawable.traffic_data_brake);
}else {
brakeStatus.setImageResource(R.drawable.traffic_data_empty);
}
CallerLogger.INSTANCE.d(TAG, "刹车:" + brake);
ThreadUtils.runOnUiThread(() -> {
if (brake > 0) {
brakeStatus.setImageResource(R.drawable.traffic_data_brake);
} else {
brakeStatus.setImageResource(R.drawable.traffic_data_empty);
}
});
}
@Override
public void onAutopilotThrottle(float throttle) {
Log.d(TAG, "油门:" + String.valueOf(throttle));
if (throttle > 0){
brakeStatus.setImageResource(R.drawable.traffic_data_accelerator);
}else {
brakeStatus.setImageResource(R.drawable.traffic_data_empty);
}
CallerLogger.INSTANCE.d(TAG, "油门:" + throttle);
ThreadUtils.runOnUiThread(() -> {
if (throttle > 0) {
brakeStatus.setImageResource(R.drawable.traffic_data_accelerator);
} else {
brakeStatus.setImageResource(R.drawable.traffic_data_empty);
}
});
}
};