[taxi]
[bugfix]
This commit is contained in:
yangyakun
2023-11-22 19:37:40 +08:00
parent d4257bd01c
commit a6d624e381
9 changed files with 154 additions and 76 deletions

View File

@@ -8,10 +8,6 @@ import com.mogo.eagle.core.data.map.MogoLocation;
* Model->Presenter回调状态控制器监听accOn、adas ui show、voice ui show、push ui show、v2x ui show等等
*/
public interface ITaxiControllerStatusCallback {
// 是否vr map模式
void onVRModeChanged(boolean isVRMode);
// 自车定位
void onCarLocationChanged(MogoLocation location);
//开始开启自动驾驶
void startOpenAutopilot();
}

View File

@@ -224,7 +224,6 @@ public class TaxiModel {
// 2021.11.1重构自动驾驶 实现接口 IMoGoAutopilotStatusListener 注册监听 替换IMogoAdasOCHCallback接口
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener);
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener);
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
//定位监听, 传false是高德坐标系
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,10, mMapLocationListener);
@@ -266,7 +265,6 @@ public class TaxiModel {
};
private void releaseListeners() {
MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
// 注销地图监听
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
@@ -1078,18 +1076,6 @@ public class TaxiModel {
}
};
private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() {
// VR mode变更回调
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
if (StatusDescriptor.VR_MODE == descriptor) {
if (mControllerStatusCallback != null) {
mControllerStatusCallback.onVRModeChanged(isTrue);
}
}
}
};
// 自车定位
private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() {
@Override
@@ -1108,9 +1094,6 @@ public class TaxiModel {
mLongitude = gnssInfo.getLongitude();
mLatitude = gnssInfo.getLatitude();
mLocation = gnssInfo;
if (mControllerStatusCallback != null) {
mControllerStatusCallback.onCarLocationChanged(gnssInfo);
}
}
};

View File

