完成了测试控制面板的分段控制展示

This commit is contained in:
董宏宇
2020-10-29 21:28:13 +08:00
parent b1a92fb0aa
commit 8d2150d97c
4 changed files with 393 additions and 306 deletions

View File

@@ -37,6 +37,7 @@ public class V2XConst {
*/
public static final String BROADCAST_TEST_PANEL_CONTROL_ACTION = "com.v2x.com.v2x.test_panel_control";
public static final String BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY = "TextPanelOpenStatus";
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "TextPanelOpenType";
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";

View File

@@ -21,15 +21,17 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
boolean textPanelOpenStatus = intent.getBooleanExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY, false);
int textPanelOpenType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
Logger.d(TAG, "textPanelOpenStatus:" + textPanelOpenStatus);
Logger.d(TAG, "textPanelOpenType:" + textPanelOpenType);
if (textPanelOpenStatus) {
V2XServiceManager
.getIMogoWindowManager()
.addView(V2XTestConsoleWindow.getInstance(context), 0, 0, false);
.addView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType), 0, 0, false);
} else {
V2XServiceManager
.getIMogoWindowManager()
.removeView(V2XTestConsoleWindow.getInstance(context));
.removeView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType));
}
} catch (Exception e) {
e.printStackTrace();

View File

@@ -6,6 +6,7 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -39,7 +40,10 @@ import static android.text.style.TtsSpan.GENDER_MALE;
public class V2XTestConsoleWindow extends ConstraintLayout {
private static V2XTestConsoleWindow mV2XTestConsoleWindow;
private FlexboxLayout mFlTestPanel;
private LinearLayout mFlTestPanel;
private FlexboxLayout flTestPanelShunNormal;
private FlexboxLayout flTestPanelShunYi;
private FlexboxLayout flTestPanelVR;
private Button mBtnTriggerOpen;
private Button mBtnTriggerRoadEvent;
private Button mBtnClearRoadEvent;
@@ -61,17 +65,22 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
btnTriggerCongestedRouteRecommendation,
btnTriggerDoubleFlash;
public static V2XTestConsoleWindow getInstance(Context context) {
public static V2XTestConsoleWindow getInstance(Context context, int showType) {
if (mV2XTestConsoleWindow == null) {
synchronized (V2XTestConsoleWindow.class) {
if (mV2XTestConsoleWindow == null) {
mV2XTestConsoleWindow = new V2XTestConsoleWindow(context);
mV2XTestConsoleWindow = new V2XTestConsoleWindow(context, showType);
}
}
}
return mV2XTestConsoleWindow;
}
public V2XTestConsoleWindow(Context context, int showType) {
super(context);
initView(context, showType);
}
public V2XTestConsoleWindow(Context context) {
this(context, null);
}
@@ -82,13 +91,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
public V2XTestConsoleWindow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context);
initView(context, 0);
}
private void initView(Context context) {
private void initView(Context context, int showType) {
LayoutInflater.from(context).inflate(R.layout.window_test_console, this);
mFlTestPanel = findViewById(R.id.flTestPanel);
flTestPanelShunNormal = findViewById(R.id.flTestPanelShunNormal);
flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi);
flTestPanelVR = findViewById(R.id.flTestPanelVR);
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
@@ -111,6 +123,24 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
btnTriggerDoubleFlash = findViewById(R.id.btnTriggerDoubleFlash);
switch (showType) {
case 0:
flTestPanelShunNormal.setVisibility(View.VISIBLE);
flTestPanelShunYi.setVisibility(View.VISIBLE);
flTestPanelVR.setVisibility(View.VISIBLE);
break;
case 1:
flTestPanelShunNormal.setVisibility(View.VISIBLE);
break;
case 2:
flTestPanelShunYi.setVisibility(View.VISIBLE);
break;
case 3:
flTestPanelVR.setVisibility(View.VISIBLE);
break;
}
mBtnTriggerCallUserInfo.setOnClickListener(v -> {
MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
mogoDriverInfo.setAge(24);
@@ -124,7 +154,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
mBtnTriggerOpen.setOnClickListener(v ->
V2XServiceManager
.getIMogoWindowManager()
.removeView(V2XTestConsoleWindow.getInstance(context))
.removeView(V2XTestConsoleWindow.getInstance(context, showType))
);
mBtnClearRoadEvent.setOnClickListener(v -> {