抽离优化速度卡片
This commit is contained in:
@@ -67,7 +67,6 @@ 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.SpeedChartView;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.share.manager.ServiceApisManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
@@ -126,7 +125,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
IMogoAimlessModeListener,
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener,
|
||||
// IMogoLocationListener,
|
||||
IMogoCarLocationChangedListener2 {
|
||||
|
||||
private static final String TAG = "EntranceFragment";
|
||||
@@ -205,8 +203,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private TextView tvExitVrMode;
|
||||
|
||||
|
||||
private FrameLayout flSpeed;
|
||||
private SpeedChartView mouduleArc;
|
||||
private ConstraintLayout clTrafficLight;
|
||||
private TextView tvYellow;
|
||||
private TextView tvRed;
|
||||
@@ -366,18 +362,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
// 根据本地配置设置自车图标
|
||||
MyLocationUtil.setMyLocationIconUrl(getContext());
|
||||
|
||||
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
|
||||
mouduleArc = (SpeedChartView) findViewById(R.id.moudule_arc);
|
||||
if (DebugConfig.isDebug()) {
|
||||
mouduleArc.setLongClickable(true);
|
||||
mouduleArc.setOnLongClickListener(v -> {
|
||||
Log.d(TAG,"长按显示状态工具栏");
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("oper", 52);
|
||||
MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke(MogoReceiver.ACTION_MOCK, intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
clTrafficLight = (ConstraintLayout) findViewById(R.id.cl_traffic_light);
|
||||
tvYellow = (TextView) findViewById(R.id.tv_yellow);
|
||||
tvRed = (TextView) findViewById(R.id.tv_red);
|
||||
@@ -420,7 +404,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);
|
||||
}
|
||||
@@ -434,10 +417,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;
|
||||
@@ -446,7 +425,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);
|
||||
}
|
||||
@@ -1387,10 +1365,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
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.mogo.module.extensions.view.SpeedChartView
|
||||
<com.mogo.module.hmi.ui.widget.SpeedChartView
|
||||
android:id="@+id/moudule_arc"
|
||||
android:layout_width="@dimen/module_ext_arcView_width"
|
||||
android:layout_height="@dimen/module_ext_arcView_height"
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_ext_top_view_width_in_vr_mode">1100px</dimen>
|
||||
<dimen name="module_ext_speed_width">460px</dimen>
|
||||
<dimen name="module_ext_speed_height">460px</dimen>
|
||||
<dimen name="module_ext_arcView_width">320px</dimen>
|
||||
<dimen name="module_ext_arcView_height">320px</dimen>
|
||||
<dimen name="module_ext_arcView_stroke_with">20px</dimen>
|
||||
<dimen name="module_ext_arcView_center_text_size">110px</dimen>
|
||||
<dimen name="module_ext_arcView_des_text_size">40px</dimen>
|
||||
|
||||
<dimen name="module_switch_map">279px</dimen>
|
||||
<dimen name="module_switch_map_height">119px</dimen>
|
||||
<dimen name="module_switch_margin_left">22px</dimen>
|
||||
|
||||
@@ -182,14 +182,7 @@
|
||||
<dimen name="module_video_window_height_content">393px</dimen>
|
||||
<dimen name="module_video_window_width_content">700px</dimen>
|
||||
|
||||
<dimen name="module_ext_speed_width">300px</dimen>
|
||||
<dimen name="module_ext_speed_height">300px</dimen>
|
||||
|
||||
<dimen name="module_ext_arcView_width">200px</dimen>
|
||||
<dimen name="module_ext_arcView_height">200px</dimen>
|
||||
<dimen name="module_ext_arcView_stroke_with">10px</dimen>
|
||||
<dimen name="module_ext_arcView_center_text_size">80px</dimen>
|
||||
<dimen name="module_ext_arcView_des_text_size">28px</dimen>
|
||||
|
||||
<dimen name="module_switch_map">190px</dimen>
|
||||
<dimen name="module_switch_map_height">76px</dimen>
|
||||
|
||||
@@ -58,6 +58,7 @@ dependencies {
|
||||
api rootProject.ext.dependencies.mogocommons
|
||||
api rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.moduleservice
|
||||
} else {
|
||||
api project(":libraries:mogo-map")
|
||||
api project(":libraries:mogo-map-api")
|
||||
@@ -65,6 +66,7 @@ dependencies {
|
||||
api project(":foudations:mogo-commons")
|
||||
api project(':services:mogo-service-api')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-service')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.mogo.module.extensions.view;
|
||||
package com.mogo.module.hmi.ui.widget;
|
||||
|
||||
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;
|
||||
@@ -10,12 +9,12 @@ 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;
|
||||
import com.mogo.module.hmi.R;
|
||||
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/3/24 16:20
|
||||
@@ -182,9 +181,4 @@ public class SpeedChartView extends View {
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
|
||||
private float dp2px(float dp) {
|
||||
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
||||
return dp * metrics.density;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.mogo.module.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.location.Location
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.module.hmi.R
|
||||
import com.mogo.module.service.receiver.MogoReceiver
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener
|
||||
import com.mogo.service.statusmanager.StatusDescriptor
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/25 8:25 下午
|
||||
*/
|
||||
class SpeedPanelView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr),
|
||||
IMogoCarLocationChangedListener2,
|
||||
IMogoStatusChangedListener {
|
||||
val TAG = "SpeedPanelView"
|
||||
private var mMogoServiceApis: IMogoServiceApis =
|
||||
ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
|
||||
var mContext: Context
|
||||
var mSpeedChartView: SpeedChartView
|
||||
|
||||
init {
|
||||
setBackgroundResource(R.drawable.yi_biao_pan_bg_nor)
|
||||
mContext = context
|
||||
mSpeedChartView = SpeedChartView(context)
|
||||
|
||||
val layoutParams = LayoutParams(
|
||||
resources.getDimension(R.dimen.module_ext_arcView_width).toInt(),
|
||||
resources.getDimension(R.dimen.module_ext_arcView_height).toInt()
|
||||
)
|
||||
layoutParams.gravity = Gravity.CENTER
|
||||
mSpeedChartView.layoutParams = layoutParams
|
||||
addView(mSpeedChartView)
|
||||
|
||||
if (DebugConfig.isDebug()) {
|
||||
mSpeedChartView.isLongClickable = true
|
||||
mSpeedChartView.setOnLongClickListener { v ->
|
||||
Log.d(TAG, "长按显示状态工具栏")
|
||||
val intent = Intent()
|
||||
intent.putExtra("oper", 52)
|
||||
MogoApisHandler.getInstance().apis.intentManagerApi
|
||||
.invoke(MogoReceiver.ACTION_MOCK, intent)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
// 注册位置回调
|
||||
mMogoServiceApis.registerCenterApi
|
||||
.registerCarLocationChangedListener(TAG, this)
|
||||
// 注册VR模式回调
|
||||
mMogoServiceApis.statusManagerApi
|
||||
.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this)
|
||||
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 解除注册
|
||||
mMogoServiceApis.registerCenterApi
|
||||
.unregisterMogoLocationListener(TAG)
|
||||
mMogoServiceApis.statusManagerApi
|
||||
.unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this)
|
||||
}
|
||||
|
||||
|
||||
override fun onCarLocationChanged(latLng: MogoLatLng?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onCarLocationChanged2(latLng: Location) {
|
||||
val speed = (latLng.speed * 3.6f).toInt()
|
||||
mSpeedChartView.setArcColor(Color.parseColor(if (speed > 60) "#DB3137" else "#3E77F6"))
|
||||
mSpeedChartView.setValues(speed)
|
||||
setBackgroundResource(if (speed > 60) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
|
||||
}
|
||||
|
||||
override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) {
|
||||
if (descriptor == StatusDescriptor.VR_MODE) {
|
||||
try {
|
||||
visibility = if (isTrue) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,6 @@
|
||||
<gradient
|
||||
android:endColor="#3B4577"
|
||||
android:startColor="#3B4577" />
|
||||
<!-- <stroke-->
|
||||
<!-- android:width="1dp"-->
|
||||
<!-- android:color="#182155" />-->
|
||||
<!-- <corners-->
|
||||
<!-- android:bottomLeftRadius="@dimen/dp_100"-->
|
||||
<!-- android:bottomRightRadius="@dimen/dp_20"-->
|
||||
<!-- android:topLeftRadius="@dimen/dp_20"-->
|
||||
<!-- android:topRightRadius="@dimen/dp_100" />-->
|
||||
<corners
|
||||
android:bottomLeftRadius="130px"
|
||||
android:bottomRightRadius="30px"
|
||||
@@ -6,9 +6,6 @@
|
||||
android:gradientRadius="50%p"
|
||||
android:startColor="#93354E"
|
||||
android:type="radial" />
|
||||
<!-- <stroke-->
|
||||
<!-- android:width="1dp"-->
|
||||
<!-- android:color="#182155" />-->
|
||||
<corners
|
||||
android:bottomLeftRadius="@dimen/dp_100"
|
||||
android:bottomRightRadius="@dimen/dp_20"
|
||||
@@ -5,6 +5,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mogo.module.hmi.ui.widget.SpeedPanelView
|
||||
android:id="@+id/flSpeedChartView"
|
||||
android:layout_width="@dimen/module_ext_speed_width"
|
||||
android:layout_height="@dimen/module_ext_speed_height"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:elevation="@dimen/dp_10"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.module.hmi.ui.widget.TrafficLightView
|
||||
android:id="@+id/viewTrafficLightVr"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_ext_speed_width">460px</dimen>
|
||||
<dimen name="module_ext_speed_height">460px</dimen>
|
||||
|
||||
<dimen name="module_ext_arcView_width">320px</dimen>
|
||||
<dimen name="module_ext_arcView_height">320px</dimen>
|
||||
<dimen name="module_ext_arcView_stroke_with">20px</dimen>
|
||||
<dimen name="module_ext_arcView_center_text_size">110px</dimen>
|
||||
<dimen name="module_ext_arcView_des_text_size">40px</dimen>
|
||||
</resources>
|
||||
11
modules/mogo-module-hmi/src/main/res/values-xhdpi/dimens.xml
Normal file
11
modules/mogo-module-hmi/src/main/res/values-xhdpi/dimens.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_ext_speed_width">300px</dimen>
|
||||
<dimen name="module_ext_speed_height">300px</dimen>
|
||||
|
||||
<dimen name="module_ext_arcView_width">200px</dimen>
|
||||
<dimen name="module_ext_arcView_height">200px</dimen>
|
||||
<dimen name="module_ext_arcView_stroke_with">10px</dimen>
|
||||
<dimen name="module_ext_arcView_center_text_size">80px</dimen>
|
||||
<dimen name="module_ext_arcView_des_text_size">28px</dimen>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user