[转 kotlin]
This commit is contained in:
yangyakun
2024-08-09 18:16:20 +08:00
parent 303fc76723
commit 5eb33f5037
16 changed files with 1962 additions and 2085 deletions

View File

@@ -17,4 +17,9 @@ object ResourcesUtils {
return AbsMogoApplication.getApp().getString(id)
}
@JvmStatic
fun getString(@StringRes id: Int, vararg formatArgs:String): String {
return AbsMogoApplication.getApp().getString(id,formatArgs)
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.och.weaknet.view;
package com.mogo.och.common.module.wigets;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
@@ -25,8 +25,8 @@ import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.utilcode.util.ConvertUtils;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.common.module.R;
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager;
import com.mogo.och.shuttle.weaknet.R;
import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.utils.AutoSizeUtils;
@@ -139,7 +139,7 @@ public class SlidePanelView extends View {
int size = AutoSizeUtils.dp2px(getContext(), 120);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inDensity = (int) AutoSizeConfig.getInstance().getInitDensity();
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.bus_base_slide_block,opts);
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.common_wiget_slide_block,opts);
bmBlock = Bitmap.createScaledBitmap(bmBlock, size, size, true);
blockWidth = bmBlock.getWidth();
UiThreadHandler.post(this::requestLayout,UiThreadHandler.MODE.QUEUE);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -88,4 +88,15 @@
<attr name="rightPadding" format="integer" />
<attr name="bottomPadding" format="integer" />
</declare-styleable>
<declare-styleable name="SlidePanelView">
<attr name="textSize" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="BLOCK_START_X" format="dimension" />
<attr name="BLOCK_START_Y" format="dimension" />
</declare-styleable>
</resources>

View File

@@ -8,8 +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 IBusControllerStatusCallback {
// 自车定位
void onCarLocationChanged(MogoLocation location);
//开始开启自动驾驶
void startOpenAutopilot();
}

View File