@@ -323,20 +323,6 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
runOnUIThread( () -> mView.onNaviToEnd(isAmap,isShow));
}
@Override
public void onVRModeChanged(boolean isVRMode) {
runOnUIThread(() -> mView.switchVRFlatMode(isVRMode));
}
@Override
public void onCarLocationChanged(MogoLocation location) {
if (null != location){
runOnUIThread(() -> {
mView.updateSpeedView((float) location.getGnssSpeed());
});
}
}
@Override
public void startOpenAutopilot() {
runOnUIThread(() -> {

View File

@@ -48,6 +48,7 @@ import com.mogo.map.uicontroller.VisualAngleMode;
import com.mogo.och.common.module.utils.AnimatorDrawableUtil;
import com.mogo.och.common.module.utils.FrameAnimatorContainer;
import com.mogo.och.taxi.R;
import com.mogo.och.taxi.ui.speed.SpeedView;
import java.util.Arrays;
import java.util.Objects;
@@ -76,7 +77,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
private FrameLayout flNaviPanelContainer;
private MapBizView mapBizView;
private Group groupTestPanel;
private TextView mSpeedView;
private SpeedView mSpeedView;
private ImageView mAutopilotImage;
private TextView mAutopilotTv;
private LinearLayout mMapswitchBtn;
@@ -124,7 +125,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
// mTrafficLightView = findViewById(R.id.taxi_traffic_light_view);
// CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
mSpeedView = findViewById(R.id.module_mogo_och_speed_tv);
mSpeedView = findViewById(R.id.taxi_speed_contain);
mCloseNaviIcon = findViewById(R.id.taxi_close_navi_icon);
flNaviPanelContainer = findViewById(R.id.module_mogo_och_navi_panel_container);
mSpeedView.setLongClickable(true); //调试按钮任意模式下都开
@@ -253,9 +254,9 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
int width = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), 420f);
int height = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), 220f);
startAutopilotAnimator = new FrameAnimatorContainer(R.array.anim_flow, 20,mAnimFlowIv,false,false,true,width,height);
startAutopilotAnimator = new FrameAnimatorContainer(R.array.anim_flow, 20,mAnimFlowIv,false,false,false,width,height);
startAutopilotAnimator.setOnAnimStopListener(() -> CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "自动驾驶动画暂停"));
startManCOAnimator = new FrameAnimatorContainer(R.array.nim_flow_man_co, 20,mAnimFlowIv,false,false,true,width,height);
startManCOAnimator = new FrameAnimatorContainer(R.array.nim_flow_man_co, 20,mAnimFlowIv,false,false,false,width,height);
startManCOAnimator.setOnAnimStopListener(() -> CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "平行驾驶动画暂停"));
}
@@ -537,11 +538,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
});
}
public void updateSpeedView(float newSpeed) {
int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值
mSpeedView.setText(String.valueOf(speed));
}
protected void showAmapNaviToStationFragment(boolean isShow) {
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();

View File

@@ -110,7 +110,6 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
super.initViews();
initFragment();
hidPanel();
switchVRFlatMode(MogoStatusManager.getInstance().isVrMode());
tvOperationStatus.setVisibility(View.VISIBLE);
initOrderTestBar();
@@ -160,12 +159,6 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
mPresenter.updateCarStatus();
}
public void switchVRFlatMode(boolean isVRMode) {
if (mRootView != null) {
mRootView.setVisibility(isVRMode ? View.VISIBLE : View.GONE);
}
}
@Override
public void onDestroyView() {
super.onDestroyView();

View File

@@ -0,0 +1,62 @@
package com.mogo.och.taxi.ui.speed
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.mogo.och.taxi.R
import kotlinx.android.synthetic.main.taxi_speed.view.taxi_speed_value
/**
* 剩余时间和结束订单入口
*/
class SpeedView : LinearLayout,SpeedViewModel.ISpeedCallback {
private val TAG = "SpeedView"
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
context,
attributeSet,
defStyleAttr
)
private fun initView() {
LayoutInflater.from(context).inflate(R.layout.taxi_speed, this, true)
gravity = Gravity.CENTER_HORIZONTAL
orientation = VERTICAL
}
override fun updateSpeedView(newSpeed: Float) {
val speed = (Math.abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
taxi_speed_value.text = speed.toString()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
val viewModel = findViewTreeViewModelStoreOwner()?.let {
ViewModelProvider(it).get(SpeedViewModel::class.java)
}
viewModel?.setAutopilotStatusCallback(this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
}
init {
try {
initView()
} catch (e: Exception) {
e.printStackTrace()
}
}
}

View File

@@ -0,0 +1,51 @@
package com.mogo.och.taxi.ui.speed
import androidx.lifecycle.ViewModel
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import java.util.concurrent.atomic.AtomicBoolean
class SpeedViewModel: ViewModel(), IMoGoChassisLocationGCJ02Listener {
private val TAG = SpeedViewModel::class.java.simpleName
private var viewCallback: ISpeedCallback?=null
private var isAnimateRunning = AtomicBoolean(false)
init {
}
fun setAutopilotStatusCallback(viewCallback: ISpeedCallback){
this.viewCallback = viewCallback
//定位监听, 传false是高德坐标系
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
}
override fun onCleared() {
super.onCleared()
this.viewCallback = null
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
}
interface ISpeedCallback{
/**
* 开始动画
*/
fun updateSpeedView(newSpeed: Float)
}
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
UiThreadHandler.post({
mogoLocation?.let {
viewCallback?.updateSpeedView(it.gnssSpeed)
}
},UiThreadHandler.MODE.QUEUE)
}
}

View File

@@ -21,38 +21,19 @@
app:layout_constraintStart_toStartOf="parent"
app:locationIcon3DRes="@raw/chuzuche" />
<LinearLayout
android:id="@+id/module_mogo_och_speed_layout"
<com.mogo.och.taxi.ui.speed.SpeedView
android:id="@+id/taxi_speed_contain"
android:layout_width="@dimen/taxi_tab_speed_width_height"
android:layout_height="@dimen/taxi_tab_speed_width_height"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/taxi_speed_bg"
android:elevation="@dimen/dp_10"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@drawable/taxi_speed_bg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/module_mogo_och_speed_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:paddingTop="6dp"
android:text="0"
android:textColor="#FFFFFF"
android:textSize="74dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:text="KM/H"
android:textColor="#FFFFFF"
android:textSize="32dp" />
</LinearLayout>
app:layout_constraintTop_toTopOf="parent"
/>
<RelativeLayout
android:id="@+id/module_mogo_och_autopilot_status"
@@ -214,7 +195,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="244dp"
android:background="@android:color/transparent"
app:layout_constraintLeft_toLeftOf="@+id/module_mogo_och_speed_layout"
app:layout_constraintLeft_toLeftOf="@+id/taxi_speed_contain"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call"
tools:visibility="visible" />

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/taxi_tab_speed_width_height"
android:layout_height="@dimen/taxi_tab_speed_width_height"
android:background="@drawable/taxi_speed_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:parentTag="LinearLayout">
<TextView
android:id="@+id/taxi_speed_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:paddingTop="6dp"
android:text="0"
android:textColor="#FFFFFF"
android:textSize="74dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:text="KM/H"
android:textColor="#FFFFFF"
android:textSize="32dp" />
</merge>