fix bug of acc num

This commit is contained in:
zhongchao
2022-08-02 19:37:29 +08:00
parent 24e62960e0
commit a274aadb00

View File

@@ -12,7 +12,9 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
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;
@@ -22,6 +24,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import mogo.telematics.pad.MessagePad;
/**
* @author Jing
@@ -46,7 +49,6 @@ public class TrafficDataView extends ConstraintLayout {
public TrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initView(context);
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
}
public TrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
@@ -57,11 +59,21 @@ public class TrafficDataView extends ConstraintLayout {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, gnssInfo -> {
CallerLogger.INSTANCE.d(TAG, "司机屏加速度:" + gnssInfo.getAcceleration());
ThreadUtils.runOnUiThread(() -> {
java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00");
String accStr = mFormat.format(gnssInfo.getAcceleration());
accTextView.setText("a: " + accStr);
});
});
}
private void initView(@NonNull Context context) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
// LayoutInflater.from(context).inflate(R.layout.hmi_traffic_data, this);
} else {
}
LayoutInflater.from(context).inflate(R.layout.hmi_traffic_data, this);
tapPositionView = findViewById(R.id.traffic_position);
speedImage = findViewById(R.id.speedImage);
@@ -70,6 +82,13 @@ public class TrafficDataView extends ConstraintLayout {
brakeStatus = findViewById(R.id.brakeStatus);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.removeListener(TAG);
CallerAutopilotCarStatusListenerManager.INSTANCE.removeListener(TAG);
}
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
/**
* 车辆转向灯
@@ -125,12 +144,7 @@ public class TrafficDataView extends ConstraintLayout {
@Override
public void onAutopilotAcc(float carAcc) {
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