@@ -1,257 +1,248 @@
package com.mogo.och.weaknet.fragment;
package com.mogo.och.weaknet.fragment
import static com.mogo.och.weaknet.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL;
import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.constraintlayout.widget.Group
import androidx.core.content.ContextCompat
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.mvp.IView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.mvp.Presenter
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HdMapBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isCanStartAutopilot
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.attachAutopilotBeforeLaunchView
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxBubbleView
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxListView
import com.mogo.eagle.core.function.smp.view.SmallMapView
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB1
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB2
import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.map.MogoMap
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.utils.ResourcesUtils.getColor
import com.mogo.och.common.module.utils.SoundPoolHelper
import com.mogo.och.common.module.wigets.SlidePanelView
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.constant.BusConst
import com.mogo.och.weaknet.model.OrderModel.busRoutesResult
import com.mogo.och.weaknet.view.BizMapView
import org.greenrobot.eventbus.EventBus
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.mvp.Presenter;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager;
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxBubbleView;
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView;
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxListView;
import com.mogo.eagle.core.function.smp.view.SmallMapView;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.MogoMap;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.och.common.module.utils.ResourcesUtils;
import com.mogo.och.weaknet.model.OrderModel;
import com.mogo.och.weaknet.view.BizMapView;
import com.mogo.och.data.bean.BusRoutesResult;
import com.mogo.och.weaknet.view.SlidePanelView;
import com.mogo.och.common.module.utils.SoundPoolHelper;
import com.mogo.och.shuttle.weaknet.R;
import org.greenrobot.eventbus.EventBus;
/**
* 网约车基础Fragment主要负责布局通用界面处理站点面板和通话面板互斥情况
* <p>
*
*
* 部分业务放在了此处处理
*
* @author tongchenfei
*/
public abstract class BaseShuttleTabFragment<V extends IView, P extends Presenter<V>> extends MvpFragment<V, P> {
abstract class BaseShuttleTabFragment<V : IView?, P : Presenter<V>?> : MvpFragment<V, P>() {
protected var slidePanelView: SlidePanelView? = null
private var ctvAutopilotStatus: RelativeLayout? = null
private var ctvAutopilotStatusIv: ImageView? = null
private var ctvAutopilotStatusTv: TextView? = null
protected var tvArrived: TextView? = null
private var flStationPanelContainer: FrameLayout? = null
private var mapBizView: BizMapView? = null
private var groupTestPanel: Group? = null
private static final String TAG = "BaseBusTabFragment";
protected SlidePanelView slidePanelView;
private RelativeLayout ctvAutopilotStatus;
private ImageView ctvAutopilotStatusIv;
private TextView ctvAutopilotStatusTv;
protected TextView tvArrived;
private FrameLayout flStationPanelContainer;
private BizMapView mapBizView;
private Group groupTestPanel;
protected SmallMapView smallMapView;
protected var smallMapView: SmallMapView? = null
//消息盒子
private DriverMsgBoxButtonView viewDriverMsgBoxButton;
private DriverMsgBoxListView viewDriverMsgBoxList;
private DriverMsgBoxBubbleView viewDriverMsgBoxBubble;
private var viewDriverMsgBoxButton: DriverMsgBoxButtonView? = null
private var viewDriverMsgBoxList: DriverMsgBoxListView? = null
private var viewDriverMsgBoxBubble: DriverMsgBoxBubbleView? = null
private ObjectAnimator autopilotLoadingAnimator;
private var autopilotLoadingAnimator: ObjectAnimator? = null
public boolean isAnimateRunning = false;
var isAnimateRunning: Boolean = false
/**
* 滑动按钮触发的事件
*/
private final SlidePanelView.OnSlidePanelMoveToEndListener onSlideToEndListener = () -> {
private val onSlideToEndListener = SlidePanelView.OnSlidePanelMoveToEndListener {
// 此处做一个代理,处理一下共有情况
if (getSlidePanelOnEndListener() != null) {
getSlidePanelOnEndListener().moveToEnd();
if (slidePanelOnEndListener() != null) {
slidePanelOnEndListener()!!.moveToEnd()
}
};
@Override
protected int getLayoutId() {
return R.layout.shuttle_weak_base_fragment;
}
@Override
protected void initViews() {
mapBizView = findViewById(R.id.mapBizView);
groupTestPanel = findViewById(R.id.groupTestPanel);
slidePanelView = findViewById(R.id.module_mogo_och_slide_panel);
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status);
ctvAutopilotStatusIv = findViewById(R.id.bus_autopilot_btn_iv);
ctvAutopilotStatusTv = findViewById(R.id.bus_autopolot_btn_tv);
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
override fun getLayoutId(): Int {
return R.layout.shuttle_weak_base_fragment
}
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv);
override fun initViews() {
mapBizView = findViewById(R.id.mapBizView)
groupTestPanel = findViewById(R.id.groupTestPanel)
slidePanelView = findViewById(R.id.module_mogo_och_slide_panel)
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status)
ctvAutopilotStatusIv = findViewById(R.id.bus_autopilot_btn_iv)
ctvAutopilotStatusTv = findViewById(R.id.bus_autopolot_btn_tv)
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container)
FrameLayout flSpeed = findViewById(R.id.fl_speed);
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv)
val flSpeed = findViewById<FrameLayout>(R.id.fl_speed)
if (flSpeed != null) {
CallerDevaToolsManager.INSTANCE.attachAutopilotBeforeLaunchView(flSpeed.getContext(), flSpeed);
attachAutopilotBeforeLaunchView(flSpeed.context, flSpeed)
}
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
LayoutInflater.from(context).inflate(stationPanelViewId(), flStationPanelContainer)
slidePanelView!!.setOnSlidePanelMoveToEndListener(onSlideToEndListener)
updateSwitchMapIcon();
updateSwitchMapIcon()
initListener();
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState(),
CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
@Override
public void onClickImpl(View v) {
restartAutopilot();
initListener()
setAutopilotBtnStatus(
getState(),
isCanStartAutopilot(false, 0)
)
ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() {
override fun onClickImpl(v: View) {
restartAutopilot()
}
});
})
// 模拟 不可自动驾驶目前场景是刚开机adas还未和工控机连接
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)
);
findViewById<View>(R.id.btnAutopilotDisable)!!.setOnClickListener { view: View? ->
debugAutoPilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
)
}
// 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态
findViewById(R.id.btnAutopilotEnable).setOnClickListener(view ->
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE)
);
findViewById<View>(R.id.btnAutopilotEnable)!!.setOnClickListener { view: View? ->
debugAutoPilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE
)
}
// 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人
findViewById(R.id.btnAutopilotRunning).setOnClickListener(view ->
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)
);
findViewById<View>(R.id.btnAutopilotRunning)!!.setOnClickListener { view: View? ->
debugAutoPilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
)
}
findViewById(R.id.btnAutopilotPingxing).setOnClickListener(view ->
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING)
);
findViewById<View>(R.id.btnAutopilotPingxing)!!.setOnClickListener { view: View? ->
debugAutoPilotStatus(
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING
)
}
// 模拟 自动驾驶网约车回调数据
findViewById(R.id.btnAutopilotArrive).setOnClickListener(view ->
debugArrivedStation()
);
findViewById<View>(R.id.btnAutopilotArrive)!!.setOnClickListener { view: View? -> debugArrivedStation() }
tvArrived.setOnClickListener(view -> {
ToastUtils.showLong("weak_net");
onArriveStation();
});
tvArrived!!.setOnClickListener { view: View? ->
ToastUtils.showLong("weak_net")
onArriveStation()
}
//消息盒子
viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton);
viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList);
viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble);
viewDriverMsgBoxButton.setClickListener(show -> {
if(show){
viewDriverMsgBoxList.setVisibility(View.VISIBLE);
viewDriverMsgBoxList.notifyData();
viewDriverMsgBoxBubble.setVisibility(View.GONE);
viewDriverMsgBoxBubble.isShowData(false);
}else{
viewDriverMsgBoxList.setVisibility(View.GONE);
viewDriverMsgBoxBubble.setVisibility(View.VISIBLE);
viewDriverMsgBoxBubble.isShowData(true);
viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton)
viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList)
viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble)
viewDriverMsgBoxButton!!.setClickListener(object :DriverMsgBoxButtonView.ClickListener {
override fun showMsgBoxList(show: Boolean) {
if (show) {
viewDriverMsgBoxList!!.visibility = View.VISIBLE
viewDriverMsgBoxList!!.notifyData()
viewDriverMsgBoxBubble!!.visibility = View.GONE
viewDriverMsgBoxBubble!!.isShowData(false)
} else {
viewDriverMsgBoxList!!.visibility = View.GONE
viewDriverMsgBoxBubble!!.visibility = View.VISIBLE
viewDriverMsgBoxBubble!!.isShowData(true)
}
}
});
})
smallMapView = findViewById(R.id.smallMapView);
smallMapView = findViewById(R.id.smallMapView)
}
@Override
protected void initViews(Bundle savedInstanceState) {
super.initViews(savedInstanceState);
mapBizView.onCreate(savedInstanceState);
smallMapView.onCreateView(savedInstanceState);
override fun initViews(savedInstanceState: Bundle?) {
super.initViews(savedInstanceState)
mapBizView!!.onCreate(savedInstanceState)
smallMapView!!.onCreateView(savedInstanceState)
}
@Override
public void onResume() {
super.onResume();
mapBizView.onResume();
smallMapView.onResume();
override fun onResume() {
super.onResume()
mapBizView!!.onResume()
smallMapView!!.onResume()
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container
, @Nullable Bundle savedInstanceState) {
EventBus.getDefault().register(this);
return super.onCreateView(inflater, container, savedInstanceState);
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
EventBus.getDefault().register(this)
return super.onCreateView(inflater, container, savedInstanceState)
}
protected abstract void onArriveStation();
protected abstract fun onArriveStation()
private void updateSwitchMapIcon() {
IMogoMapUIController mapUIController = CallerMapUIServiceManager.INSTANCE.getMapUIController(MogoMap.DEFAULT);
if(mapUIController!=null){
if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) {
mapUIController.changeCurrentIcon(R.raw.m2);
HdMapBuildConfig.currentCarVrIconRes = R.raw.m2;
}else if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) {
mapUIController.changeCurrentIcon(R.raw.xiaoba);
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba;
private fun updateSwitchMapIcon() {
val mapUIController = getMapUIController(MogoMap.DEFAULT)
if (mapUIController != null) {
if (isB2(FunctionBuildConfig.appIdentityMode)) {
mapUIController.changeCurrentIcon(R.raw.m2)
HdMapBuildConfig.currentCarVrIconRes = R.raw.m2
} else if (isB1(FunctionBuildConfig.appIdentityMode)) {
mapUIController.changeCurrentIcon(R.raw.xiaoba)
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba
}
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
mapBizView.onSaveInstanceState(outState);
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapBizView!!.onSaveInstanceState(outState)
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapBizView.onLowMemory();
override fun onLowMemory() {
super.onLowMemory()
mapBizView!!.onLowMemory()
}
@Override
public void onPause() {
super.onPause();
mapBizView.onPause();
smallMapView.onPause();
override fun onPause() {
super.onPause()
mapBizView!!.onPause()
smallMapView!!.onPause()
}
@Override
public void onDestroyView() {
mapBizView.onDestroy();
if(smallMapView != null){
smallMapView.onDestroy();
override fun onDestroyView() {
mapBizView!!.onDestroy()
if (smallMapView != null) {
smallMapView!!.onDestroy()
}
super.onDestroyView();
CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG);
EventBus.getDefault().unregister(this);
super.onDestroyView()
CallerAutopilotRecordListenerManager.removeListener(TAG)
EventBus.getDefault().unregister(this)
}
/**
* 测试到站
*/
protected abstract void debugArrivedStation();
private void initListener() {
protected abstract fun debugArrivedStation()
private fun initListener() {
}
/**
@@ -259,15 +250,12 @@ public abstract class BaseShuttleTabFragment<V extends IView, P extends Presente
*
* @param text 指定的文字
*/
public void showSlidePanel(String text) {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
slidePanelView.setText(text);
slidePanelView.setVisibility(View.VISIBLE);
}
}, UiThreadHandler.MODE.QUEUE);
setArrivedClikable(false);
fun showSlidePanel(text: String?) {
UiThreadHandler.post({
slidePanelView!!.setText(text)
slidePanelView!!.visibility = View.VISIBLE
}, UiThreadHandler.MODE.QUEUE)
setArrivedClikable(false)
}
/**
@@ -275,34 +263,39 @@ public abstract class BaseShuttleTabFragment<V extends IView, P extends Presente
*
* @param isClickable
*/
public void setArrivedClikable(boolean isClickable) {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
tvArrived.setEnabled(isClickable);
if (isClickable) {
tvArrived.setTextColor(ContextCompat.getColor(AbsMogoApplication.getApp(),R.color.bus_white));
} else {
tvArrived.setTextColor(ContextCompat.getColor(AbsMogoApplication.getApp(),R.color.bus_arrived_btn_un_clickable_color));
}
fun setArrivedClikable(isClickable: Boolean) {
UiThreadHandler.post({
tvArrived!!.isEnabled = isClickable
if (isClickable) {
tvArrived!!.setTextColor(
ContextCompat.getColor(
AbsMogoApplication.getApp(),
R.color.bus_white
)
)
} else {
tvArrived!!.setTextColor(
ContextCompat.getColor(
AbsMogoApplication.getApp(),
R.color.bus_arrived_btn_un_clickable_color
)
)
}
}, UiThreadHandler.MODE.QUEUE);
}, UiThreadHandler.MODE.QUEUE)
}
/**
* 隐藏滑动按钮
*/
public void hideSlidePanel() {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
slidePanelView.setVisibility(View.GONE);
}
}, UiThreadHandler.MODE.QUEUE);
fun hideSlidePanel() {
UiThreadHandler.post(
{ slidePanelView!!.visibility = View.GONE },
UiThreadHandler.MODE.QUEUE
)
}
public void playDI() {
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(getContext(), R.raw.bus_di);
fun playDI() {
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
}
/**
@@ -310,251 +303,272 @@ public abstract class BaseShuttleTabFragment<V extends IView, P extends Presente
*
* @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中
*/
public void onAutopilotStatusChanged(int autopilotStatus,boolean canStartAuto) {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
changeAutopilotBtnView(autopilotStatus, isAnimateRunning,canStartAuto);
}
}, UiThreadHandler.MODE.QUEUE);
fun onAutopilotStatusChanged(autopilotStatus: Int, canStartAuto: Boolean) {
UiThreadHandler.post({
changeAutopilotBtnView(
autopilotStatus,
isAnimateRunning,
canStartAuto
)
}, UiThreadHandler.MODE.QUEUE)
}
public void setAutopilotBtnStatus(int autopilotStatus,boolean canStartAuto) {
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) {//0不可用
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_disable));
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv));
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_start_fail);
fun setAutopilotBtnStatus(autopilotStatus: Int, canStartAuto: Boolean) {
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) { //0不可用
ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable))
ctvAutopilotStatusTv!!.text =
ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv)
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon)
ctvAutopilotStatus!!.isClickable = true
ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail)
} else {
ctvAutopilotStatusTv.setTextColor(AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot);
ctvAutopilotStatusTv!!.setTextColor(
AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_normal)
)
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_ic_autopilot)
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv));
if(canStartAuto){
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_press);
}else {
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_disable));
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_start_fail);
ctvAutopilotStatusTv!!.text =
ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv)
if (canStartAuto) {
ctvAutopilotStatus!!.isClickable = true
ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_press)
} else {
ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable))
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon)
ctvAutopilotStatus!!.isClickable = true
ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail)
}
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {
ctvAutopilotStatusTv.setText(R.string.bus_loading_autopilot_runnig_tv);
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_in_autopilot);
ctvAutopilotStatusTv!!.setText(R.string.bus_loading_autopilot_runnig_tv)
ctvAutopilotStatus!!.isClickable = true
ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_in_autopilot)
} else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING
== autopilotStatus){
ctvAutopilotStatusTv.setText(R.string.bus_pingxing_driver);
ctvAutopilotStatus.setClickable(false);
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_pxjs);
== autopilotStatus
) {
ctvAutopilotStatusTv!!.setText(R.string.bus_pingxing_driver)
ctvAutopilotStatus!!.isClickable = false
ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_pxjs)
}
}
}
public void updateAutopilotStatus(int autopilotStatus) {
fun updateAutopilotStatus(autopilotStatus: Int) {
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
== autopilotStatus) {//2 running
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon);
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv));
// ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatus.setClickable(false);
== autopilotStatus
) { //2 running
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_right_autopilot_icon)
ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
ctvAutopilotStatusTv!!.text =
ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv)
// ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatus!!.isClickable = false
} else {
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv));
ctvAutopilotStatus.setClickable(false);
// ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_wrong_autopilot_icon)
ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
ctvAutopilotStatusTv!!.text =
ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv)
ctvAutopilotStatus!!.isClickable = false
// ctvAutopilotStatus.setSelected(false);
}
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() {
setAutopilotBtnStatus(autopilotStatus,CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
}
}, 1000);
UiThreadHandler.postDelayed({
setAutopilotBtnStatus(
autopilotStatus,
isCanStartAutopilot(false, 0)
)
}, 1000)
}
private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning,boolean canStartAuto) {
if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
!= autopilotStatus) {
private fun changeAutopilotBtnView(
autopilotStatus: Int,
isAnimateRunning: Boolean,
canStartAuto: Boolean
) {
if (isAnimateRunning && (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
!= autopilotStatus)
) {
// 主动开启自动驾驶中不为2为0、1则继续loading
return;
return
}
if (isAnimateRunning) {
stopAnimAndUpdateBtnStatus();
stopAnimAndUpdateBtnStatus()
} else {
setAutopilotBtnStatus(autopilotStatus,canStartAuto);
setAutopilotBtnStatus(autopilotStatus, canStartAuto)
}
}
public void stopAnimAndUpdateBtnStatus() {
stopAutopilotAnimation();
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
fun stopAnimAndUpdateBtnStatus() {
stopAutopilotAnimation()
updateAutopilotStatus(getState())
}
/**
* 隐藏【自动驾驶】按钮
*/
public void hideAutopilotBiz() {
fun hideAutopilotBiz() {
}
/**
* 展示【自动驾驶】按钮
*/
public void showAutopilotBiz() {
fun showAutopilotBiz() {
}
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
return null;
}
abstract fun slidePanelOnEndListener(): SlidePanelView.OnSlidePanelMoveToEndListener?
/**
* 获取站点面板view{@link #initViews()}时候添加到container中
* 获取站点面板view[.initViews]时候添加到container中
*
* @return 站点面板view
*/
public abstract int getStationPanelViewId();
abstract fun stationPanelViewId(): Int
/**
* 重新开启自动驾驶
*/
public abstract void restartAutopilot();
abstract fun restartAutopilot()
/**
* 模拟自动驾驶返回状态
*
* @param status
*/
public abstract void debugAutoPilotStatus(int status);
abstract fun debugAutoPilotStatus(status: Int)
/**
* 开启自动驾驶中间动画
*/
public void startAutopilotAnimation() {
isAnimateRunning = true;
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_tv));
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_loading_autopilot_icon);
fun startAutopilotAnimation() {
isAnimateRunning = true
ctvAutopilotStatusTv!!.text =
ResourcesUtils.getString(R.string.bus_loading_autopilot_tv)
ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
ctvAutopilotStatus!!.isClickable = true
ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_loading_autopilot_icon)
if (autopilotLoadingAnimator == null) {
autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f);
autopilotLoadingAnimator.setInterpolator(new LinearInterpolator());
autopilotLoadingAnimator.setRepeatCount(-1);//无限循环
autopilotLoadingAnimator.setDuration(1000);//设置持续时间
autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv!!, "rotation", 0f, 360f)
autopilotLoadingAnimator?.interpolator = LinearInterpolator()
autopilotLoadingAnimator?.repeatCount = -1 //无限循环
autopilotLoadingAnimator?.setDuration(1000) //设置持续时间
}
autopilotLoadingAnimator.start();//动画开始
startingAutoApilotCountDown();
autopilotLoadingAnimator!!.start() //动画开始
startingAutoApilotCountDown()
}
private void startingAutoApilotCountDown() {
private fun startingAutoApilotCountDown() {
//10s 若自动驾驶没有开启,则结束动画
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() { //未启动成功做处理
if (isAnimateRunning) {// 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
stopAutopilotAnimation();
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
}
UiThreadHandler.postDelayed({
//未启动成功做处理
if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
stopAutopilotAnimation()
updateAutopilotStatus(getState())
}
}, TIMER_START_AUTOPILOT_INTERVAL);
}, BusConst.TIMER_START_AUTOPILOT_INTERVAL)
}
/**
* 停止自动驾驶中间动画
*/
protected void stopAutopilotAnimation() {
protected fun stopAutopilotAnimation() {
if (autopilotLoadingAnimator != null) {
autopilotLoadingAnimator.end();
ctvAutopilotStatusIv.clearAnimation();
autopilotLoadingAnimator = null;
isAnimateRunning = false;
autopilotLoadingAnimator!!.end()
ctvAutopilotStatusIv!!.clearAnimation()
autopilotLoadingAnimator = null
isAnimateRunning = false
}
}
// /**
// * 迈速表实时更新
// *
// * @param newSpeed
// */
// public void updateSpeedView(float newSpeed) {
// int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值
// if (mTrafficDataView != null) {
// mTrafficDataView.updateSpeedWithValue(speed);
// }
// }
@Override
public void onDestroy() {
super.onDestroy();
// /**
// * 迈速表实时更新
// *
// * @param newSpeed
// */
// public void updateSpeedView(float newSpeed) {
// int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值
// if (mTrafficDataView != null) {
// mTrafficDataView.updateSpeedWithValue(speed);
// }
// }
override fun onDestroy() {
super.onDestroy()
}
/**
* bus调试面板打开关闭
*/
public void debugTestBar() {
if (groupTestPanel.getVisibility() == View.VISIBLE) {
groupTestPanel.setVisibility(View.GONE);
fun debugTestBar() {
if (groupTestPanel!!.visibility == View.VISIBLE) {
groupTestPanel!!.visibility = View.GONE
} else {
groupTestPanel.setVisibility(View.VISIBLE);
groupTestPanel!!.visibility = View.VISIBLE
}
}
/**
* Bus调试信息线路、轨迹等信息
* <p>
*
*
* START
*/
private View busTestBar;
private TextView lineIdTV;
private TextView lineNameTV;
private TextView trajMd5TV;
private TextView stopMd5TV;
private TextView trajMd5DPQPTV;
private TextView stopMd5DPQPTV;
private var busTestBar: View? = null
private var lineIdTV: TextView? = null
private var lineNameTV: TextView? = null
private var trajMd5TV: TextView? = null
private var stopMd5TV: TextView? = null
private var trajMd5DPQPTV: TextView? = null
private var stopMd5DPQPTV: TextView? = null
public void showHideTestBar() {
fun showHideTestBar() {
if (busTestBar == null) {
busTestBar = findViewById(R.id.module_mogo_och_bus_test_bar);
lineIdTV = findViewById(R.id.bus_test_bar_current_line_id);
lineNameTV = findViewById(R.id.bus_test_bar_current_line_name);
trajMd5TV = findViewById(R.id.bus_test_bar_current_traj_md5);
stopMd5TV = findViewById(R.id.bus_test_bar_current_stop_md5);
trajMd5DPQPTV = findViewById(R.id.bus_test_bar_current_traj_md5_dpqp);
stopMd5DPQPTV = findViewById(R.id.bus_test_bar_current_stop_md5_dpqp);
busTestBar = findViewById(R.id.module_mogo_och_bus_test_bar)
lineIdTV = findViewById(R.id.bus_test_bar_current_line_id)
lineNameTV = findViewById(R.id.bus_test_bar_current_line_name)
trajMd5TV = findViewById(R.id.bus_test_bar_current_traj_md5)
stopMd5TV = findViewById(R.id.bus_test_bar_current_stop_md5)
trajMd5DPQPTV = findViewById(R.id.bus_test_bar_current_traj_md5_dpqp)
stopMd5DPQPTV = findViewById(R.id.bus_test_bar_current_stop_md5_dpqp)
}
if (busTestBar.getVisibility() == View.VISIBLE) {
busTestBar.setVisibility(View.GONE);
if (busTestBar!!.visibility == View.VISIBLE) {
busTestBar!!.visibility = View.GONE
} else {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId())));
lineNameTV.setText("lineName:" + (routesResult == null ? "" : routesResult.getName()));
trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5));
stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5));
trajMd5DPQPTV.setText("TMd5DPQP:" + (routesResult == null ? "" : routesResult.csvFileMd5DPQP));
stopMd5DPQPTV.setText("SMd5DPQP:" + (routesResult == null ? "" : routesResult.txtFileMd5DPQP));
busTestBar.setVisibility(View.VISIBLE);
val routesResult = busRoutesResult
lineIdTV!!.text =
"lineId:" + (routesResult?.lineId?.toString() ?: "")
lineNameTV!!.text =
"lineName:" + (if (routesResult == null) "" else routesResult.name)
trajMd5TV!!.text = "TMd5:" + (if (routesResult == null) "" else routesResult.csvFileMd5)
stopMd5TV!!.text =
"SMd5:" + (if (routesResult == null) "" else routesResult.txtFileMd5)
trajMd5DPQPTV!!.text =
"TMd5DPQP:" + (if (routesResult == null) "" else routesResult.csvFileMd5DPQP)
stopMd5DPQPTV!!.text =
"SMd5DPQP:" + (if (routesResult == null) "" else routesResult.txtFileMd5DPQP)
busTestBar!!.visibility = View.VISIBLE
}
}
public void updateBusTestBarInfo() {
if (busTestBar != null && busTestBar.getVisibility() == View.VISIBLE) {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId())));
lineNameTV.setText("lineName:" + (routesResult == null ? "" : routesResult.getName()));
trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5));
stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5));
trajMd5DPQPTV.setText("TMd5DPQP:" + (routesResult == null ? "" : routesResult.csvFileMd5DPQP));
stopMd5DPQPTV.setText("SMd5DPQP:" + (routesResult == null ? "" : routesResult.txtFileMd5DPQP));
fun updateBusTestBarInfo() {
if (busTestBar != null && busTestBar!!.visibility == View.VISIBLE) {
val routesResult = busRoutesResult
lineIdTV!!.text =
"lineId:" + (routesResult?.lineId?.toString() ?: "")
lineNameTV!!.text = "lineName:" + (if (routesResult == null) "" else routesResult.name)
trajMd5TV!!.text =
"TMd5:" + (if (routesResult == null) "" else routesResult.csvFileMd5)
stopMd5TV!!.text =
"SMd5:" + (if (routesResult == null) "" else routesResult.txtFileMd5)
trajMd5DPQPTV!!.text =
"TMd5DPQP:" + (if (routesResult == null) "" else routesResult.csvFileMd5DPQP)
stopMd5DPQPTV!!.text =
"SMd5DPQP:" + (if (routesResult == null) "" else routesResult.txtFileMd5DPQP)
}
}
/**
* END
*/
companion object {
private const val TAG = "BaseBusTabFragment"
}
}

