完成了自动驾驶按钮的点击触发逻辑抽离

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-23 10:57:34 +08:00
parent 808e772cce
commit d80348b32f
15 changed files with 210 additions and 186 deletions

View File

@@ -1,5 +1,20 @@
package com.mogo.module.extensions.entrance;
import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
import static com.mogo.module.common.utils.SPConst.getSpGuide;
import static com.mogo.module.extensions.ExtensionsModuleConst.TYPE_ENTRANCE;
import static com.mogo.module.service.receiver.MogoReceiver.ACTION_V2X_REMOVE_TIP_WINDOW;
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_BUTTON;
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_TIME;
import static com.mogo.module.share.constant.ShareConstants.KEY_SERVER_SHOW_DAY_COUNT;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE_TIME;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE_TIME;
import static com.mogo.module.share.constant.ShareConstants.ONE_DAY_TIME;
import static com.mogo.module.share.constant.ShareConstants.SEVEN_DAY_TIME;
import static com.mogo.module.share.constant.ShareConstants.VOICE_ALERT_COUNT;
import android.content.Intent;
import android.graphics.Rect;
import android.location.Location;
@@ -71,8 +86,6 @@ import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.module.share.manager.ServiceApisManager;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.eagle.core.data.autopilot.AdasOCHData;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
import com.mogo.service.entrance.ButtonIndex;
@@ -100,21 +113,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Random;
import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
import static com.mogo.module.common.utils.SPConst.getSpGuide;
import static com.mogo.module.extensions.ExtensionsModuleConst.TYPE_ENTRANCE;
import static com.mogo.module.service.receiver.MogoReceiver.ACTION_V2X_REMOVE_TIP_WINDOW;
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_BUTTON;
import static com.mogo.module.share.constant.ShareConstants.KEY_CLICK_SHARE_TIME;
import static com.mogo.module.share.constant.ShareConstants.KEY_SERVER_SHOW_DAY_COUNT;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_INNER_GUIDE_TIME;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_OUTER_GUIDE_TIME;
import static com.mogo.module.share.constant.ShareConstants.ONE_DAY_TIME;
import static com.mogo.module.share.constant.ShareConstants.SEVEN_DAY_TIME;
import static com.mogo.module.share.constant.ShareConstants.VOICE_ALERT_COUNT;
/**
* @author congtaowang
* @since 2020-01-07
@@ -128,9 +126,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
IMogoAimlessModeListener,
IMogoStatusChangedListener,
IMogoIntentListener,
// IMogoLocationListener,
IMogoCheckListener ,
IMogoAdasOCHCallback,
// IMogoLocationListener,
IMogoCheckListener,
IMogoCarLocationChangedListener2 {
private static final String TAG = "EntranceFragment";
@@ -214,7 +211,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
private TextView tvRed;
private TextView tvGreen;
// private CheckedTextView ctvAutopilotStatus;
// private CheckedTextView ctvAutopilotStatus;
/**
* 内部变量标识是否在vrMode用于方法执行过滤避免重复或异常调用
@@ -284,7 +281,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMove2CurrentLocation = findViewById(R.id.module_entrance_id_move2_current_location);
mUserHeadImg = findViewById(R.id.ivUserHeadImg);
groupFix = findViewById(R.id.groupFix);
// ctvAutopilotStatus = findViewById(R.id.module_mogo_autopilot_status);
// ctvAutopilotStatus = findViewById(R.id.module_mogo_autopilot_status);
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
if (rootView != null) {
@@ -355,16 +352,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
});
}
// onAutopilotStatusChanged(
// MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
// ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
// @Override
// public void onClickImpl(View v) {
// // 如果能自动驾驶,就自动驾驶,不能就提示
// autopilotStatusClick();
// }
// });
// ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
// @Override
// public void onClickImpl(View v) {
// // 如果能自动驾驶,就自动驾驶,不能就提示
// autopilotStatusClick();
// }
// });
dealWeatherContainer();
@@ -399,7 +394,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
enterVrMode();
localIsVrMode = true;
}
// //检测入口
// //检测入口
jumpCheck = findViewById(R.id.module_ext_enter_check);
tipImageView = findViewById(R.id.error_tip_image);
jumpCheck.setOnClickListener(new View.OnClickListener() {
@@ -413,21 +408,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
// /**
// * 自动驾驶状态改变
// *
// * @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
// */
// public void onAutopilotStatusChanged(boolean isInAutopilot) {
// getActivity().runOnUiThread(() -> {
// ctvAutopilotStatus.setChecked(isInAutopilot);
// });
// }
private void autopilotStatusClick() {
EntranceViewHolder.getInstance().entranceAutopilotStatusClick();
}
private int debugPanelClickCount = 0;
private long lastDebugPanelClickTime = 0;
@@ -442,8 +422,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMsgContainer.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
// ctvAutopilotStatus.setVisibility(View.VISIBLE);
// tvExitVrMode.setVisibility(View.VISIBLE);
// tvExitVrMode.setVisibility(View.VISIBLE);
TopViewAnimHelper.getInstance().enterVrMode();
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
mNaviInfo = vrModeNavInfoView;
@@ -585,7 +564,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
if (intervalTime == 0) {
SharedPrefsMgr.getInstance(getContext()).putLong(KEY_SHARE_OUTER_GUIDE_TIME, time);
SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SHARE_OUTER_GUIDE, ++shareItemSum);
// AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[random.nextInt(3)]);
// AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[random.nextInt(3)]);
AIAssist.getInstance(getContext()).speakTTSVoice(mOuterGuideVoiceStrings[0]);
} else {
Logger.d(TAG, " playShareOuterGuideVoice else interval = " + (time - intervalTime));
@@ -744,7 +723,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMogoRegisterCenter.registerMogoNaviListener(TYPE_ENTRANCE, this);
mMogoRegisterCenter.registerMogoMapListener(TYPE_ENTRANCE, this);
//车辆监控
//车辆监控
CallerCheckManager.registerVehicleMonitoringListener(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, this);
mMogoMarkerManager = mService.getMarkerManager(getContext());
@@ -884,15 +863,15 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
} else {
mExitNavi.setText(R.string.module_ext_str_continue_navi);
}
// if ( isLock ) {
// if ( mMApUIController.getCurrentUiMode() == EnumMapUI.CarUp_2D ) {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_north_up );
// } else {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_car_up );
// }
// } else {
// mMove2CurrentLocation.setImageResource( R.drawable.module_map_ic_move2_current_location );
// }
// if ( isLock ) {
// if ( mMApUIController.getCurrentUiMode() == EnumMapUI.CarUp_2D ) {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_north_up );
// } else {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_car_up );
// }
// } else {
// mMove2CurrentLocation.setImageResource( R.drawable.module_map_ic_move2_current_location );
// }
}
private void traceData(String from) {
@@ -1007,14 +986,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
private void debugTopView() {
findViewById(R.id.btnDebugCtrlNaviView).setOnClickListener(view -> {
// SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705236512" +
// "&di=50620661ded7035fb84899a408f9f27e&imgtype=0&src=http%3A%2F%2Fb-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F201409%2F11%2F20140911211243_3rT4u.jpeg");
// MyLocationUtil.setMyLocationIconUrl(getContext(), "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705236512" +
// "&di=50620661ded7035fb84899a408f9f27e&imgtype=0&src=http%3A%2F%2Fb-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F201409%2F11%2F20140911211243_3rT4u.jpeg");
// SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705236512" +
// "&di=50620661ded7035fb84899a408f9f27e&imgtype=0&src=http%3A%2F%2Fb-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F201409%2F11%2F20140911211243_3rT4u.jpeg");
// MyLocationUtil.setMyLocationIconUrl(getContext(), "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705236512" +
// "&di=50620661ded7035fb84899a408f9f27e&imgtype=0&src=http%3A%2F%2Fb-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F201409%2F11%2F20140911211243_3rT4u.jpeg");
if (!toggle) {
TopViewAnimHelper.getInstance().showNaviView();
} else {
@@ -1024,7 +1003,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
});
findViewById(R.id.btnDebugCtrlSubView).setOnClickListener(view -> {
// MyLocationUtil.emphasizeMyLocation();
// MyLocationUtil.emphasizeMyLocation();
View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null);
TextView tv = v.findViewById(R.id.tvIndex);
tv.setText("sub view height: " + currentHeight + ": " + v);
@@ -1052,17 +1031,17 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
});
findViewById(R.id.btnDebugCtrlTopView).setOnClickListener(view -> {
// SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705508574" +
// "&di=339d3259ad21f5f48c8abcd1bafff324&imgtype=0&src=http%3A%2F%2Fc-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F202004%2F23%2F20200423111550_4AJLr.thumb" +
// ".1000_0.jpeg");
// MyLocationUtil.setMyLocationIconUrl(getContext(),"https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705508574" +
// "&di=339d3259ad21f5f48c8abcd1bafff324&imgtype=0&src=http%3A%2F%2Fc-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F202004%2F23%2F20200423111550_4AJLr.thumb" +
// ".1000_0.jpeg");
// MyLocationUtil.emphasizeMyLocation();
// SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705508574" +
// "&di=339d3259ad21f5f48c8abcd1bafff324&imgtype=0&src=http%3A%2F%2Fc-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F202004%2F23%2F20200423111550_4AJLr.thumb" +
// ".1000_0.jpeg");
// MyLocationUtil.setMyLocationIconUrl(getContext(),"https" +
// "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705508574" +
// "&di=339d3259ad21f5f48c8abcd1bafff324&imgtype=0&src=http%3A%2F%2Fc-ssl" +
// ".duitang.com%2Fuploads%2Fitem%2F202004%2F23%2F20200423111550_4AJLr.thumb" +
// ".1000_0.jpeg");
// MyLocationUtil.emphasizeMyLocation();
View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null);
TextView tv = v.findViewById(R.id.tvIndex);
Random random = new Random();
@@ -1070,7 +1049,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
tv.setText(" height: " + currentHeight + ": " + v);
ViewGroup.LayoutParams params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, currentHeight);
// mApis.getEntranceButtonController().addLeftFeatureView(v);
// mApis.getEntranceButtonController().addLeftFeatureView(v);
mApis.getTopViewManager().addView(v, params, new IMogoTopViewStatusListener() {
@Override
@@ -1113,12 +1092,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMsgContainer.setVisibility(View.GONE);
// String enthusiasmIndex = "一般的字加粗的字一般的字";
// SpannableString spannableStringUnSelectCountStr = new SpannableString(enthusiasmIndex);
// ForegroundColorSpan foregroundColorSpanUnSelectCount = new ForegroundColorSpan(Color.RED);
// spannableStringUnSelectCountStr.setSpan(foregroundColorSpanUnSelectCount, 4, 7, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//
// TipToast.tip(spannableStringUnSelectCountStr.toString());
// String enthusiasmIndex = "一般的字加粗的字一般的字";
// SpannableString spannableStringUnSelectCountStr = new SpannableString(enthusiasmIndex);
// ForegroundColorSpan foregroundColorSpanUnSelectCount = new ForegroundColorSpan(Color.RED);
// spannableStringUnSelectCountStr.setSpan(foregroundColorSpanUnSelectCount, 4, 7, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//
// TipToast.tip(spannableStringUnSelectCountStr.toString());
TipDrawable drawable =
new TipDrawable(getResources().getDrawable(R.drawable.model_ext_default_user_head));
TipToast.tip("分享成功", drawable);
@@ -1135,11 +1114,11 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mCameraMode.setSelected(ui == EnumMapUI.NorthUP_2D);
mCameraMode.setText(getString(ui == EnumMapUI.NorthUP_2D ? R.string.mode_car_up : R.string.mode_north_up));
// if ( ui == EnumMapUI.CarUp_2D ) {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_north_up );
// } else if( ui == EnumMapUI.NorthUP_2D ){
// mMove2CurrentLocation.setImageResource( R.drawable.icon_car_up );
// }
// if ( ui == EnumMapUI.CarUp_2D ) {
// mMove2CurrentLocation.setImageResource( R.drawable.icon_north_up );
// } else if( ui == EnumMapUI.NorthUP_2D ){
// mMove2CurrentLocation.setImageResource( R.drawable.icon_car_up );
// }
}
@@ -1423,20 +1402,13 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
@Override
public void updateMonitoringStatus(boolean hasError){
Log.d(TAG,"updateCheckStatus");
if(hasError==true){
tipImageView.setVisibility(View.VISIBLE);
}else{
tipImageView.setVisibility(View.INVISIBLE);
public void updateMonitoringStatus(boolean hasError) {
Log.d(TAG, "updateCheckStatus");
if (hasError == true) {
tipImageView.setVisibility(View.VISIBLE);
} else {
tipImageView.setVisibility(View.INVISIBLE);
}
}
public void onArriveAt(AdasOCHData data) {
}
@Override
public void onStateChanged(int state, String reason) {
// ctvAutopilotStatus.setChecked(state == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING);
}
}

View File

@@ -8,7 +8,6 @@ import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.extensions.utils.EntranceViewHolder;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.entrance.IMogoEntranceAutopilotStatusClickListener;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.service.windowview.IMogoEntranceViewListener;
@@ -71,16 +70,6 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
EntranceViewHolder.getInstance().removeEntranceViewListener(listener);
}
@Override
public void addEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) {
EntranceViewHolder.getInstance().addEntranceAutopilotStatusClickListener(listener);
}
@Override
public void removeEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) {
EntranceViewHolder.getInstance().removeEntranceAutopilotStatusClickListener(listener);
}
@Override
public void init( Context context ) {

View File

@@ -12,7 +12,6 @@ import android.widget.TextView;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.bean.BottomLayerViewWrapper;
import com.mogo.service.entrance.IMogoEntranceAutopilotStatusClickListener;
import com.mogo.service.windowview.IMogoEntranceViewListener;
import com.mogo.utils.logger.Logger;
@@ -133,7 +132,7 @@ public class EntranceViewHolder {
View v = wrapper.getView();
v.setLayoutParams(params);
rootViewGroup.addView(v, 0);
// rootViewGroup.setBackgroundColor(Color.WHITE);
// rootViewGroup.setBackgroundColor(Color.WHITE);
}
public void removeBottomLayerView(View view) {
@@ -270,7 +269,6 @@ public class EntranceViewHolder {
}
private final List<IMogoEntranceViewListener> listeners = new ArrayList<>();
private final List<IMogoEntranceAutopilotStatusClickListener> btnClickListeners = new ArrayList<>();
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
listeners.add(listener);
@@ -280,20 +278,6 @@ public class EntranceViewHolder {
listeners.remove(listener);
}
public void addEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) {
btnClickListeners.add(listener);
}
public void removeEntranceAutopilotStatusClickListener(IMogoEntranceAutopilotStatusClickListener listener) {
btnClickListeners.remove(listener);
}
public void entranceAutopilotStatusClick() {
for (IMogoEntranceAutopilotStatusClickListener listener : btnClickListeners) {
listener.click();
}
}
public void release() {
rootViewGroup = null;
featureViewGroup = null;