导航界面普通模式和vr模式兼容
This commit is contained in:
@@ -30,6 +30,8 @@ import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
@@ -43,14 +45,11 @@ import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
|
||||
import com.mogo.module.common.map.CustomNaviInterrupter;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.MyLocationUtil;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.common.view.OnPreventFastClickListener;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.AnimNavInfoView;
|
||||
import com.mogo.module.extensions.navi.BaseNaviInfoView;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.module.extensions.navi.VrModeNavInfoView;
|
||||
import com.mogo.module.extensions.userinfo.UserInfo;
|
||||
import com.mogo.module.extensions.utils.AdasNoticeHelper;
|
||||
@@ -58,8 +57,6 @@ import com.mogo.module.extensions.utils.CameraLiveNoticeHelper;
|
||||
import com.mogo.module.extensions.utils.EntranceViewHolder;
|
||||
import com.mogo.module.extensions.utils.NoMapTopViewShaderHelper;
|
||||
import com.mogo.module.extensions.utils.TopViewAnimHelper;
|
||||
import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper;
|
||||
import com.mogo.module.extensions.utils.TrafficLightPanelManager;
|
||||
import com.mogo.module.share.manager.ServiceApisManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
@@ -115,7 +112,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
IMogoMapListener,
|
||||
IMogoAimlessModeListener,
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener {
|
||||
IMogoIntentListener,
|
||||
IMogoLocationListener {
|
||||
|
||||
private static final String TAG = "EntranceFragment";
|
||||
|
||||
@@ -493,7 +491,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
});
|
||||
|
||||
TrafficLightPanelManager.getInstance().initPanel(mRootView);
|
||||
}
|
||||
|
||||
private EditText etTimes;
|
||||
@@ -510,11 +507,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
tvExitVrMode.setVisibility(View.VISIBLE);
|
||||
TopViewAnimHelper.getInstance().enterVrMode();
|
||||
// TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
|
||||
showVrModeNaviView();
|
||||
mNaviInfo = vrModeNavInfoView;
|
||||
adasNoticeHelper.enterVrMode();
|
||||
mCameraLiveNoticeHelper.enterVrMode();
|
||||
TrafficLightPanelManager.getInstance().showNavPanel();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG,this);
|
||||
|
||||
}
|
||||
|
||||
private void exitVrMode(){
|
||||
@@ -529,11 +527,11 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
tvExitVrMode.setVisibility(View.GONE);
|
||||
TopViewAnimHelper.getInstance().exitVrMode();
|
||||
// TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
|
||||
hideVrModeNaviView();
|
||||
mNaviInfo = animNavInfoView;
|
||||
adasNoticeHelper.exitVrMode();
|
||||
mCameraLiveNoticeHelper.exitVrMode();
|
||||
TrafficLightPanelManager.getInstance().hideNavPanel();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
}
|
||||
|
||||
private void debugCrashWarn(){
|
||||
@@ -1183,12 +1181,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
// }
|
||||
}
|
||||
|
||||
private static int SEEK_HELP_NOTICE_NUM_MSG_TYPE = 401015;
|
||||
private static final int SEEK_HELP_NOTICE_NUM_MSG_TYPE = 401015;
|
||||
|
||||
private IMogoOnMessageListener<String> seekHelpNoticeListener =
|
||||
private final IMogoOnMessageListener<String> seekHelpNoticeListener =
|
||||
new IMogoOnMessageListener<String>() {
|
||||
@Override
|
||||
public Class target() {
|
||||
public Class<String> target() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@@ -1206,7 +1204,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
};
|
||||
|
||||
private Handler handler = new Handler();
|
||||
private final Handler handler = new Handler();
|
||||
|
||||
private void listenSeekNumber() {
|
||||
mApis.getSocketManagerApi(getContext()).registerOnMessageListener(SEEK_HELP_NOTICE_NUM_MSG_TYPE, seekHelpNoticeListener);
|
||||
@@ -1235,14 +1233,10 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mApis.getSocketManagerApi(getContext()).unregisterOnMessageListener(SEEK_HELP_NOTICE_NUM_MSG_TYPE, seekHelpNoticeListener);
|
||||
}
|
||||
|
||||
TrafficLightPanelManager.getInstance().release();
|
||||
}
|
||||
|
||||
private void showVrModeNaviView(){
|
||||
|
||||
}
|
||||
|
||||
private void hideVrModeNaviView(){
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
vrModeNavInfoView.refreshCurrentSpeed((int) (location.getSpeed() * 3.6F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class AnimNavInfoView extends BaseNaviInfoView {
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return turnIcon != null && turnIcon.getVisibility() == View.VISIBLE;
|
||||
return getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,9 @@ public class AnimNavInfoView extends BaseNaviInfoView {
|
||||
}
|
||||
|
||||
public void exchangeToSmall(boolean smooth) {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (smooth) {
|
||||
TransitionManager.beginDelayedTransition(this);
|
||||
}
|
||||
@@ -167,6 +170,9 @@ public class AnimNavInfoView extends BaseNaviInfoView {
|
||||
}
|
||||
|
||||
public void exchangeToBig(boolean smooth) {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (smooth) {
|
||||
TransitionManager.beginDelayedTransition(this);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,38 @@
|
||||
package com.mogo.module.extensions.navi;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.view.VerticalTrafficLightView;
|
||||
|
||||
/**
|
||||
* vr模式下导航信息封装
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class VrModeNavInfoView extends BaseNaviInfoView {
|
||||
public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callback {
|
||||
|
||||
private final Group speedGroup, navGroup;
|
||||
private final TextView tvLimitSpeed;
|
||||
private final VerticalTrafficLightView turnAroundLight, turnLeftLight, straightLight, turnRightLight;
|
||||
|
||||
private final ImageView ivTurnIcon;
|
||||
private final TextView tvDistance,tvDistanceUnit, tvNextRoad;
|
||||
|
||||
private final TextView tvCurrentSpeed;
|
||||
|
||||
private final Handler handler = new Handler(this);
|
||||
|
||||
public VrModeNavInfoView(Context context) {
|
||||
this(context,null);
|
||||
@@ -23,15 +44,91 @@ public class VrModeNavInfoView extends BaseNaviInfoView {
|
||||
|
||||
public VrModeNavInfoView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
LayoutInflater.from(context).inflate(R.layout.include_navi_in_vr, this);
|
||||
speedGroup = findViewById(R.id.module_ext_id_group_navi_in_vr_speed);
|
||||
navGroup = findViewById(R.id.module_ext_id_group_navi_in_vr_nav_info);
|
||||
tvLimitSpeed = findViewById(R.id.module_ext_id_tv_limit_speed);
|
||||
turnAroundLight = findViewById(R.id.module_ext_id_traffic_light_turn_around);
|
||||
turnLeftLight = findViewById(R.id.module_ext_id_traffic_light_turn_left);
|
||||
straightLight = findViewById(R.id.module_ext_id_traffic_light_straight);
|
||||
turnRightLight = findViewById(R.id.module_ext_id_traffic_light_turn_right);
|
||||
|
||||
tvCurrentSpeed = findViewById(R.id.module_ext_id_tv_speed);
|
||||
|
||||
ivTurnIcon = findViewById(R.id.module_map_id_navi_next_info_road_turn_icon_in_vr_mode);
|
||||
tvDistance = findViewById(R.id.module_map_id_navi_next_info_distance_in_vr_mode);
|
||||
tvDistanceUnit = findViewById(R.id.module_map_id_navi_next_info_distance_unit_in_vr_mode);
|
||||
tvNextRoad = findViewById(R.id.module_map_id_navi_next_info_road_in_vr_mode);
|
||||
}
|
||||
|
||||
public void startNav() {
|
||||
navGroup.setVisibility(View.VISIBLE);
|
||||
speedGroup.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void stopNav() {
|
||||
speedGroup.setVisibility(View.VISIBLE);
|
||||
navGroup.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void refreshLimitSpeed(int limitSpeed) {
|
||||
handler.removeMessages(MSG_HIDE_LIMIT_SPEED);
|
||||
tvLimitSpeed.setVisibility(View.VISIBLE);
|
||||
tvLimitSpeed.setText(String.valueOf(limitSpeed));
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_LIMIT_SPEED, HIDE_LIMIT_SPEED_DELAY);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void refreshCurrentSpeed(int speed) {
|
||||
if (speedGroup.getVisibility() == View.VISIBLE) {
|
||||
tvCurrentSpeed.setText(Integer.toString(speed));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新红绿灯显示状态
|
||||
*
|
||||
* @param laneLight 固定数组长度为4的车道类型灯,从0-3依次代表 掉头,左转,执行,右转
|
||||
* @param surplusTime 固定数组长度为4的剩余时长数组,从0-3依次代表 掉头,左转,执行,右转
|
||||
*/
|
||||
public void refreshTrafficLightStatus(int[] laneLight, String[] surplusTime) {
|
||||
turnAroundLight.setTrafficLightStatus(laneLight[0], surplusTime[0]);
|
||||
turnLeftLight.setTrafficLightStatus(laneLight[1], surplusTime[1]);
|
||||
straightLight.setTrafficLightStatus(laneLight[2], surplusTime[2]);
|
||||
turnRightLight.setTrafficLightStatus(laneLight[3], surplusTime[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChanged(MogoNaviInfo naviInfo) {
|
||||
if (naviInfo == null) {
|
||||
return;
|
||||
}
|
||||
fillNextCrossDistance(tvDistance, tvDistanceUnit, naviInfo.getCurStepRetainDistance());
|
||||
fillNextCrossIconType(ivTurnIcon, naviInfo.getIconResId());
|
||||
tvNextRoad.setText(naviInfo.getNextRoadName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
handler.removeMessages(MSG_HIDE_LIMIT_SPEED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return navGroup.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
private static final int MSG_HIDE_LIMIT_SPEED = 1001;
|
||||
private static final long HIDE_LIMIT_SPEED_DELAY = 5000;
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (!isAttachedToWindow()||getVisibility() != View.VISIBLE) {
|
||||
return false;
|
||||
}
|
||||
if (msg.what == MSG_HIDE_LIMIT_SPEED) {
|
||||
tvLimitSpeed.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.os.Handler;
|
||||
import android.transition.Transition;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -18,7 +17,9 @@ import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.AnimNavInfoView;
|
||||
import com.mogo.module.extensions.navi.BaseNaviInfoView;
|
||||
import com.mogo.module.extensions.navi.TopView;
|
||||
import com.mogo.module.extensions.navi.VrModeNavInfoView;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -39,7 +40,8 @@ public class TopViewAnimHelper {
|
||||
private TopView topContainer;
|
||||
|
||||
private TextView cameraMode;
|
||||
private AnimNavInfoView navInfoView;
|
||||
private AnimNavInfoView animNavInfoView;
|
||||
private VrModeNavInfoView vrModeNavInfoView;
|
||||
|
||||
private float topHeight = 0f;
|
||||
|
||||
@@ -74,7 +76,8 @@ public class TopViewAnimHelper {
|
||||
public void init(ConstraintLayout rootView, OnTopViewAnimSimpleListener listener) {
|
||||
topMotionLayout = rootView;
|
||||
topContainer = rootView.findViewById(R.id.module_entrance_id_top_container);
|
||||
navInfoView = rootView.findViewById(R.id.module_ext_id_anim_nav_info);
|
||||
animNavInfoView = rootView.findViewById(R.id.module_ext_id_anim_nav_info);
|
||||
vrModeNavInfoView = rootView.findViewById(R.id.module_ext_id_vr_nav_info);
|
||||
|
||||
topContainer.setSlideListener(this::startLatestTopOutAnim);
|
||||
|
||||
@@ -244,8 +247,8 @@ public class TopViewAnimHelper {
|
||||
if (statusListenerMap.get(view) != null) {
|
||||
statusListenerMap.get(view).beforeViewAddAnim(view);
|
||||
}
|
||||
if (navInfoView.isVisible()) {
|
||||
navInfoView.animate().translationY(computeNaviMarginTop(params.height)).start();
|
||||
if (animNavInfoView.isVisible()) {
|
||||
animNavInfoView.animate().translationY(computeNaviMarginTop(params.height)).start();
|
||||
}
|
||||
view.animate().translationY(0).setDuration(500).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
@@ -288,10 +291,10 @@ public class TopViewAnimHelper {
|
||||
NoMapTopViewShaderHelper.getInstance().showShader();
|
||||
checkCameraModePosition(false);
|
||||
int scene = 0;
|
||||
if (navInfoView.isVisible()) {
|
||||
if (animNavInfoView.isVisible()) {
|
||||
scene = Scene.NAVI_WITH_ROAD_EVENT;
|
||||
navInfoView.animate().translationY(computeNaviMarginTop(child.getHeight())).start();
|
||||
navInfoView.exchangeToSmall(true);
|
||||
animNavInfoView.animate().translationY(computeNaviMarginTop(child.getHeight())).start();
|
||||
animNavInfoView.exchangeToSmall(true);
|
||||
} else {
|
||||
scene = Scene.AIMLESS_WITH_ROAD_EVENT;
|
||||
}
|
||||
@@ -340,9 +343,9 @@ public class TopViewAnimHelper {
|
||||
checkCameraModePosition(false);
|
||||
|
||||
int scene = 0;
|
||||
if (navInfoView.isVisible()) {
|
||||
navInfoView.animate().translationY(0).start();
|
||||
navInfoView.exchangeToBig(true);
|
||||
if (animNavInfoView.isVisible()) {
|
||||
animNavInfoView.animate().translationY(0).start();
|
||||
animNavInfoView.exchangeToBig(true);
|
||||
scene = Scene.NAVI;
|
||||
} else {
|
||||
scene = Scene.AIMLESS;
|
||||
@@ -359,14 +362,18 @@ public class TopViewAnimHelper {
|
||||
}
|
||||
|
||||
Logger.d("TopViewAnimHelper", "showNaviView=====");
|
||||
setNaviVisibility(View.VISIBLE);
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()){
|
||||
vrModeNavInfoView.startNav();
|
||||
}else {
|
||||
animNavInfoView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
int scene = 0;
|
||||
if (isTopViewOut) {
|
||||
scene = Scene.NAVI_WITH_ROAD_EVENT;
|
||||
navInfoView.exchangeToBig(false);
|
||||
animNavInfoView.exchangeToBig(false);
|
||||
} else {
|
||||
scene = Scene.NAVI;
|
||||
navInfoView.exchangeToSmall(false);
|
||||
animNavInfoView.exchangeToSmall(false);
|
||||
}
|
||||
Logger.d(TAG, "navi show setMapCenterPointByScene: " + scene);
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, scene);
|
||||
@@ -379,7 +386,8 @@ public class TopViewAnimHelper {
|
||||
}
|
||||
|
||||
Logger.d("TopViewAnimHelper", "hideNaviView=====");
|
||||
setNaviVisibility(View.GONE);
|
||||
animNavInfoView.setVisibility(View.GONE);
|
||||
vrModeNavInfoView.stopNav();
|
||||
int scene = 0;
|
||||
if (isTopViewOut) {
|
||||
scene = Scene.AIMLESS;
|
||||
@@ -414,10 +422,6 @@ public class TopViewAnimHelper {
|
||||
return viewCaches.contains(view);
|
||||
}
|
||||
|
||||
private void setNaviVisibility(int visibility) {
|
||||
navInfoView.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void removeAllView(){
|
||||
Logger.d(TAG, "remove all view");
|
||||
isTopViewOut = true;
|
||||
@@ -433,6 +437,7 @@ public class TopViewAnimHelper {
|
||||
}
|
||||
topContainer.removeAllViews();
|
||||
hideNaviView();
|
||||
vrModeNavInfoView.setVisibility(View.GONE);
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, Scene.AIMLESS);
|
||||
}
|
||||
|
||||
@@ -445,6 +450,7 @@ public class TopViewAnimHelper {
|
||||
public void enterVrMode(){
|
||||
removeAllView();
|
||||
topContainer.getLayoutParams().width = (int) getDimen(R.dimen.module_ext_top_view_width_in_vr_mode);
|
||||
vrModeNavInfoView.setVisibility(View.VISIBLE);
|
||||
// topContainer.requestLayout();
|
||||
// topMotionLayout.requestLayout();
|
||||
}
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.view.VerticalTrafficLightView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 红绿灯面板管理类,控制各部分显示隐藏,同时控制限速、车速、红绿灯信息展示
|
||||
* <p>
|
||||
* 导航信息内容通过{@link com.mogo.module.extensions.navi.VrModeNavInfoView} 在{@link com.mogo.module.extensions.entrance.EntranceFragment}进行控制
|
||||
* 此处仅控制导航信息的显示与隐藏
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class TrafficLightPanelManager implements Handler.Callback, View.OnClickListener {
|
||||
private static final String TAG = "TrafficLightPanelManager";
|
||||
|
||||
private TrafficLightPanelManager() {
|
||||
}
|
||||
|
||||
private final static TrafficLightPanelManager INSTANCE = new TrafficLightPanelManager();
|
||||
|
||||
public static TrafficLightPanelManager getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Group speedGroup, navGroup, extraGroup;
|
||||
private TextView tvLimitSpeed;
|
||||
private VerticalTrafficLightView turnAroundLight, turnLeftLight, straightLight, turnRightLight;
|
||||
|
||||
private Handler handler = new Handler(this);
|
||||
|
||||
private boolean isInit = false;
|
||||
|
||||
public void initPanel(View root) {
|
||||
speedGroup = root.findViewById(R.id.module_ext_id_group_navi_in_vr_speed);
|
||||
navGroup = root.findViewById(R.id.module_ext_id_group_navi_in_vr_nav_info);
|
||||
extraGroup = root.findViewById(R.id.module_ext_id_group_traffic_light_panel_extra);
|
||||
tvLimitSpeed = root.findViewById(R.id.module_ext_id_tv_limit_speed);
|
||||
turnAroundLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_around);
|
||||
turnLeftLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_left);
|
||||
straightLight = root.findViewById(R.id.module_ext_id_traffic_light_straight);
|
||||
turnRightLight = root.findViewById(R.id.module_ext_id_traffic_light_turn_right);
|
||||
isInit = true;
|
||||
|
||||
// debug
|
||||
// root.findViewById(R.id.module_ext_id_navi_in_vr_speed_bg).setOnClickListener(this);
|
||||
// root.findViewById(R.id.module_ext_id_navi_in_vr_traffic_bg).setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void showNavPanel() {
|
||||
if (!isInit) {
|
||||
Logger.e(TAG, "nav panel 未初始化");
|
||||
return;
|
||||
}
|
||||
// extraGroup.setVisibility(View.VISIBLE);
|
||||
// if (isNav) {
|
||||
// navGroup.setVisibility(View.VISIBLE);
|
||||
// speedGroup.setVisibility(View.GONE);
|
||||
// } else {
|
||||
// speedGroup.setVisibility(View.VISIBLE);
|
||||
// navGroup.setVisibility(View.GONE);
|
||||
// }
|
||||
// tvLimitSpeed.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hideNavPanel() {
|
||||
if (!isInit) {
|
||||
Logger.e(TAG, "nav panel 未初始化");
|
||||
return;
|
||||
}
|
||||
// extraGroup.setVisibility(View.GONE);
|
||||
// speedGroup.setVisibility(View.GONE);
|
||||
// tvLimitSpeed.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
private boolean isNav = false;
|
||||
|
||||
public void startNav() {
|
||||
isNav = true;
|
||||
// navGroup.setVisibility(View.VISIBLE);
|
||||
// speedGroup.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void stopNav() {
|
||||
isNav = false;
|
||||
// speedGroup.setVisibility(View.VISIBLE);
|
||||
// navGroup.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void refreshLimitSpeed(int limitSpeed) {
|
||||
handler.removeMessages(MSG_HIDE_LIMIT_SPEED);
|
||||
tvLimitSpeed.setVisibility(View.VISIBLE);
|
||||
tvLimitSpeed.setText(String.valueOf(limitSpeed));
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_LIMIT_SPEED, HIDE_LIMIT_SPEED_DELAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新红绿灯显示状态
|
||||
*
|
||||
* @param laneLight 固定数组长度为4的车道类型灯,从0-3依次代表 掉头,左转,执行,右转
|
||||
* @param surplusTime 固定数组长度为4的剩余时长数组,从0-3依次代表 掉头,左转,执行,右转
|
||||
*/
|
||||
public void refreshTrafficLightStatus(int[] laneLight, String[] surplusTime) {
|
||||
turnAroundLight.setTrafficLightStatus(laneLight[0], surplusTime[0]);
|
||||
turnLeftLight.setTrafficLightStatus(laneLight[1], surplusTime[1]);
|
||||
straightLight.setTrafficLightStatus(laneLight[2], surplusTime[2]);
|
||||
turnRightLight.setTrafficLightStatus(laneLight[3], surplusTime[3]);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
isInit = false;
|
||||
speedGroup = null;
|
||||
navGroup = null;
|
||||
extraGroup = null;
|
||||
tvLimitSpeed = null;
|
||||
turnAroundLight = null;
|
||||
turnLeftLight = null;
|
||||
straightLight = null;
|
||||
turnRightLight = null;
|
||||
}
|
||||
|
||||
private static final int MSG_HIDE_LIMIT_SPEED = 1001;
|
||||
private static final long HIDE_LIMIT_SPEED_DELAY = 5000;
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (!isInit) {
|
||||
return false;
|
||||
}
|
||||
if (msg.what == MSG_HIDE_LIMIT_SPEED) {
|
||||
tvLimitSpeed.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.module_ext_id_navi_in_vr_speed_bg) {
|
||||
boolean s = new Random().nextBoolean();
|
||||
boolean b = new Random().nextBoolean();
|
||||
if (s) {
|
||||
if (b) {
|
||||
startNav();
|
||||
} else {
|
||||
stopNav();
|
||||
}
|
||||
} else {
|
||||
refreshLimitSpeed(90);
|
||||
}
|
||||
} else {
|
||||
int[] color = new int[4];
|
||||
String[] time = new String[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int s = new Random().nextInt(4);
|
||||
boolean b = new Random().nextBoolean();
|
||||
color[i] = s;
|
||||
time[i] = b ? "12" : "";
|
||||
}
|
||||
refreshTrafficLightStatus(color, time);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user