View File

@@ -1,272 +1,260 @@
package com.mogo.och.weaknet.fragment;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
import static com.mogo.map.MogoMap.DEFAULT;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.annotation.Nullable;
import com.mogo.commons.storage.SharedPrefsMgr;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.temp.EventLogout;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.overlay.IMoGoOverlayManager;
import com.mogo.map.overlay.core.Level;
import com.mogo.map.overlay.point.Point;
import com.mogo.och.common.module.utils.ResourcesUtils;
import com.mogo.och.data.bean.BusStationBean;
import com.mogo.och.weaknet.constant.BusConst;
import com.mogo.och.weaknet.presenter.BusPresenter;
import com.mogo.och.weaknet.ui.BusStationCommonItem;
import com.mogo.och.weaknet.ui.BusSwitchLineActivity;
import com.mogo.och.weaknet.view.SlidePanelView;
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
import com.mogo.och.common.module.utils.QRUtilsKt;
import com.mogo.och.common.module.wigets.BindQRCodeDialog;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import com.mogo.och.common.module.wigets.OCHCommitDialog;
import com.mogo.och.shuttle.weaknet.R;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
import java.util.Objects;
import me.jessyan.autosize.utils.AutoSizeUtils;
package com.mogo.och.weaknet.fragment
import android.content.Intent
import android.graphics.BitmapFactory
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.Group
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.temp.EventLogout
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getOverlayManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.map.MogoMap
import com.mogo.map.overlay.core.Level
import com.mogo.map.overlay.point.Point
import com.mogo.och.common.module.utils.BlinkAnimationUtil
import com.mogo.och.common.module.utils.OCHThreadPoolManager
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.utils.ResourcesUtils.getColor
import com.mogo.och.common.module.utils.createQRCodeWithPicture
import com.mogo.och.common.module.wigets.BindQRCodeDialog
import com.mogo.och.common.module.wigets.MarqueeTextView
import com.mogo.och.common.module.wigets.OCHCommitDialog
import com.mogo.och.common.module.wigets.SlidePanelView
import com.mogo.och.data.bean.BusStationBean
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.constant.BusConst
import com.mogo.och.weaknet.presenter.BusPresenter
import com.mogo.och.weaknet.ui.BusStationCommonItem
import com.mogo.och.weaknet.ui.BusSwitchLineActivity
import me.jessyan.autosize.utils.AutoSizeUtils
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.util.Objects
/**
* 网约车小巴界面
*
* @author tongchenfei
*/
public class ShuttleFragment extends BaseShuttleTabFragment<ShuttleFragment, BusPresenter>
implements SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener {
public static final String TAG = "BusFragment";
class ShuttleFragment : BaseShuttleTabFragment<ShuttleFragment?, BusPresenter?>(),
SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener {
private var mSwitchLine: TextView? = null //切换路线
private var mLineName: MarqueeTextView? = null
private var mTaskTime: TextView? = null
private var groupStationsPanel: Group? = null
private var noDataView: ConstraintLayout? = null
private TextView mSwitchLine; //切换路线
private MarqueeTextView mLineName;
private TextView mTaskTime;
private Group groupStationsPanel;
private ConstraintLayout noDataView;
private BusStationBean startStation = null;
private BusStationBean endStation = null;
private BusStationCommonItem firstStationItem;
private BusStationCommonItem secondStationItem;
private BusStationCommonItem thirdStationItem;
private var startStation: BusStationBean? = null
private var endStation: BusStationBean? = null
private var firstStationItem: BusStationCommonItem? = null
private var secondStationItem: BusStationCommonItem? = null
private var thirdStationItem: BusStationCommonItem? = null
@Override
public String getTagName() {
return "BusFragment";
override fun getTagName(): String {
return "BusFragment"
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
}
@Override
public void onDestroyView() {
override fun onDestroyView() {
if (mPresenter != null) {
mPresenter.onDestroy(this);
mPresenter!!.onDestroy(this)
}
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
if(overlayManager!=null) {
overlayManager.removeAllLines();
overlayManager.removeAllPoints();
val overlayManager = getOverlayManager()
if (overlayManager != null) {
overlayManager.removeAllLines()
overlayManager.removeAllPoints()
}
super.onDestroyView();
super.onDestroyView()
}
@Override
protected void initViews() {
super.initViews();
override fun initViews() {
super.initViews()
mSwitchLine = findViewById(R.id.switch_line_btn);
mSwitchLine.setTag(0);
mLineName = findViewById(R.id.module_och_bus_line_name);
mSwitchLine = findViewById(R.id.switch_line_btn)
mSwitchLine!!.tag = 0
mLineName = findViewById(R.id.module_och_bus_line_name)
firstStationItem = findViewById(R.id.bus_panel_first_station);
secondStationItem = findViewById(R.id.bus_panel_second_station);
thirdStationItem = findViewById(R.id.bus_panel_third_station);
mTaskTime = findViewById(R.id.bus_task_time_tv);
groupStationsPanel = findViewById(R.id.group_stations_panel);
noDataView = findViewById(R.id.no_line_data_view);
firstStationItem = findViewById(R.id.bus_panel_first_station)
secondStationItem = findViewById(R.id.bus_panel_second_station)
thirdStationItem = findViewById(R.id.bus_panel_third_station)
mTaskTime = findViewById(R.id.bus_task_time_tv)
groupStationsPanel = findViewById(R.id.group_stations_panel)
noDataView = findViewById(R.id.no_line_data_view)
CallerLogger.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getState());
d(SceneConstant.M_BUS + TAG, "initView: " + getState())
// 初始化的时候设置 UI 按钮状态
showAutopilotBiz();
showAutopilotBiz()
mSwitchLine.setOnClickListener(this);
mSwitchLine!!.setOnClickListener(this)
mLineName.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
showHideTestBar();
return false;
}
});
mLineName!!.setOnLongClickListener {
showHideTestBar()
false
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void changeOverview(EventLogout eventLogout){
if (eventLogout.getMessgae() == EventLogout.LOGOUT_TYPE){
CallerLogger.d(M_BUS + TAG,"changeOverview Event消息去登出");
mPresenter.logout();
}else if (eventLogout.getMessgae() == EventLogout.SHOW_QR_TYPE){ //显示二维码
CallerLogger.d(M_BUS + TAG,"changeOverview Event qrcodesn = "
+ SharedPrefsMgr.getInstance().getSn());
String qrUrl = String.format(FunctionBuildConfig.urlJson.getBindDriverQRUrl(),
SharedPrefsMgr.getInstance().getSn());
Bitmap bmQr = QRUtilsKt.createQRCodeWithPicture(
BitmapFactory.decodeResource(getResources(), R.drawable.icon_qr_center_logo)
,qrUrl, AutoSizeUtils.dp2px(getContext(),340f),
AutoSizeUtils.dp2px(getContext(),340f),true);
if (bmQr != null){
BindQRCodeDialog.Builder builder = new BindQRCodeDialog.Builder();
fun changeOverview(eventLogout: EventLogout) {
if (eventLogout.messgae == EventLogout.LOGOUT_TYPE) {
d(SceneConstant.M_BUS + TAG, "changeOverview Event消息去登出")
mPresenter!!.logout()
} else if (eventLogout.messgae == EventLogout.SHOW_QR_TYPE) { //显示二维码
d(
SceneConstant.M_BUS + TAG, "changeOverview Event qrcodesn = "
+ SharedPrefsMgr.getInstance().sn
)
val qrUrl = String.format(
FunctionBuildConfig.urlJson.bindDriverQRUrl,
SharedPrefsMgr.getInstance().sn
)
val bmQr = createQRCodeWithPicture(
BitmapFactory.decodeResource(resources, R.drawable.icon_qr_center_logo),
qrUrl, AutoSizeUtils.dp2px(context, 340f),
AutoSizeUtils.dp2px(context, 340f), true
)
if (bmQr != null) {
val builder = BindQRCodeDialog.Builder()
builder.title(getString(R.string.bind_driver_qr_title))
.cancelStr(getString(R.string.qr_cancel))
.qrBm(bmQr).build(getContext()).show();
}else {
CallerLogger.d(M_BUS + TAG,"bmQr = null ");
.cancelStr(getString(R.string.qr_cancel))
.qrBm(bmQr).build(AbsMogoApplication.getApp())!!.show()
} else {
d(SceneConstant.M_BUS + TAG, "bmQr = null ")
}
}
}
@Override
protected void onArriveStation() {
mPresenter.onAutopilotArriveAtStation(null);
mPresenter.arriveStation(null,"点击进站触发进站操作");
override fun onArriveStation() {
mPresenter!!.onAutopilotArriveAtStation(null)
mPresenter!!.arriveStation(null, "点击进站触发进站操作")
}
@Override
protected void debugArrivedStation() {
mPresenter.onAutopilotArriveAtStation(null);
mPresenter.arriveStation(null,"点击debug进站按钮触发进站操作");
override fun debugArrivedStation() {
mPresenter!!.onAutopilotArriveAtStation(null)
mPresenter!!.arriveStation(null, "点击debug进站按钮触发进站操作")
}
@NonNull
@Override
protected BusPresenter createPresenter() {
return new BusPresenter(this);
override fun createPresenter(): BusPresenter {
return BusPresenter(this)
}
@Override
public void onResume() {
super.onResume();
override fun onResume() {
super.onResume()
}
public void hideStationsPanel(){
groupStationsPanel.setVisibility(View.GONE);
noDataView.setVisibility(View.VISIBLE);
fun hideStationsPanel() {
groupStationsPanel!!.visibility = View.GONE
noDataView!!.visibility = View.VISIBLE
}
public void showStationsPanel(){
groupStationsPanel.setVisibility(View.VISIBLE);
noDataView.setVisibility(View.GONE);
fun showStationsPanel() {
groupStationsPanel!!.visibility = View.VISIBLE
noDataView!!.visibility = View.GONE
}
public void updateLineEmptyUI(){
setArrivedClikable(false);
showOrHideSwitchLineBtn(true);
hideStationsPanel();
hideSlidePanel();
resetStationBlinkAnim();
fun updateLineEmptyUI() {
setArrivedClikable(false)
showOrHideSwitchLineBtn(true)
hideStationsPanel()
hideSlidePanel()
resetStationBlinkAnim()
}
private void resetStationBlinkAnim() {
BlinkAnimationUtil.clearAnimation(firstStationItem.getCircleImageView());
BlinkAnimationUtil.clearAnimation(secondStationItem.getCircleImageView());
BlinkAnimationUtil.clearAnimation(thirdStationItem.getCircleImageView());
private fun resetStationBlinkAnim() {
BlinkAnimationUtil.clearAnimation(firstStationItem!!.getCircleImageView())
BlinkAnimationUtil.clearAnimation(secondStationItem!!.getCircleImageView())
BlinkAnimationUtil.clearAnimation(thirdStationItem!!.getCircleImageView())
}
public void updateBusTaskStatus(String lineName, String lineTime,
List<BusStationBean> stationList,
int arrivingOrArrivedIndex,
boolean isArrived){
if (getActivity() == null) {
return;
fun updateBusTaskStatus(
lineName: String?, lineTime: String,
stationList: List<BusStationBean>?,
arrivingOrArrivedIndex: Int,
isArrived: Boolean
) {
if (activity == null) {
return
}
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if (stationList == null) {
// 获取小巴数据失败
return;
}
showStationsPanel();
showOrHideSwitchLineBtn(false);
mLineName.setText(lineName);
mTaskTime.setText(getString(R.string.bus_line_time_tag)+ lineTime);
// 渲染小巴路线数据
updateBusStationStatus(stationList,arrivingOrArrivedIndex,isArrived);
UiThreadHandler.post(Runnable {
if (stationList == null) {
// 获取小巴数据失败
return@Runnable
}
},UiThreadHandler.MODE.QUEUE);
showStationsPanel()
showOrHideSwitchLineBtn(false)
mLineName!!.text = lineName
mTaskTime!!.text = getString(R.string.bus_line_time_tag) + lineTime
// 渲染小巴路线数据
updateBusStationStatus(stationList, arrivingOrArrivedIndex, isArrived)
}, UiThreadHandler.MODE.QUEUE)
}
private void updateBusStationStatus(List<BusStationBean> stationList,
int arrivingOrArrivedIndex,
boolean isArrived) {
private fun updateBusStationStatus(
stationList: List<BusStationBean>,
arrivingOrArrivedIndex: Int,
isArrived: Boolean
) {
startStation = stationList[0]
endStation = stationList[stationList.size - 1]
startStation = stationList.get(0);
endStation = stationList.get(stationList.size() - 1);
if (arrivingOrArrivedIndex == stationList.size() - 1 && isArrived){
if (arrivingOrArrivedIndex == stationList.size - 1 && isArrived) {
//切换路线和结束路线按钮切换
showSlidePanel("单程结束");
showSlidePanel("单程结束")
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
, endStation.getLon(),R.raw.end_marker);
}else if (arrivingOrArrivedIndex == 0 && isArrived){
setOrRemoveMapMaker(
false, BusConst.BUS_END_MAP_MAKER, endStation!!.lat,
endStation!!.lon, R.raw.end_marker
)
} else if (arrivingOrArrivedIndex == 0 && isArrived) {
showSlidePanel("滑动出发")
showSlidePanel("滑动出发");
setOrRemoveMapMaker(true, BusConst.BUS_START_MAP_MAKER,
startStation.getLat(), startStation.getLon(),R.raw.star_marker);
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER,
endStation.getLat(), endStation.getLon(),R.raw.end_marker);
}else{
if (isArrived){
setOrRemoveMapMaker(
true, BusConst.BUS_START_MAP_MAKER,
startStation!!.lat, startStation!!.lon, R.raw.star_marker
)
setOrRemoveMapMaker(
true, BusConst.BUS_END_MAP_MAKER,
endStation!!.lat, endStation!!.lon, R.raw.end_marker
)
} else {
if (isArrived) {
// 重置滑动按钮文字
showSlidePanel("滑动出发");
showSlidePanel("滑动出发")
}
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
, startStation.getLon(),R.raw.star_marker);
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
, endStation.getLon(),R.raw.end_marker);
setOrRemoveMapMaker(
false, BusConst.BUS_START_MAP_MAKER, startStation!!.lat,
startStation!!.lon, R.raw.star_marker
)
setOrRemoveMapMaker(
true, BusConst.BUS_END_MAP_MAKER, endStation!!.lat,
endStation!!.lon, R.raw.end_marker
)
}
if (stationList.size() > 2){ //只有两个站点
updateMoreThanTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
}else {
updateTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
if (stationList.size > 2) { //只有两个站点
updateMoreThanTwoStationsUI(stationList, arrivingOrArrivedIndex, isArrived)
} else {
updateTwoStationsUI(stationList, arrivingOrArrivedIndex, isArrived)
}
updateBusTestBarInfo();
updateBusTestBarInfo()
}
/**
@@ -275,87 +263,84 @@ public class ShuttleFragment extends BaseShuttleTabFragment<ShuttleFragment, Bus
* @param arrivingOrArrivedIndex
* @param isArrived
*/
private void updateMoreThanTwoStationsUI(List<BusStationBean> stationList,
int arrivingOrArrivedIndex,
boolean isArrived) {
secondStationItem.setStationTag("");
secondStationItem.showOrHideStationArrowBg(true);
thirdStationItem.setStationTag("");
secondStationItem.setVisibility(View.VISIBLE);
thirdStationItem.showOrHideStationArrowBg(false);
private fun updateMoreThanTwoStationsUI(
stationList: List<BusStationBean>,
arrivingOrArrivedIndex: Int,
isArrived: Boolean
) {
secondStationItem!!.setStationTag("")
secondStationItem!!.showOrHideStationArrowBg(true)
thirdStationItem!!.setStationTag("")
secondStationItem!!.visibility = View.VISIBLE
thirdStationItem!!.showOrHideStationArrowBg(false)
if (arrivingOrArrivedIndex == 0 || arrivingOrArrivedIndex -1 == 0
|| (arrivingOrArrivedIndex -2 == 0 && stationList.size() == 3)){
firstStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start));
}else {
firstStationItem.setStationTag("");
if (arrivingOrArrivedIndex == 0 || arrivingOrArrivedIndex - 1 == 0 || (arrivingOrArrivedIndex - 2 == 0 && stationList.size == 3)) {
firstStationItem!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start))
} else {
firstStationItem!!.setStationTag("")
}
if (arrivingOrArrivedIndex + 1 == stationList.size() - 1 || arrivingOrArrivedIndex == stationList.size() - 1
|| (arrivingOrArrivedIndex == 0 && arrivingOrArrivedIndex + 2 == stationList.size() - 1)){ //确认是否显示 "终"
thirdStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end));
}else {
thirdStationItem.setStationTag("");
if (arrivingOrArrivedIndex + 1 == stationList.size - 1 || arrivingOrArrivedIndex == stationList.size - 1 || (arrivingOrArrivedIndex == 0 && arrivingOrArrivedIndex + 2 == stationList.size - 1)) { //确认是否显示 "终"
thirdStationItem!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end))
} else {
thirdStationItem!!.setStationTag("")
}
//圆点: 0:灰色 过站 1绿色 到站或者即将到站 2蓝色未到站
if (arrivingOrArrivedIndex == 0 && isArrived){
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
if (arrivingOrArrivedIndex == 0 && isArrived) {
firstStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
secondStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
firstStationItem.setStationName(stationList.get(0).getName());
secondStationItem.setStationName(stationList.get(1).getName());
thirdStationItem.setStationName(stationList.get(2).getName());
firstStationItem!!.setStationName(stationList[0].name)
secondStationItem!!.setStationName(stationList[1].name)
thirdStationItem!!.setStationName(stationList[2].name)
firstStationItem.setStationPointBg(1);
secondStationItem.setStationPointBg(2);
thirdStationItem.setStationPointBg(2);
firstStationItem!!.setStationPointBg(1)
secondStationItem!!.setStationPointBg(2)
thirdStationItem!!.setStationPointBg(2)
firstStationItem.setStationArrowBg(2);
secondStationItem.setStationArrowBg(2);
firstStationItem!!.setStationArrowBg(2)
secondStationItem!!.setStationArrowBg(2)
} else if (arrivingOrArrivedIndex == stationList.size - 1) {
firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
secondStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
thirdStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
}else if (arrivingOrArrivedIndex == stationList.size() - 1){
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
firstStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 2].name)
secondStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name)
thirdStationItem!!.setStationName(stationList[arrivingOrArrivedIndex].name)
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -2).getName());
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
firstStationItem!!.setStationPointBg(0)
secondStationItem!!.setStationPointBg(0)
thirdStationItem!!.setStationPointBg(1)
firstStationItem.setStationPointBg(0);
secondStationItem.setStationPointBg(0);
thirdStationItem.setStationPointBg(1);
firstStationItem.setStationArrowBg(0);
if (isArrived){
secondStationItem.setStationArrowBg(0);
}else {
secondStationItem.setStationArrowBg(1);
firstStationItem!!.setStationArrowBg(0)
if (isArrived) {
secondStationItem!!.setStationArrowBg(0)
} else {
secondStationItem!!.setStationArrowBg(1)
}
} else {
firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
secondStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
}else {
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
firstStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name)
secondStationItem!!.setStationName(stationList[arrivingOrArrivedIndex].name)
thirdStationItem!!.setStationName(stationList[arrivingOrArrivedIndex + 1].name)
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex + 1).getName());
firstStationItem!!.setStationPointBg(0)
secondStationItem!!.setStationPointBg(1)
thirdStationItem!!.setStationPointBg(2)
firstStationItem.setStationPointBg(0);
secondStationItem.setStationPointBg(1);
thirdStationItem.setStationPointBg(2);
secondStationItem.setStationArrowBg(2);
if (isArrived){
firstStationItem.setStationArrowBg(0);
}else {
firstStationItem.setStationArrowBg(1);
secondStationItem!!.setStationArrowBg(2)
if (isArrived) {
firstStationItem!!.setStationArrowBg(0)
} else {
firstStationItem!!.setStationArrowBg(1)
}
}
}
/**
@@ -364,109 +349,110 @@ public class ShuttleFragment extends BaseShuttleTabFragment<ShuttleFragment, Bus
* @param arrivingOrArrivedIndex
* @param isArrived
*/
private void updateTwoStationsUI(List<BusStationBean> stationList,
int arrivingOrArrivedIndex,
boolean isArrived) {
private fun updateTwoStationsUI(
stationList: List<BusStationBean>,
arrivingOrArrivedIndex: Int,
isArrived: Boolean
) {
secondStationItem!!.visibility = View.GONE
secondStationItem!!.showOrHideStationArrowBg(false)
thirdStationItem!!.showOrHideStationArrowBg(false)
secondStationItem.setVisibility(View.GONE);
secondStationItem.showOrHideStationArrowBg(false);
thirdStationItem.showOrHideStationArrowBg(false);
firstStationItem!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start))
thirdStationItem!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end))
firstStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start));
thirdStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end));
firstStationItem.setStationName(stationList.get(0).getName());
thirdStationItem.setStationName(stationList.get(1).getName());
firstStationItem!!.setStationName(stationList[0].name)
thirdStationItem!!.setStationName(stationList[1].name)
//圆点: 0:灰色 过站 1绿色 到站或者即将到站 2蓝色未到站
if (arrivingOrArrivedIndex == 0 && isArrived){//到站
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
firstStationItem.setStationPointBg(1);
firstStationItem.setStationArrowBg(2);
thirdStationItem.setStationPointBg(0);
}else {
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
if (isArrived){ //到终点
firstStationItem.setStationPointBg(0);
firstStationItem.setStationArrowBg(0);
thirdStationItem.setStationPointBg(1);
}else { //到终点途中
firstStationItem.setStationPointBg(0);
firstStationItem.setStationArrowBg(1);
thirdStationItem.setStationPointBg(1);
}
if (arrivingOrArrivedIndex == 0 && isArrived) { //到站
firstStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
firstStationItem!!.setStationPointBg(1)
firstStationItem!!.setStationArrowBg(2)
thirdStationItem!!.setStationPointBg(0)
} else {
firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
thirdStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
if (isArrived) { //到终点
firstStationItem!!.setStationPointBg(0)
firstStationItem!!.setStationArrowBg(0)
thirdStationItem!!.setStationPointBg(1)
} else { //到终点途中
firstStationItem!!.setStationPointBg(0)
firstStationItem!!.setStationArrowBg(1)
thirdStationItem!!.setStationPointBg(1)
}
}
}
private void showOrHideSwitchLineBtn(boolean isShow) {
if (isShow){//显示切换路线
mSwitchLine.setTag(0);
mSwitchLine.setText(ResourcesUtils.getString(R.string.bus_switch_line_btn));
}else {//显示结束路线
mSwitchLine.setTag(1);
mSwitchLine.setText(ResourcesUtils.getString(R.string.bus_close_line_btn));
private fun showOrHideSwitchLineBtn(isShow: Boolean) {
if (isShow) { //显示切换路线
mSwitchLine!!.tag = 0
mSwitchLine!!.text =
ResourcesUtils.getString(R.string.bus_switch_line_btn)
} else { //显示结束路线
mSwitchLine!!.tag = 1
mSwitchLine!!.text =
ResourcesUtils.getString(R.string.bus_close_line_btn)
}
}
public void hideOchBus() {
fun hideOchBus() {
// tvNotice.setVisibility(View.GONE);
}
@Override
public int getStationPanelViewId() {
return R.layout.shuttle_weak_fragment_och;
override fun stationPanelViewId(): Int {
return R.layout.shuttle_weak_fragment_och
}
@Override
public void restartAutopilot() {
override fun restartAutopilot() {
if (!isAnimateRunning) {
mPresenter.restartAutopilot();
mPresenter!!.restartAutopilot()
}
}
@Override
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
return this;
override fun slidePanelOnEndListener(): SlidePanelView.OnSlidePanelMoveToEndListener {
return this
}
@Override
public void moveToEnd() {
override fun moveToEnd() {
// 开启自动驾驶到下一站
if (isAnimateRunning){
stopAutopilotAnimation();
if (isAnimateRunning) {
stopAutopilotAnimation()
}
mPresenter.autoDriveToNextStation();
mPresenter!!.autoDriveToNextStation()
}
/**
* 设置自动驾驶可用状态
*/
public void onAutopilotEnableChange(boolean isEnable) {
fun onAutopilotEnableChange(isEnable: Boolean) {
if (isEnable) {
showAutopilotBiz();
showAutopilotBiz()
} else {
hideAutopilotBiz();
hideAutopilotBiz()
}
}
public void clearBusStationsMarkers(){
CallerLogger.d(M_BUS + TAG,"clearBusStationsMarkers()");
fun clearBusStationsMarkers() {
d(SceneConstant.M_BUS + TAG, "clearBusStationsMarkers()")
if (null != startStation) {
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
, startStation.getLon(),R.raw.star_marker);
setOrRemoveMapMaker(
false, BusConst.BUS_START_MAP_MAKER, startStation!!.lat,
startStation!!.lon, R.raw.star_marker
)
}
if (null != endStation) {
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
, endStation.getLon(),R.raw.end_marker);
setOrRemoveMapMaker(
false, BusConst.BUS_END_MAP_MAKER, endStation!!.lat,
endStation!!.lon, R.raw.end_marker
)
}
//清除鹰眼右下角小地图轨迹
CallerLogger.d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->");
smallMapView.clearPolyline();
d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->")
smallMapView?.clearPolyline()
}
/**
@@ -475,13 +461,21 @@ public class ShuttleFragment extends BaseShuttleTabFragment<ShuttleFragment, Bus
* @param isAdd
* @param uuid
*/
private void setOrRemoveMapMaker(boolean isAdd, String uuid, double lat, double longi,int resourceId) {
private fun setOrRemoveMapMaker(
isAdd: Boolean,
uuid: String,
lat: Double,
longi: Double,
resourceId: Int
) {
if (isAdd) {
Runnable setMapMarkerRunnable = () -> {
CallerLogger.d(M_BUS + "setMapMaker= "+Thread.currentThread().getName(),
uuid + "=latitude=" + lat + ",longitude=" + longi);
Point.Options.Builder builder = new Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER)
val setMapMarkerRunnable = Runnable {
d(
SceneConstant.M_BUS + "setMapMaker= " + Thread.currentThread().name,
"$uuid=latitude=$lat,longitude=$longi"
)
val builder =
Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER)
.setId(uuid)
.anchor(0.5f, 0.5f)
.set3DMode(true)
@@ -489,63 +483,63 @@ public class ShuttleFragment extends BaseShuttleTabFragment<ShuttleFragment, Bus
.controlAngle(false)
.icon3DRes(resourceId)
.latitude(lat)
.longitude(longi);
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
if (overlayManager != null) {
overlayManager.showOrUpdatePoint(builder.build(),DEFAULT);
}
};
.longitude(longi)
val overlayManager = getOverlayManager()
overlayManager?.showOrUpdatePoint(builder.build(), MogoMap.DEFAULT)
}
OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable);
}else {
Runnable removeMapMarkerRunnable = () -> {
CallerLogger.d(M_BUS + "RemoveMapMaker="+Thread.currentThread().getName(),
uuid+"=latitude="+lat+",longitude="+longi);
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getOverlayManager()).removePoint(uuid);
};
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable);
OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable)
} else {
val removeMapMarkerRunnable = Runnable {
d(
SceneConstant.M_BUS + "RemoveMapMaker=" + Thread.currentThread().name,
"$uuid=latitude=$lat,longitude=$longi"
)
getOverlayManager()?.removePoint(uuid)
}
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable)
}
}
@Override
public void debugAutoPilotStatus(int status) {
mPresenter.debugAutoPilotStatus(status);
override fun debugAutoPilotStatus(status: Int) {
mPresenter!!.debugAutoPilotStatus(status)
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中点击则toast提示自动驾驶中不可切换路线
override fun onClick(v: View) {
if (v.id == R.id.switch_line_btn) { //切换路线条件: 自动驾驶过程中点击则toast提示自动驾驶中不可切换路线
//本次行程未结束不支持切换路线。点击则toast提示当前行程未完成不可切换路线
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1));
return;
if (getState()
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
) {
ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1))
return
}
if ((int)mSwitchLine.getTag() == 0){//切换路线
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
ActivityUtils.startActivity(intent);
}else {//结束任务
OCHCommitDialog.Builder builder = new OCHCommitDialog.Builder();
OCHCommitDialog closeLineConfirmDialog = builder
.title(getString(R.string.bus_dialog_title))
.tips(getString(R.string.bus_dialog_tips))
.confirmStr(getString(R.string.bus_dialog_confirm))
.cancelStr(getString(R.string.bus_dialog_cancel))
.build(getContext());
closeLineConfirmDialog.setClickListener(new OCHCommitDialog.ClickListener() {
@Override
public void confirm() {
mPresenter.abortTask();
if (mSwitchLine!!.tag as Int == 0) { //切换路线
val intent = Intent(context, BusSwitchLineActivity::class.java)
ActivityUtils.startActivity(intent)
} else { //结束任务
val builder = OCHCommitDialog.Builder()
val closeLineConfirmDialog = builder
.title(getString(R.string.bus_dialog_title))
.tips(getString(R.string.bus_dialog_tips))
.confirmStr(getString(R.string.bus_dialog_confirm))
.cancelStr(getString(R.string.bus_dialog_cancel))
.build(AbsMogoApplication.getApp())
closeLineConfirmDialog!!.setClickListener(object : OCHCommitDialog.ClickListener {
override fun confirm() {
mPresenter!!.abortTask()
}
@Override
public void cancel() {
closeLineConfirmDialog.dismiss();
override fun cancel() {
closeLineConfirmDialog.dismiss()
}
});
closeLineConfirmDialog.show();
})
closeLineConfirmDialog.show()
}
}
}
companion object {
const val TAG: String = "BusFragment"
}
}

View File

@@ -96,8 +96,8 @@ object TicketModel : IReceivedMsgListener, IOchOnMessageListener<WriteOffPasseng
}
private fun selectWriteOffCount(){
val busRoutesResult = OrderModel.getInstance().busRoutesResult
val busNextStation = OrderModel.getInstance().busNextStation
val busRoutesResult = OrderModel.busRoutesResult
val busNextStation = OrderModel.busNextStation
if(busRoutesResult==null||busNextStation==null){
emitterMain?.onNext(0)
d(SceneConstant.M_BUS + TAG, "线路或者站点未空:${busRoutesResult}----${busNextStation}")

View File

@@ -1,109 +1,102 @@
package com.mogo.och.weaknet.presenter;
package com.mogo.och.weaknet.presenter
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.mvp.Presenter;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse;
import com.mogo.och.weaknet.bean.BusQueryLinesResponse;
import com.mogo.och.weaknet.callback.IBusLinesCallback;
import com.mogo.och.weaknet.model.BusLineModel;
import com.mogo.och.weaknet.model.OrderModel;
import com.mogo.och.weaknet.ui.BusSwitchLineView;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import androidx.lifecycle.LifecycleOwner
import com.mogo.commons.mvp.Presenter
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
import com.mogo.och.weaknet.callback.IBusLinesCallback
import com.mogo.och.weaknet.model.BusLineModel
import com.mogo.och.weaknet.model.BusLineModel.queryBusLineTasksById
import com.mogo.och.weaknet.model.BusLineModel.setBusLinesCallback
import com.mogo.och.weaknet.model.OrderModel
import com.mogo.och.weaknet.model.OrderModel.clearBusStationDatas
import com.mogo.och.weaknet.ui.BusSwitchLineView
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit
/**
* @author: wangmingjun
* @date: 2022/2/9
*/
public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IBusLinesCallback {
class BusLinePresenter(view: BusSwitchLineView?) : Presenter<BusSwitchLineView?>(view),
IBusLinesCallback {
private var subscribe: Disposable? = null
private Disposable subscribe;
public BusLinePresenter(BusSwitchLineView view) {
super(view);
BusLineModel.init();
OrderModel.getInstance().init();
init {
BusLineModel.init()
OrderModel.init()
}
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
initListener();
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
initListener()
}
private void initListener() {
BusLineModel.setBusLinesCallback(this);
private fun initListener() {
setBusLinesCallback(this)
}
@Override
public void onBusLinesChange(List<BusQueryLinesResponse.Result> data) {
if(mView!=null) {
mView.onBusLinesChange(data);
override fun onBusLinesChange(data: List<BusQueryLinesResponse.Result>) {
if (mView != null) {
mView!!.onBusLinesChange(data)
}
}
@Override
public void onChangeLineIdSuccess() {
OrderModel.getInstance().clearBusStationDatas();
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.onChangeLineIdSuccess();
}
override fun onChangeLineIdSuccess() {
clearBusStationDatas()
UiThreadHandler.post({
if (mView != null) {
mView!!.onChangeLineIdSuccess()
}
}, UiThreadHandler.MODE.QUEUE);
}, UiThreadHandler.MODE.QUEUE)
}
public void queryBusLines(){
BusLineModel.queryBusLines();
fun queryBusLines() {
BusLineModel.queryBusLines()
}
public void queryBusLineTasks(long lineId, int position,boolean close){
if(subscribe!=null&&!subscribe.isDisposed()){
subscribe.dispose();
fun queryBusLineTasks(lineId: Long, position: Int, close: Boolean) {
if (subscribe != null && !subscribe!!.isDisposed) {
subscribe!!.dispose()
}
if(close){
return;
if (close) {
return
}
queryBusLineTasksById(lineId, position, false)
subscribe = Observable.interval(3, TimeUnit.MINUTES).subscribe { aLong: Long? ->
queryBusLineTasksById(lineId, position, true)
}
BusLineModel.queryBusLineTasksById(lineId,position,false);
subscribe = Observable.interval(3, TimeUnit.MINUTES).subscribe(aLong -> {
BusLineModel.queryBusLineTasksById(lineId,position,true);
});
}
public void commitSwitchLineId(long taskId,long lineId){
BusLineModel.commitSwitchLineId(taskId,lineId);
fun commitSwitchLineId(taskId: Long, lineId: Long) {
BusLineModel.commitSwitchLineId(taskId, lineId)
}
public void removeListener(){
BusLineModel.setBusLinesCallback(null);
fun removeListener() {
setBusLinesCallback(null)
}
public void queryBusRoutes(){
OrderModel.getInstance().queryBusRoutes();
fun queryBusRoutes() {
OrderModel.queryBusRoutes()
}
@Override
public void onDestroy(@NonNull LifecycleOwner owner) {
super.onDestroy(owner);
if(subscribe!=null&&!subscribe.isDisposed()){
subscribe.dispose();
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
if (subscribe != null && !subscribe!!.isDisposed) {
subscribe!!.dispose()
}
}
@Override
public void onBusLineTasks(List<BusQueryLineTaskResponse.Result> o, int position, boolean autoRefresh) {
if(mView!=null) {
mView.onBusLineTasks(o,position,autoRefresh);
override fun onBusLineTasks(
o: List<BusQueryLineTaskResponse.Result>,
position: Int,
autoRefresh: Boolean
) {
if (mView != null) {
mView!!.onBusLineTasks(o, position, autoRefresh)
}
}
}

View File

@@ -1,325 +1,274 @@
package com.mogo.och.weaknet.presenter;
package com.mogo.och.weaknet.presenter
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.mvp.Presenter;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.common.module.biz.login.LoginStatusEnum;
import com.mogo.och.common.module.manager.autopilot.autopilot.ArrivedStation;
import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatusListener;
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotStatusListenerManager;
import com.mogo.och.data.bean.BusStationBean;
import com.mogo.och.common.module.biz.login.ILoginCallback;
import com.mogo.och.common.module.biz.login.LoginStatusManager;
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager;
import com.mogo.och.weaknet.callback.IBusADASStatusCallback;
import com.mogo.och.weaknet.callback.IBusControllerStatusCallback;
import com.mogo.och.weaknet.callback.IRefreshBusStationsCallback;
import com.mogo.och.weaknet.callback.ISlidePannelHideCallback;
import com.mogo.och.weaknet.fragment.ShuttleFragment;
import com.mogo.och.weaknet.model.OrderModel;
import com.mogo.och.weaknet.util.BusTrajectoryManager;
import java.util.ArrayList;
import java.util.List;
import mogo_msg.MogoReportMsg;
import androidx.lifecycle.LifecycleOwner
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.mvp.Presenter
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isCanStartAutopilot
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.common.module.biz.login.ILoginCallback
import com.mogo.och.common.module.biz.login.LoginStatusEnum
import com.mogo.och.common.module.biz.login.LoginStatusManager
import com.mogo.och.common.module.biz.login.LoginStatusManager.isLogin
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.autopilot.autopilot.ArrivedStation
import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatusListener
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotStatusListenerManager
import com.mogo.och.data.bean.BusStationBean
import com.mogo.och.weaknet.callback.IBusADASStatusCallback
import com.mogo.och.weaknet.callback.IBusControllerStatusCallback
import com.mogo.och.weaknet.callback.IRefreshBusStationsCallback
import com.mogo.och.weaknet.callback.ISlidePannelHideCallback
import com.mogo.och.weaknet.fragment.ShuttleFragment
import com.mogo.och.weaknet.model.OrderModel
import com.mogo.och.weaknet.model.OrderModel.closeBeautificationMode
import com.mogo.och.weaknet.model.OrderModel.init
import com.mogo.och.weaknet.model.OrderModel.isGoingToNextStation
import com.mogo.och.weaknet.model.OrderModel.isRestartAutopilot
import com.mogo.och.weaknet.model.OrderModel.onArriveAt
import com.mogo.och.weaknet.model.OrderModel.queryBusCacheRoutes
import com.mogo.och.weaknet.model.OrderModel.release
import com.mogo.och.weaknet.model.OrderModel.setAdasStatusCallback
import com.mogo.och.weaknet.model.OrderModel.setControllerStatusCallback
import com.mogo.och.weaknet.model.OrderModel.setRefreshBusStationsCallback
import com.mogo.och.weaknet.model.OrderModel.setSlidePanelHideCallback
import com.mogo.och.weaknet.model.OrderModel.triggerStartServiceEvent
import com.mogo.och.weaknet.util.BusTrajectoryManager
import mogo_msg.MogoReportMsg.MogoReportMessage
/**
* 网约车小巴
*
* @author tongchenfei
*/
public class BusPresenter extends Presenter<ShuttleFragment>
implements IRefreshBusStationsCallback, ISlidePannelHideCallback
, IOchAutopilotStatusListener, IBusControllerStatusCallback, ILoginCallback, IBusADASStatusCallback {
class BusPresenter(view: ShuttleFragment?) : Presenter<ShuttleFragment?>(view),
IRefreshBusStationsCallback, ISlidePannelHideCallback, IOchAutopilotStatusListener,
IBusControllerStatusCallback, ILoginCallback, IBusADASStatusCallback {
private val mStationList: MutableList<BusStationBean> = ArrayList()
private var mCurrentStation = 0
private static final String TAG = "BusPresenter";
private final List<BusStationBean> mStationList = new ArrayList<>();
private int mCurrentStation = 0;
public BusPresenter(ShuttleFragment view) {
super(view);
init {
//2021.11.1 鹰眼架构整合由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口
OrderModel.getInstance().init();
OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp());
init()
OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp())
}
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
initModelListener();
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
initModelListener()
OrderModel.getInstance().queryBusCacheRoutes();
queryBusCacheRoutes()
}
@Override
public void onDestroy(@NonNull LifecycleOwner owner) {
super.onDestroy(owner);
OrderModel.getInstance().release();
releaseListener();
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
release()
releaseListener()
}
public void initModelListener() {
OrderModel.getInstance().setRefreshBusStationsCallback(this);
OrderModel.getInstance().setSlidePanelHideCallback(this);
OrderModel.getInstance().setControllerStatusCallback(this);
OrderModel.getInstance().setAdasStatusCallback(this);
OchAutoPilotStatusListenerManager.INSTANCE.addListener(TAG,this);
LoginStatusManager.INSTANCE.addListener(TAG,this);
fun initModelListener() {
setRefreshBusStationsCallback(this)
setSlidePanelHideCallback(this)
setControllerStatusCallback(this)
setAdasStatusCallback(this)
OchAutoPilotStatusListenerManager.addListener(TAG, this)
LoginStatusManager.addListener(TAG, this)
}
public void releaseListener() {
OrderModel.getInstance().setRefreshBusStationsCallback(null);
OrderModel.getInstance().setSlidePanelHideCallback(null);
OrderModel.getInstance().setControllerStatusCallback(null);
OrderModel.getInstance().setAdasStatusCallback(null);
OCHAdasAbilityManager.getInstance().release();
OchAutoPilotStatusListenerManager.INSTANCE.removeListener(TAG);
LoginStatusManager.INSTANCE.removeListener(TAG);
fun releaseListener() {
setRefreshBusStationsCallback(null)
setSlidePanelHideCallback(null)
setControllerStatusCallback(null)
setAdasStatusCallback(null)
OCHAdasAbilityManager.getInstance().release()
OchAutoPilotStatusListenerManager.removeListener(TAG)
LoginStatusManager.removeListener(TAG)
}
public void abortTask() {
OrderModel.getInstance().abortTask();
fun abortTask() {
OrderModel.abortTask()
}
public void autoDriveToNextStation() {
OrderModel.getInstance().autoDriveToNextStation();
fun autoDriveToNextStation() {
OrderModel.autoDriveToNextStation()
}
public void restartAutopilot() {
if (OrderModel.getInstance().isGoingToNextStation()){
OrderModel.getInstance().restartAutopilot();
fun restartAutopilot() {
if (isGoingToNextStation) {
OrderModel.restartAutopilot()
}
}
// 登出
public void logout() {
OrderModel.getInstance().logout();
fun logout() {
OrderModel.logout()
}
@Override
public void updateBusTaskStatus(String lineName,String lineTime,
List<BusStationBean> stationList,
int arrivingOrArrivedIndex,
boolean isArrived) {
mStationList.clear();
mStationList.addAll(stationList);
if (arrivingOrArrivedIndex == 0 || isArrived){
mCurrentStation = arrivingOrArrivedIndex;
}else {
mCurrentStation = arrivingOrArrivedIndex -1;
override fun updateBusTaskStatus(
lineName: String, lineTime: String,
stationList: List<BusStationBean>,
arrivingOrArrivedIndex: Int,
isArrived: Boolean
) {
mStationList.clear()
mStationList.addAll(stationList)
mCurrentStation = if (arrivingOrArrivedIndex == 0 || isArrived) {
arrivingOrArrivedIndex
} else {
arrivingOrArrivedIndex - 1
}
CallerLogger.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation);
d(SceneConstant.M_BUS + "BusOrderModel =", " mCurrentStation =$mCurrentStation")
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.updateBusTaskStatus(lineName,lineTime,
stationList, arrivingOrArrivedIndex, isArrived);
}
}
}, UiThreadHandler.MODE.QUEUE);
}
@Override
public void updateEmptyUi() {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.updateLineEmptyUI();
}
}
}, UiThreadHandler.MODE.QUEUE);
}
@Override
public void clearBusStationsMarkers() {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.clearBusStationsMarkers();
}
}
}, UiThreadHandler.MODE.QUEUE);
}
@Override
public void hideSlidePanel() {
if (mView != null) {
mView.hideSlidePanel();
mView.setArrivedClikable(true);
}
}
@Override
public void onAutopilotArriveAtStation(ArrivedStation arrivedStation) {
CallerLogger.e( M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive");
arriveStation(arrivedStation,"底盘触发进站");
}
public void arriveStation(ArrivedStation arrivedStation,String type){
OrderModel.getInstance().onArriveAt(arrivedStation,type);
}
@Override
public void onAutopilotStatusResponse(int state) {
switch (state) {
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING:
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
if (FunctionBuildConfig.isDemoMode
&& (
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
&& OrderModel.getInstance().isGoingToNextStation()
UiThreadHandler.post({
if (mView != null) {
mView!!.updateBusTaskStatus(
lineName, lineTime,
stationList, arrivingOrArrivedIndex, isArrived
)
) {
CallerLogger.d(M_BUS + "BusOrderModel=", "有美化功能");
return;
}
// 改变UI自动驾驶状态
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false,0));
}
}
}, UiThreadHandler.MODE.QUEUE);
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
OrderModel.getInstance().triggerStartServiceEvent(
OrderModel.getInstance().isRestartAutopilot(), true);
// 改变UI自动驾驶状态
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false,0));
}
}
}, UiThreadHandler.MODE.QUEUE);
break;
default:
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.onAutopilotEnableChange(false);
}
}
}, UiThreadHandler.MODE.QUEUE);
break;
}
}, UiThreadHandler.MODE.QUEUE)
}
override fun updateEmptyUi() {
UiThreadHandler.post({
if (mView != null) {
mView!!.updateLineEmptyUI()
}
}, UiThreadHandler.MODE.QUEUE)
}
override fun clearBusStationsMarkers() {
UiThreadHandler.post({
if (mView != null) {
mView!!.clearBusStationsMarkers()
}
}, UiThreadHandler.MODE.QUEUE)
}
override fun hideSlidePanel() {
if (mView != null) {
mView!!.hideSlidePanel()
mView!!.setArrivedClikable(true)
}
}
@Override
public void onCarLocationChanged(MogoLocation location) {
// if (null != location) {
// runOnUIThread(() -> mView.updateSpeedView(location.getGnssSpeed()));
// }
override fun onAutopilotArriveAtStation(arrivedStation: ArrivedStation?) {
e(SceneConstant.M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive")
arriveStation(arrivedStation, "底盘触发进站")
}
@Override
public void startOpenAutopilot() {
//非美化模式下启动动画
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.startAutopilotAnimation();
fun arriveStation(arrivedStation: ArrivedStation?, type: String?) {
onArriveAt(arrivedStation, type!!)
}
override fun onAutopilotStatusResponse(state: Int) {
when (state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING, IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
if (FunctionBuildConfig.isDemoMode
&& ((mCurrentStation >= 0 && mCurrentStation <= mStationList.size - 1)
&& isGoingToNextStation
)
) {
d(SceneConstant.M_BUS + "BusOrderModel=", "有美化功能")
return
}
// 改变UI自动驾驶状态
UiThreadHandler.post({
if (mView != null) {
mView!!.onAutopilotStatusChanged(state, isCanStartAutopilot(false, 0))
}
}, UiThreadHandler.MODE.QUEUE)
}
}, UiThreadHandler.MODE.QUEUE);
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
triggerStartServiceEvent(
isRestartAutopilot, true
)
// 改变UI自动驾驶状态
UiThreadHandler.post({
if (mView != null) {
mView!!.onAutopilotStatusChanged(state, isCanStartAutopilot(false, 0))
}
}, UiThreadHandler.MODE.QUEUE)
}
else -> UiThreadHandler.post({
if (mView != null) {
mView!!.onAutopilotEnableChange(false)
}
}, UiThreadHandler.MODE.QUEUE)
}
}
override fun startOpenAutopilot() {
//非美化模式下启动动画
UiThreadHandler.post({
if (mView != null) {
mView!!.startAutopilotAnimation()
}
}, UiThreadHandler.MODE.QUEUE)
//中间站点再次开启自驾时, 自动驾驶状态是2未改变 此次鹰眼底层不再返给业务,需优化按钮动画显示
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
== CallerAutoPilotStatusListenerManager.INSTANCE.getState()&&mView!=null){
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState(),
CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false,0));
}
}
private void runOnUIThread(Runnable executor) {
if (executor == null) {
return;
}
if (Looper.myLooper() != Looper.getMainLooper()) {
UiThreadHandler.post(executor);
} else {
executor.run();
== getState() && mView != null
) {
mView!!.onAutopilotStatusChanged(
getState(),
isCanStartAutopilot(false, 0)
)
}
}
/**
* 测试使用
*/
public void debugAutoPilotStatus(int status) {
onAutopilotStatusResponse(status);
fun debugAutoPilotStatus(status: Int) {
onAutopilotStatusResponse(status)
}
@Override
public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo, long lineId) {
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo,lineId);
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage, lineId: Long) {
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo, lineId)
}
@Override
public void onStatusChange(LoginStatusEnum currentStatus) {
CallerLogger.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin());
if(LoginStatusManager.isLogin()){
// OrderModel.getInstance().queryBusRoutes();
OrderModel.getInstance().queryBusCacheRoutes();
}else {
BusTrajectoryManager.getInstance().stopTrajReqLoop();
BusTrajectoryManager.getInstance().stopTrajReqLoop();
clearBusStationsMarkers();
if(mView!=null) {
mView.hideSlidePanel();
override fun onStatusChange(currentStatus: LoginStatusEnum) {
d(SceneConstant.M_BUS + TAG, " loginStatus =" + isLogin())
if (isLogin()) {
queryBusCacheRoutes()
} else {
BusTrajectoryManager.getInstance().stopTrajReqLoop()
BusTrajectoryManager.getInstance().stopTrajReqLoop()
clearBusStationsMarkers()
if (mView != null) {
mView!!.hideSlidePanel()
}
OrderModel.getInstance().closeBeautificationMode();
closeBeautificationMode()
}
}
@Override
public void onStartAdasFailure() {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.stopAnimAndUpdateBtnStatus();
}
override fun onStartAdasFailure() {
UiThreadHandler.post({
if (mView != null) {
mView!!.stopAnimAndUpdateBtnStatus()
}
}, UiThreadHandler.MODE.QUEUE);
}, UiThreadHandler.MODE.QUEUE)
}
@Override
public void canStartAutopilot(boolean canStart) {
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState(),canStart);
}
override fun canStartAutopilot(canStart: Boolean) {
UiThreadHandler.post({
if (mView != null) {
mView!!.onAutopilotStatusChanged(getState(), canStart)
}
}, UiThreadHandler.MODE.QUEUE);
}, UiThreadHandler.MODE.QUEUE)
}
companion object {
private const val TAG = "BusPresenter"
}
}

