Merge branch 'dev/dev_eagle_architecture_upgrade' into dev/dev_eagle_check
# Conflicts: # app/build.gradle # app/src/main/java/com/mogo/launcher/MogoApplication.java # gradle.properties # modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java # modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java # services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java # services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java # services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -69,13 +67,16 @@ 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.view.ArcView;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.share.manager.ServiceApisManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
<<<<<<< HEAD
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
=======
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||
import com.mogo.service.adas.entity.AdasOCHData;
|
||||
>>>>>>> dev/dev_eagle_architecture_upgrade
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
|
||||
import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.service.fragmentmanager.IFragmentProvider;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
@@ -103,7 +104,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
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;
|
||||
@@ -132,10 +132,15 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
IMogoAimlessModeListener,
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener,
|
||||
<<<<<<< HEAD
|
||||
// IMogoLocationListener,
|
||||
IMogoCarLocationChangedListener2,
|
||||
IMogoCheckListener {
|
||||
|
||||
=======
|
||||
IMogoAdasOCHCallback,
|
||||
IMogoCarLocationChangedListener2 {
|
||||
>>>>>>> dev/dev_eagle_architecture_upgrade
|
||||
|
||||
private static final String TAG = "EntranceFragment";
|
||||
|
||||
@@ -213,13 +218,12 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private TextView tvExitVrMode;
|
||||
|
||||
|
||||
private FrameLayout flSpeed;
|
||||
private ArcView mouduleArc;
|
||||
private ConstraintLayout clTrafficLight;
|
||||
private TextView tvYellow;
|
||||
private TextView tvRed;
|
||||
private TextView tvGreen;
|
||||
|
||||
private CheckedTextView ctvAutopilotStatus;
|
||||
|
||||
/**
|
||||
* 内部变量标识是否在vrMode,用于方法执行过滤,避免重复或异常调用
|
||||
@@ -289,6 +293,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);
|
||||
|
||||
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
|
||||
if (rootView != null) {
|
||||
@@ -359,6 +364,17 @@ 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();
|
||||
}
|
||||
});
|
||||
|
||||
dealWeatherContainer();
|
||||
|
||||
listenSeekNumber();
|
||||
@@ -377,6 +393,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
// 根据本地配置设置自车图标
|
||||
MyLocationUtil.setMyLocationIconUrl(getContext());
|
||||
|
||||
<<<<<<< HEAD
|
||||
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
|
||||
mouduleArc = (ArcView) findViewById(R.id.moudule_arc);
|
||||
if (DebugConfig.isDebug()) {
|
||||
@@ -389,6 +406,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
return true;
|
||||
});
|
||||
}
|
||||
=======
|
||||
>>>>>>> dev/dev_eagle_architecture_upgrade
|
||||
clTrafficLight = (ConstraintLayout) findViewById(R.id.cl_traffic_light);
|
||||
tvYellow = (TextView) findViewById(R.id.tv_yellow);
|
||||
tvRed = (TextView) findViewById(R.id.tv_red);
|
||||
@@ -418,6 +437,21 @@ 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;
|
||||
|
||||
@@ -431,7 +465,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mWeatherContainer.setVisibility(View.GONE);
|
||||
mMsgContainer.setVisibility(View.GONE);
|
||||
groupUserHead.setVisibility(View.GONE);
|
||||
seekHelpGroup.setVisibility(View.GONE);
|
||||
groupUserHead.setVisibility(View.GONE);
|
||||
ctvAutopilotStatus.setVisibility(View.VISIBLE);
|
||||
// tvExitVrMode.setVisibility(View.VISIBLE);
|
||||
TopViewAnimHelper.getInstance().enterVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
|
||||
@@ -443,7 +478,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
|
||||
localIsVrMode = true;
|
||||
flSpeed.setVisibility(View.VISIBLE);
|
||||
mSwitchMapModeLayout.setVisibility(View.VISIBLE);
|
||||
mApis.getV2XListenerManager().changeTipWindowStatusForListener(ACTION_V2X_REMOVE_TIP_WINDOW);
|
||||
}
|
||||
@@ -457,10 +491,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
|
||||
seekHelpGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// mWeatherContainer.setVisibility(View.VISIBLE);
|
||||
// mMsgContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
// tvExitVrMode.setVisibility(View.GONE);
|
||||
TopViewAnimHelper.getInstance().exitVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
|
||||
mNaviInfo = animNavInfoView;
|
||||
@@ -469,7 +499,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
localIsVrMode = false;
|
||||
flSpeed.setVisibility(View.GONE);
|
||||
mSwitchMapModeLayout.setVisibility(View.GONE);
|
||||
clTrafficLight.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -759,12 +788,10 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
getContext().getResources().getStringArray(R.array.search_voice_guide_outer_array);
|
||||
|
||||
//TODO 因为衡阳6.30交付没有2D模式,临时方案,进入vr模式,不可缩放地图
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
// 进入鹰眼模式,设置手势缩放地图失效
|
||||
Logger.d(TAG, "进入vr模式");
|
||||
mMApUIController.changeMapMode(EnumMapUI.Type_VR);
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true);
|
||||
}
|
||||
// 进入鹰眼模式,设置手势缩放地图失效
|
||||
Logger.d(TAG, "进入vr模式");
|
||||
mMApUIController.changeMapMode(EnumMapUI.Type_VR);
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true);
|
||||
|
||||
}
|
||||
|
||||
@@ -1412,10 +1439,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location location) {
|
||||
vrModeNavInfoView.refreshCurrentSpeed((int) (location.getSpeed() * 3.6F));
|
||||
int speed = (int) (location.getSpeed() * 3.6F);
|
||||
mouduleArc.setArcColor(Color.parseColor(speed > 60 ? "#DB3137" : "#3E77F6"));
|
||||
mouduleArc.setValues(speed);
|
||||
flSpeed.setBackgroundResource(speed > 60 ? R.drawable.yi_biao_pan_bg_speeding : R.drawable.yi_biao_pan_bg_nor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1424,6 +1447,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public void updateMonitoringStatus(boolean hasError) {
|
||||
Log.d(TAG, "updateCheckStatus");
|
||||
if (hasError == true) {
|
||||
@@ -1431,5 +1455,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
} 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);
|
||||
>>>>>>> dev/dev_eagle_architecture_upgrade
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
|
||||
@@ -70,6 +71,16 @@ 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 ) {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class MogoEntranceButtons {
|
||||
|
||||
private static Map< ButtonIndex, TextView > sButtons = new HashMap<>();
|
||||
private static final Map< ButtonIndex, TextView > sButtons = new HashMap<>();
|
||||
|
||||
public static void save( ButtonIndex index, TextView btn ) {
|
||||
sButtons.put( index, btn );
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.extensions.live;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
@@ -11,9 +10,8 @@ import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.cloud.socket.IMogoSocketManager;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.eventpanel.IEventPanelProvider;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import static com.mogo.service.entrance.IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -10,6 +12,7 @@ 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;
|
||||
|
||||
@@ -17,20 +20,20 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.service.entrance.IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP;
|
||||
|
||||
/**
|
||||
* 入口页view管理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class EntranceViewHolder {
|
||||
private static final String TAG = "EntranceViewHolder";
|
||||
private List<BottomLayerViewWrapper> preAddView = new ArrayList<>();
|
||||
private List<View> leftFeaturePreAddView = new ArrayList<>();
|
||||
private View preAddLeftNoticeView = null;
|
||||
private EntranceViewHolder(){}
|
||||
|
||||
private EntranceViewHolder() {
|
||||
}
|
||||
|
||||
private volatile static EntranceViewHolder instance = null;
|
||||
public static EntranceViewHolder getInstance(){
|
||||
|
||||
public static EntranceViewHolder getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (EntranceViewHolder.class) {
|
||||
if (instance == null) {
|
||||
@@ -40,13 +43,18 @@ public class EntranceViewHolder {
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<BottomLayerViewWrapper> preAddView = new ArrayList<>();
|
||||
private final List<View> leftFeaturePreAddView = new ArrayList<>();
|
||||
private View preAddLeftNoticeView = null;
|
||||
|
||||
private ViewGroup rootViewGroup = null;
|
||||
private ViewGroup featureViewGroup = null;
|
||||
private ViewGroup leftNoticeContainer = null;
|
||||
|
||||
public void initRootViewGroup(View rootView) {
|
||||
Logger.i(TAG, "initRootViewGroup==");
|
||||
if(rootView instanceof ViewGroup) {
|
||||
if (rootView instanceof ViewGroup) {
|
||||
Logger.d(TAG, "initRootViewGroup 赋值");
|
||||
rootViewGroup = (ViewGroup) rootView.getParent();
|
||||
leftNoticeContainer =
|
||||
@@ -82,12 +90,12 @@ public class EntranceViewHolder {
|
||||
Logger.d(TAG, "addBottomLayerView, rootViewGroup is null: " + (rootViewGroup == null) +
|
||||
"\n x: " + x + ", y: " + y);
|
||||
BottomLayerViewWrapper wrapper = new BottomLayerViewWrapper(view, x, y);
|
||||
if(rootViewGroup == null) {
|
||||
if(!preAddView.contains(wrapper)) {
|
||||
if (rootViewGroup == null) {
|
||||
if (!preAddView.contains(wrapper)) {
|
||||
preAddView.add(wrapper);
|
||||
}
|
||||
}else{
|
||||
if(!containView(view)) {
|
||||
} else {
|
||||
if (!containView(view)) {
|
||||
realAddView(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +104,7 @@ public class EntranceViewHolder {
|
||||
private boolean containView(View view) {
|
||||
int count = rootViewGroup.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if(rootViewGroup.getChildAt(i).equals(view)){
|
||||
if (rootViewGroup.getChildAt(i).equals(view)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +114,7 @@ public class EntranceViewHolder {
|
||||
private boolean containFeatureView(View view) {
|
||||
int count = featureViewGroup.getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if(featureViewGroup.getChildAt(i).equals(view)){
|
||||
if (featureViewGroup.getChildAt(i).equals(view)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +124,7 @@ public class EntranceViewHolder {
|
||||
/**
|
||||
* 使用的时候需要预先判断rootViewGroup是否为空,本方法默认rootViewGroup不为空
|
||||
*/
|
||||
private void realAddView(BottomLayerViewWrapper wrapper){
|
||||
private void realAddView(BottomLayerViewWrapper wrapper) {
|
||||
FrameLayout.LayoutParams params =
|
||||
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
@@ -145,10 +153,10 @@ public class EntranceViewHolder {
|
||||
Logger.d(TAG, "addLeftFeatureView==" + view);
|
||||
if (featureViewGroup == null) {
|
||||
// 先缓存起来,等待时机加载
|
||||
if(!leftFeaturePreAddView.contains(view)) {
|
||||
if (!leftFeaturePreAddView.contains(view)) {
|
||||
leftFeaturePreAddView.add(view);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 直接加载
|
||||
if (!containFeatureView(view)) {
|
||||
featureViewGroup.addView(view);
|
||||
@@ -171,7 +179,7 @@ public class EntranceViewHolder {
|
||||
|
||||
|
||||
public void showLeftNoticeView(View view) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (leftNoticeContainer != null) {
|
||||
realShowLeftNoticeView(view);
|
||||
} else {
|
||||
@@ -181,7 +189,7 @@ public class EntranceViewHolder {
|
||||
}
|
||||
|
||||
public void hideLeftNoticeView(View view) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (preAddLeftNoticeView != null && preAddLeftNoticeView == view) {
|
||||
preAddLeftNoticeView = null;
|
||||
}
|
||||
@@ -191,7 +199,7 @@ public class EntranceViewHolder {
|
||||
}
|
||||
}
|
||||
|
||||
public void forceHideNoticeView(){
|
||||
public void forceHideNoticeView() {
|
||||
for (IMogoEntranceViewListener listener : listeners) {
|
||||
listener.onViewRemoved(currentShowNoticeType);
|
||||
}
|
||||
@@ -203,8 +211,9 @@ public class EntranceViewHolder {
|
||||
}
|
||||
|
||||
private int currentShowNoticeType = 0;
|
||||
public void showLeftNoticeByType(int noticeType, int iconRes, String content){
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
|
||||
public void showLeftNoticeByType(int noticeType, int iconRes, String content) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (currentShowNoticeType != noticeType && currentShowNoticeType != 0) {
|
||||
for (IMogoEntranceViewListener listener : listeners) {
|
||||
listener.onViewRemoved(currentShowNoticeType);
|
||||
@@ -221,21 +230,21 @@ public class EntranceViewHolder {
|
||||
}
|
||||
|
||||
public void hideLeftNoticeByType(int noticeType) {
|
||||
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (currentShowNoticeType == noticeType) {
|
||||
forceHideNoticeView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private View generateNoticeViewByType(int noticeType,int iconRes, String content) {
|
||||
private View generateNoticeViewByType(int noticeType, int iconRes, String content) {
|
||||
View view =
|
||||
LayoutInflater.from(leftNoticeContainer.getContext()).inflate(R.layout.item_vr_left_notice, leftNoticeContainer, false);
|
||||
ImageView icon = view.findViewById(R.id.module_ext_iv_left_notice_icon);
|
||||
if (noticeType == NOTICE_TYPE_SEEK_HELP) {
|
||||
// 自车求助,是橘色的背景
|
||||
icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_orange_bg);
|
||||
}else{
|
||||
} else {
|
||||
// 其他是红色背景
|
||||
icon.setBackgroundResource(R.drawable.module_ext_left_notice_icon_red_bg);
|
||||
}
|
||||
@@ -245,7 +254,7 @@ public class EntranceViewHolder {
|
||||
return view;
|
||||
}
|
||||
|
||||
private void realShowLeftNoticeView(View view){
|
||||
private void realShowLeftNoticeView(View view) {
|
||||
leftNoticeContainer.setVisibility(View.VISIBLE);
|
||||
leftNoticeContainer.removeAllViews();
|
||||
leftNoticeContainer.addView(view);
|
||||
@@ -260,7 +269,8 @@ public class EntranceViewHolder {
|
||||
leftNoticeContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private List<IMogoEntranceViewListener> listeners = new ArrayList<>();
|
||||
private final List<IMogoEntranceViewListener> listeners = new ArrayList<>();
|
||||
private final List<IMogoEntranceAutopilotStatusClickListener> btnClickListeners = new ArrayList<>();
|
||||
|
||||
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
listeners.add(listener);
|
||||
@@ -270,7 +280,21 @@ public class EntranceViewHolder {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void release(){
|
||||
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;
|
||||
leftNoticeContainer = null;
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.mogo.module.extensions.view;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.extensions.R;
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/3/24 16:20
|
||||
* describe:
|
||||
*/
|
||||
public class ArcView extends View {
|
||||
|
||||
//中心的文字描述
|
||||
private String mDes = "km/h";
|
||||
//根据数据显示的圆弧Paint
|
||||
private Paint mArcPaint;
|
||||
//圆弧颜色
|
||||
private int mArcColor;
|
||||
//圆弧的画笔的宽度
|
||||
private float mStrokeWith = getResources().getDimension(R.dimen.module_ext_arcView_stroke_with);
|
||||
//文字描述的paint
|
||||
private Paint mTextPaint;
|
||||
|
||||
//当前进度夹角大小
|
||||
private float mIncludedAngle = 0;
|
||||
//当前数据
|
||||
private int currentValue;
|
||||
//最大数据
|
||||
private int maxValue = 240;
|
||||
//圆弧背景的开始和结束间的夹角大小
|
||||
private float mAngle = 270;
|
||||
//上次绘制圆弧夹角
|
||||
private float lastAngle = 0;
|
||||
|
||||
public ArcView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ArcView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ArcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
//初始化paint
|
||||
initPaint();
|
||||
//绘制弧度
|
||||
drawArc(canvas);
|
||||
//绘制文本
|
||||
drawText(canvas);
|
||||
}
|
||||
|
||||
private void drawText(Canvas canvas) {
|
||||
Rect mRect = new Rect();
|
||||
String mValue = String.valueOf(currentValue);
|
||||
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
|
||||
//绘制中心的数值
|
||||
mTextPaint.getTextBounds(mValue, 0, mValue.length(), mRect);
|
||||
canvas.drawText(mValue, getWidth() / 2, getHeight() / 2 + mRect.height() / 2 - 10, mTextPaint);
|
||||
|
||||
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
|
||||
//绘制中心文字描述
|
||||
mTextPaint.setTextSize(getResources().getDimension(R.dimen.module_ext_arcView_des_text_size));
|
||||
mTextPaint.getTextBounds(mDes, 0, mDes.length(), mRect);
|
||||
canvas.drawText(mDes, getWidth() / 2, getHeight() * 17 / 20 + mRect.height() / 2, mTextPaint);
|
||||
}
|
||||
|
||||
private void drawArc(Canvas canvas) {
|
||||
//绘制圆弧背景
|
||||
RectF mRectF = new RectF(mStrokeWith, mStrokeWith, getWidth() - mStrokeWith, getHeight() - mStrokeWith);
|
||||
canvas.drawArc(mRectF, 135, mAngle, false, mArcPaint);
|
||||
|
||||
//绘制当前数值对应的圆弧
|
||||
mArcPaint.setColor(mArcColor);
|
||||
//根据当前数据绘制对应的圆弧
|
||||
canvas.drawArc(mRectF, 135, mIncludedAngle, false, mArcPaint);
|
||||
}
|
||||
|
||||
private void initPaint() {
|
||||
//圆弧的paint
|
||||
mArcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
//抗锯齿
|
||||
mArcPaint.setAntiAlias(true);
|
||||
mArcPaint.setColor(Color.parseColor("#151D4C"));
|
||||
//设置透明度(数值为0-255)
|
||||
mArcPaint.setAlpha(100);
|
||||
//设置画笔的画出的形状
|
||||
mArcPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mArcPaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
//设置画笔类型
|
||||
mArcPaint.setStyle(Paint.Style.STROKE);
|
||||
//画笔宽度
|
||||
mArcPaint.setStrokeWidth(mStrokeWith);
|
||||
|
||||
//中心文字的paint
|
||||
mTextPaint = new Paint();
|
||||
mTextPaint.setAntiAlias(true);
|
||||
mTextPaint.setColor(Color.parseColor("#FFFFFF"));
|
||||
//设置文本的对齐方式
|
||||
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||
//mTextPaint.setTextSize(getResources().getDimensionPixelSize(R.dimen.dp_12));
|
||||
mTextPaint.setTextSize(getResources().getDimension(R.dimen.module_ext_arcView_center_text_size));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 为绘制弧度及数据设置动画
|
||||
*
|
||||
* @param startAngle 开始的弧度
|
||||
* @param currentAngle 需要绘制的弧度
|
||||
* @param time 动画执行的时长
|
||||
*/
|
||||
private void setAnimation(float startAngle, float currentAngle, int time) {
|
||||
//绘制当前数据对应的圆弧的动画效果
|
||||
ValueAnimator progressAnimator = ValueAnimator.ofFloat(startAngle, currentAngle);
|
||||
progressAnimator.setDuration(time);
|
||||
progressAnimator.setTarget(mIncludedAngle);
|
||||
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mIncludedAngle = (float) animation.getAnimatedValue();
|
||||
//重新绘制,不然不会出现效果
|
||||
postInvalidate();
|
||||
}
|
||||
});
|
||||
//开始执行动画
|
||||
progressAnimator.start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置弧形颜色
|
||||
*
|
||||
* @param value 颜色值
|
||||
*/
|
||||
public void setArcColor(int value) {
|
||||
mArcColor = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
*
|
||||
* @param value 当前绘制的值
|
||||
*/
|
||||
public void setValues(int value) {
|
||||
//完全覆盖
|
||||
if (value > maxValue) {
|
||||
value = maxValue;
|
||||
}
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
currentValue = value;
|
||||
//计算弧度比重
|
||||
float scale = (float) currentValue / maxValue;
|
||||
//计算弧度
|
||||
float currentAngle = scale * mAngle;
|
||||
//开始执行动画
|
||||
setAnimation(lastAngle, currentAngle, 1000);
|
||||
lastAngle = currentAngle;
|
||||
//重新绘制
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
|
||||
private float dp2px(float dp) {
|
||||
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
||||
return dp * metrics.density;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user