档位+自动驾驶状态业务逻辑添加
缺少根据方向盘转角,方向盘动画 缺少外层圆形进度条动画
This commit is contained in:
@@ -4,12 +4,28 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import chassis.Chassis;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
@@ -18,10 +34,78 @@ import com.mogo.eagle.core.function.hmi.R;
|
||||
*/
|
||||
public class SteeringWheelView extends ConstraintLayout {
|
||||
private static final String TAG = "SteeringWheelView";
|
||||
private ImageView autopilotIV;
|
||||
private TextView steeringTV;
|
||||
private TapPositionView tapPositionView;
|
||||
|
||||
public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater.from(context).inflate(R.layout.hmi_steering_wheel, this);
|
||||
Log.d(TAG, "2");
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener);
|
||||
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
|
||||
autopilotIV = findViewById(R.id.autopilot_iv);
|
||||
steeringTV = findViewById(R.id.steering_tv);
|
||||
tapPositionView = findViewById(R.id.tap_position);
|
||||
}
|
||||
|
||||
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() {
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
if (autopilotStatusInfo == null) return;
|
||||
int state = autopilotStatusInfo.getState();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "state = %s", state);
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
autopilotIV.setImageResource(R.drawable.bg_auto);
|
||||
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
autopilotIV.setImageResource(R.drawable.bg_auto_nor);
|
||||
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
autopilotIV.setImageResource(R.drawable.bg_auto_nor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
|
||||
@Override
|
||||
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotBrakeLightData(boolean brakeLight) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSteeringData(float steering) {
|
||||
steeringTV.setText(String.valueOf(steering) + "°");
|
||||
}
|
||||
|
||||
/**
|
||||
* 档位
|
||||
* @param gear
|
||||
*/
|
||||
@Override
|
||||
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
|
||||
Log.d(TAG, "档位" + gear.toString());
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -12,9 +13,13 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import chassis.Chassis;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 档位
|
||||
* @description 方向盘下方的档位
|
||||
* @since: 4/7/22
|
||||
*/
|
||||
public class TapPositionView extends ConstraintLayout {
|
||||
@@ -28,6 +33,47 @@ public class TapPositionView extends ConstraintLayout {
|
||||
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);
|
||||
tabN = findViewById(R.id.tap_n);
|
||||
tabD = findViewById(R.id.tap_d);
|
||||
}
|
||||
|
||||
public void updateWithGear(@NotNull Chassis.GearPosition gear) {
|
||||
|
||||
switch (gear) {
|
||||
case GEAR_NONE:
|
||||
tabP.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabR.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabN.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabD.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
break;
|
||||
case GEAR_P:
|
||||
tabP.setTextColor(Color.parseColor("#0043FF"));
|
||||
tabR.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabN.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabD.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
break;
|
||||
case GEAR_R:
|
||||
tabR.setTextColor(Color.parseColor("#0043FF"));
|
||||
tabP.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabN.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabD.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
break;
|
||||
case GEAR_N:
|
||||
tabN.setTextColor(Color.parseColor("#0043FF"));
|
||||
tabR.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabP.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabD.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
break;
|
||||
case GEAR_D:
|
||||
tabD.setTextColor(Color.parseColor("#0043FF"));
|
||||
tabN.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabR.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
tabP.setTextColor(Color.parseColor("#6E8EC9"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/steering_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
|
||||
Reference in New Issue
Block a user