View File

@@ -1,56 +1,42 @@
package com.mogo.och.weaknet.util;
package com.mogo.och.weaknet.util
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import androidx.annotation.NonNull;
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics;
/**
* OCH Bus埋点工具
* <p>
*
*
* Created on 2022/3/24
*/
public class BusAnalyticsManager extends OchAutopilotAnalytics {
object BusAnalyticsManager : OchAutopilotAnalytics() {
// 埋点key开启自动驾驶前已识别的异常会导致无法开启自驾
private static final String EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason";
private const val EVENT_KEY_AP_UNABLE_START_REASON =
"event_key_och_bus_ap_unable_start_reason"
// 埋点key接管后点击'自动驾驶'按钮启动
private static final String EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot";
private const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot"
// 埋点key开始服务开启自动驾驶成功/失败)
private static final String EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service";
private const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service"
// 埋点key点击启动自驾
private static final String EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_shuttle_click_start_autopilot";
private const val EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_shuttle_click_start_autopilot"
private static final class SingletonHolder {
private static final BusAnalyticsManager INSTANCE = new BusAnalyticsManager();
override fun getEventKeyStartService(): String {
return EVENT_KEY_START_SERVICE
}
public static BusAnalyticsManager getInstance() {
return SingletonHolder.INSTANCE;
override fun getEventKeyRestartService(): String {
return EVENT_KEY_RESTART_AUTOPILOT
}
@NonNull
@Override
public String getEventKeyStartService() {
return EVENT_KEY_START_SERVICE;
override fun getEventKeyApUnableStartReason(): String {
return EVENT_KEY_AP_UNABLE_START_REASON
}
@NonNull
@Override
public String getEventKeyRestartService() {
return EVENT_KEY_RESTART_AUTOPILOT;
override fun getEventKeyClickStartAutopilot(): String {
return EVENT_KEY_CLICK_START_AUTOPILOT
}
@NonNull
@Override
public String getEventKeyApUnableStartReason() {
return EVENT_KEY_AP_UNABLE_START_REASON;
}
@NonNull
@Override
public String getEventKeyClickStartAutopilot() {
return EVENT_KEY_CLICK_START_AUTOPILOT;
}
}

View File

@@ -50,10 +50,10 @@ public class BusTrajectoryManager {
* 同步Bus路线信息
*/
public void syncTrajectoryInfo() {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
BusRoutesResult routesResult = OrderModel.getBusRoutesResult();
if (LoginStatusManager.isLogin() && routesResult != null
&& OrderModel.getInstance().getCurrentStationIndex() == 0
&& !OrderModel.getInstance().isGoingToNextStation()) {
&& OrderModel.getCurrentStationIndex() == 0
&& !OrderModel.isGoingToNextStation()) {
CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() start.");
startTrajReqLoop();
} else {
@@ -111,7 +111,7 @@ public class BusTrajectoryManager {
}
private void setupAutoPilotLine() {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
BusRoutesResult routesResult = OrderModel.getBusRoutesResult();
if (routesResult == null) {
CallerLogger.e(M_BUS + TAG,
"setupAutoPilotLine(): routesResult is null.");

View File

@@ -1,64 +0,0 @@
package com.mogo.och.weaknet.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
/**
* 垂直虚线
*
* @author tongchenfei
*/
public class VerticalDashLineView extends View {
public VerticalDashLineView(Context context) {
this(context,null);
}
public VerticalDashLineView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}
public VerticalDashLineView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private final Paint linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Path dashPath = new Path();
private void init(){
linePaint.setColor(Color.GREEN);
linePaint.setStyle(Paint.Style.STROKE);
linePaint.setStrokeWidth(2);
linePaint.setPathEffect(new DashPathEffect(new float[]{5, 5}, 0));
}
public void setGradient(int startColor, int endColor) {
LinearGradient linearGradient = new LinearGradient(0, 0, getWidth(), getHeight(), startColor, endColor, Shader.TileMode.CLAMP);
linePaint.setShader(linearGradient);
invalidate();
}
public void setColor(int color) {
linePaint.setShader(null);
linePaint.setColor(color);
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
dashPath.reset();
dashPath.moveTo((float) getWidth()/2, 0);
dashPath.lineTo((float) getWidth()/2,getHeight());
canvas.drawPath(dashPath,linePaint);
}
}

View File

@@ -276,7 +276,7 @@
android:layout_width="@dimen/dp_142"
android:layout_height="@dimen/dp_142"/>
<com.mogo.och.weaknet.view.SlidePanelView
<com.mogo.och.common.module.wigets.SlidePanelView
android:id="@+id/module_mogo_och_slide_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -1,13 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SlidePanelView">
<attr name="textSize" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="BLOCK_START_X" format="dimension" />
<attr name="BLOCK_START_Y" format="dimension" />
</declare-styleable>
</resources>