完成了他人故障求助的展示逻辑统一
This commit is contained in:
@@ -7,12 +7,15 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.V2XEventShowEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.module.v2x.utils.SpanUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
@@ -85,6 +88,13 @@ public class V2XFatigueDrivingVH extends V2XBaseViewHolder {
|
||||
} else {
|
||||
mTvAddress.setText("");
|
||||
}
|
||||
// 计算距离
|
||||
float calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(mV2XPushMessageEntity.getLat(), mV2XPushMessageEntity.getLon()),
|
||||
LocationUtils.getCurrentLatLon()
|
||||
);
|
||||
mV2XPushMessageEntity.setDistance(calculateDistance);
|
||||
|
||||
SpanUtils.with(mTvAddressDistance)
|
||||
.append("" + (int) mV2XPushMessageEntity.getDistance())
|
||||
.setFontSize((int) itemView.getResources().getDimension(R.dimen.dp_80))
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
|
||||
import com.mogo.module.v2x.utils.ChartingUtil;
|
||||
import com.mogo.module.v2x.utils.SpanUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
@@ -74,7 +75,7 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
|
||||
|
||||
public V2XOtherSeekHelpVH(ViewGroup viewGroup) {
|
||||
super(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.window_fault_help, viewGroup, false));
|
||||
.inflate(R.layout.item_v2x_fault_help, viewGroup, false));
|
||||
ivHead = itemView.findViewById(R.id.ivFaultHelpHead);
|
||||
tvName = itemView.findViewById(R.id.tvFaultHelpName);
|
||||
tvDistance = itemView.findViewById(R.id.tvFaultHelpDistance);
|
||||
@@ -168,7 +169,7 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
|
||||
}
|
||||
tvName.setText(mV2XPushMessageEntity.getDisplayName());
|
||||
SpanUtils.with(tvDistance)
|
||||
.append("" + mV2XPushMessageEntity.getDistance())
|
||||
.append("" + (int) mV2XPushMessageEntity.getDistance())
|
||||
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_80))
|
||||
.append("M")
|
||||
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_30))
|
||||
@@ -188,7 +189,7 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
|
||||
*/
|
||||
@Override
|
||||
public void delayedCloseWindow() {
|
||||
itemView.postDelayed(() -> V2XFatigueDrivingScenario.getInstance().close(), 1000);
|
||||
itemView.postDelayed(() -> V2XSeekHelpScenario.getInstance().close(), 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import com.mogo.utils.logger.Logger;
|
||||
*/
|
||||
public abstract class AbsV2XScenario<T> implements IV2XScenario {
|
||||
protected String TAG = "AbsV2XScenario";
|
||||
protected IV2XWindow mV2XWindow;
|
||||
protected IV2XButton mV2XButton;
|
||||
protected IV2XMarker<T> mV2XMarker;
|
||||
protected IMoGoV2XStatusManager mV2XStatusManager;
|
||||
protected V2XMessageEntity<T> mV2XMessageEntity;
|
||||
private IV2XWindow mV2XWindow;
|
||||
private IV2XButton mV2XButton;
|
||||
private IV2XMarker<T> mV2XMarker;
|
||||
private IMoGoV2XStatusManager mV2XStatusManager;
|
||||
private V2XMessageEntity<T> mV2XMessageEntity;
|
||||
|
||||
protected AbsV2XScenario() {
|
||||
this.mV2XStatusManager = V2XServiceManager.getMoGoV2XStatusManager();
|
||||
@@ -62,6 +62,14 @@ public abstract class AbsV2XScenario<T> implements IV2XScenario {
|
||||
this.mV2XWindow = mV2XWindow;
|
||||
}
|
||||
|
||||
public IV2XMarker<T> getV2XMarker() {
|
||||
return mV2XMarker;
|
||||
}
|
||||
|
||||
public IV2XButton getV2XButton() {
|
||||
return mV2XButton;
|
||||
}
|
||||
|
||||
public void setV2XButton(@Nullable IV2XButton mV2XButton) {
|
||||
this.mV2XButton = mV2XButton;
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ public class V2XAnimationScenario extends AbsV2XScenario<V2XPushMessageEntity> {
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.setWindowStatusListener(new V2XWindowStatusListener() {
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().setWindowStatusListener(new V2XWindowStatusListener() {
|
||||
@Override
|
||||
public void onViewShow() {
|
||||
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), mV2XMessageEntity.getContent());
|
||||
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), getV2XMessageEntity().getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,48 +74,48 @@ public class V2XAnimationScenario extends AbsV2XScenario<V2XPushMessageEntity> {
|
||||
clearPOI();
|
||||
}
|
||||
});
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.addView(mV2XWindow.getView(), 0, 0, false);
|
||||
.addView(getV2XWindow().getView(), 0, 0, false);
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setV2XAnimationWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setV2XAnimationWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
setV2XMessageEntity(null);
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,23 +76,23 @@ public class V2XFatigueDrivingScenario extends AbsV2XScenario<V2XPushMessageEnti
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
if (getV2XWindow() != null) {
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(mV2XWindow.getView(), layoutParams, this);
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setFatigueDrivingWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,14 +141,15 @@ public class V2XFatigueDrivingScenario extends AbsV2XScenario<V2XPushMessageEnti
|
||||
* 导航规划路线
|
||||
*/
|
||||
private void startNavi() {
|
||||
if (mV2XMessageEntity.getContent() != null) {
|
||||
if (getV2XMessageEntity().getContent() != null) {
|
||||
// 反注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.unRegisterWakeCmd(
|
||||
V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI)
|
||||
.unRegisterUnWakeVoice(
|
||||
V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP);
|
||||
MogoLatLng endPoint = new MogoLatLng(mV2XMessageEntity.getContent().getLat(), mV2XMessageEntity.getContent().getLon());
|
||||
MogoLatLng endPoint = new MogoLatLng(getV2XMessageEntity().getContent().getLat(),
|
||||
getV2XMessageEntity().getContent().getLon());
|
||||
V2XServiceManager.getNavi().naviTo(endPoint);
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.adapter.V2XRoadEventAdapter;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -71,7 +69,7 @@ public class V2XFatigueDrivingWindow extends RelativeLayout
|
||||
|
||||
public void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "V2X-初始化疲劳驾驶");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_road_event_detail, this);
|
||||
LayoutInflater.from(context).inflate(R.layout.window_fault_help, this);
|
||||
// 详情列表
|
||||
mRecyclerView = findViewById(R.id.rvRoadEventList);
|
||||
mV2XRoadEventAdapter = new V2XRoadEventAdapter(mItemList);
|
||||
@@ -119,12 +117,6 @@ public class V2XFatigueDrivingWindow extends RelativeLayout
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// 反注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.unRegisterWakeCmd(
|
||||
V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI)
|
||||
.unRegisterUnWakeVoice(
|
||||
V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP);
|
||||
// 停止倒计时
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
|
||||
@@ -6,9 +6,9 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpButton;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpDialog;
|
||||
@@ -64,8 +64,8 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
|
||||
if (v2XMessageEntity == null) {
|
||||
return;
|
||||
}
|
||||
mV2XMessageEntity = v2XMessageEntity;
|
||||
Boolean isShow = mV2XMessageEntity.getContent();
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
Boolean isShow = getV2XMessageEntity().getContent();
|
||||
if (isShow) {
|
||||
showButton();
|
||||
mySeekHelpCountDownTimerCancel();
|
||||
@@ -108,9 +108,9 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
|
||||
Logger.d(TAG, "打开自车求助按钮!");
|
||||
// 设置Button的显示
|
||||
V2XUtils.runOnUiThread(() -> {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.setOnActionListener(this::showDialog);
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().setOnActionListener(this::showDialog);
|
||||
getV2XButton().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -120,8 +120,8 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
|
||||
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
|
||||
Logger.d(TAG, "关闭自车求助按钮!");
|
||||
V2XServiceManager.getMoGoStatusManager().setSeekHelping(TAG, false);
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
SharedPrefsMgr.getInstance(V2XUtils.getApp()).putLong(V2XConst.SEEK_HELP_TIME, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
@@ -76,59 +76,59 @@ public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity>
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
if (getV2XWindow() != null) {
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_window_height));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(mV2XWindow.getView(), layoutParams, this);
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
Logger.d(MODULE_NAME, "展示 Window 动画结束");
|
||||
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), mV2XMessageEntity.getContent());
|
||||
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), getV2XMessageEntity().getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.mogo.module.v2x.scenario.scene.livecar;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.common.entity.V2XEventShowEntity;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventWindow;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -70,55 +67,55 @@ public class V2XRoadLiveCarScenario extends AbsV2XScenario<List<V2XEventShowEnti
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (mV2XMessageEntity != null && mV2XMessageEntity.getContent() != null) {
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
showWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
if (getV2XWindow() != null) {
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addSubView(mV2XWindow.getView(), this);
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
.addSubView(getV2XWindow().getView(), this);
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadLiveCarWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadLiveCarWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ public class V2XIllegalParkScenario extends AbsV2XScenario<List<MarkerExploreWay
|
||||
@Override
|
||||
public void showWindow() {
|
||||
MarkerExploreWay markerExploreWay = null;
|
||||
if (mV2XMessageEntity.getContent() != null) {
|
||||
if (getV2XMessageEntity().getContent() != null) {
|
||||
markerExploreWay = V2XAlarmServer
|
||||
.getIllegalParkAlarmEvent(
|
||||
(ArrayList<MarkerExploreWay>) mV2XMessageEntity.getContent(),
|
||||
(ArrayList<MarkerExploreWay>) getV2XMessageEntity().getContent(),
|
||||
V2XStatusManager.getInstance().getLocation());
|
||||
}
|
||||
if (markerExploreWay != null) {
|
||||
@@ -76,7 +76,7 @@ public class V2XIllegalParkScenario extends AbsV2XScenario<List<MarkerExploreWay
|
||||
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.ALERT_ILLEGAL_PARK);
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
v2XRoadEventEntity.setTts(markerExploreWay.getAddr() + "可能被罚违章停车,您可以说,有用或没用来帮助其它车友。");
|
||||
((V2XIllegalParkWindow) mV2XWindow).show(markerExploreWay, true);
|
||||
((V2XIllegalParkWindow) getV2XWindow()).show(markerExploreWay, true);
|
||||
TrackUtils.trackV2xRoadShow(markerExploreWay.getInfoId(), V2XPoiTypeEnum.ALERT_ILLEGAL_PARK, "1");
|
||||
} else {
|
||||
v2XRoadEventEntity.setTts(markerExploreWay.getAddr() + "可能被罚违章停车");
|
||||
@@ -88,7 +88,7 @@ public class V2XIllegalParkScenario extends AbsV2XScenario<List<MarkerExploreWay
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
V2XServiceManager.getMogoTopViewManager().removeView(mV2XWindow.getView());
|
||||
V2XServiceManager.getMogoTopViewManager().removeView(getV2XWindow().getView());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,8 +101,8 @@ public class V2XIllegalParkScenario extends AbsV2XScenario<List<MarkerExploreWay
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMessageEntity != null) {
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
if (getV2XMessageEntity() != null) {
|
||||
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class V2XIllegalParkWindow extends RelativeLayout implements IV2XWindow<M
|
||||
* 初始化视图
|
||||
*/
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.window_road_event_detail, this);
|
||||
LayoutInflater.from(context).inflate(R.layout.window_fault_help, this);
|
||||
// 详情列表
|
||||
mRecyclerView = findViewById(R.id.rvRoadEventList);
|
||||
mV2XRoadEventAdapter = new V2XRoadEventAdapter(mItemList);
|
||||
|
||||
@@ -5,11 +5,11 @@ import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
@@ -62,8 +62,8 @@ public class V2XPushEventScenario extends AbsV2XScenario<V2XPushMessageEntity> i
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (mV2XMessageEntity != null && mV2XMessageEntity.getContent() != null) {
|
||||
speakTTSVoice(mV2XMessageEntity.getContent().getTts(), null);
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
speakTTSVoice(getV2XMessageEntity().getContent().getTts(), null);
|
||||
drawPOI();
|
||||
showWindow();
|
||||
}
|
||||
@@ -71,15 +71,15 @@ public class V2XPushEventScenario extends AbsV2XScenario<V2XPushMessageEntity> i
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
if (getV2XWindow() != null) {
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_window_height_ground));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(mV2XWindow.getView(), layoutParams,this);
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
@@ -87,37 +87,37 @@ public class V2XPushEventScenario extends AbsV2XScenario<V2XPushMessageEntity> i
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, false);
|
||||
}
|
||||
|
||||
@@ -78,22 +78,22 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (mV2XMessageEntity != null && mV2XMessageEntity.getContent() != null) {
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
// 设置TTS
|
||||
mV2XMessageEntity.getContent().getTts(false);
|
||||
getV2XMessageEntity().getContent().getTts(false);
|
||||
// 广播给ADAS
|
||||
ADASUtils.broadcastToADAS(
|
||||
V2XServiceManager.getContext(),
|
||||
mV2XMessageEntity.getContent());
|
||||
getV2XMessageEntity().getContent());
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
showWindow();
|
||||
}
|
||||
|
||||
// 地图主动推送/触发消息 埋点
|
||||
String poiType = mV2XMessageEntity.getContent().getPoiType();
|
||||
String lat = String.valueOf(mV2XMessageEntity.getContent().getLocation().getLat());
|
||||
String lon = String.valueOf(mV2XMessageEntity.getContent().getLocation().getLon());
|
||||
String infoId = mV2XMessageEntity.getContent().getNoveltyInfo().getInfoId();
|
||||
String poiType = getV2XMessageEntity().getContent().getPoiType();
|
||||
String lat = String.valueOf(getV2XMessageEntity().getContent().getLocation().getLat());
|
||||
String lon = String.valueOf(getV2XMessageEntity().getContent().getLocation().getLon());
|
||||
String infoId = getV2XMessageEntity().getContent().getNoveltyInfo().getInfoId();
|
||||
String style = V2XServiceManager.getMoGoStatusManager().isMainPageOnResume() ? "1" : "2";
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("dbid", infoId);
|
||||
@@ -107,7 +107,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
if (getV2XWindow() != null) {
|
||||
// 关闭直播弹窗
|
||||
try {
|
||||
IV2XWindow v2XWindow = V2XRoadLiveCarScenario.getInstance().getV2XWindow();
|
||||
@@ -122,7 +122,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
// 关闭之前的事件弹窗
|
||||
boolean isShowEventWindow = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow();
|
||||
if (isShowEventWindow) {
|
||||
((V2XRoadEventWindow) mV2XWindow).updateTopWindowInfo(mV2XMessageEntity.getContent());
|
||||
((V2XRoadEventWindow) getV2XWindow()).updateTopWindowInfo(getV2XMessageEntity().getContent());
|
||||
} else {
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
@@ -130,8 +130,8 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_window_height));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(mV2XWindow.getView(), layoutParams, this);
|
||||
mV2XWindow.show(mV2XMessageEntity.getContent());
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventWindowShow(TAG, true);
|
||||
}
|
||||
@@ -141,42 +141,42 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (mV2XWindow != null) {
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.setOnActionListener(this::showWindow);
|
||||
mV2XButton.show();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().setOnActionListener(this::showWindow);
|
||||
getV2XButton().show();
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventButtonShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
if (mV2XButton != null) {
|
||||
mV2XButton.close();
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventButtonShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
if (getV2XMarker() != null) {
|
||||
// 重置告警信息
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(mV2XMessageEntity.getContent());
|
||||
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(getV2XMessageEntity().getContent());
|
||||
getV2XMarker() .drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.module.v2x.scenario.scene.seek;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -20,7 +19,6 @@ import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
@@ -32,6 +30,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> implements IMogoTopViewStatusListener {
|
||||
|
||||
private volatile static V2XSeekHelpScenario mV2XSeekHelpScenario;
|
||||
|
||||
private V2XSeekHelpScenario() {
|
||||
@@ -42,6 +41,8 @@ public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> i
|
||||
synchronized (V2XSeekHelpScenario.class) {
|
||||
if (mV2XSeekHelpScenario == null) {
|
||||
mV2XSeekHelpScenario = new V2XSeekHelpScenario();
|
||||
mV2XSeekHelpScenario.setV2XWindow(new V2XSeekHelpWindow());
|
||||
mV2XSeekHelpScenario.setV2XMarker(new V2XSeekHelpMarker());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,21 +53,8 @@ public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> i
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<List<V2XMarkerEntity>> v2XMessageEntity) {
|
||||
mV2XMessageEntity = v2XMessageEntity;
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
if (mV2XMessageEntity != null) {
|
||||
mMarkerEntity = mV2XMessageEntity.getContent();
|
||||
}
|
||||
if (!isShown) {
|
||||
setV2XWindow(new V2XSeekHelpWindow());
|
||||
setV2XMarker(new V2XSeekHelpMarker());
|
||||
} else {
|
||||
countDownFaultHelpWindowCancel();
|
||||
closeWindow();
|
||||
clearPOI();
|
||||
}
|
||||
show();
|
||||
}
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("发现其他车主的求助信息");
|
||||
// 广播给ADAS和Launcher卡片
|
||||
V2XRoadEventEntity eventEntity = new V2XRoadEventEntity();
|
||||
@@ -74,6 +62,14 @@ public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> i
|
||||
eventEntity.setExpireTime(30000);
|
||||
eventEntity.setAlarmContent("其他车主求助");
|
||||
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), eventEntity);
|
||||
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
if (getV2XMessageEntity() != null &&
|
||||
!V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
|
||||
mMarkerEntity = getV2XMessageEntity().getContent();
|
||||
show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,90 +77,31 @@ public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> i
|
||||
showWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
countDownFaultHelpWindowCancel();
|
||||
super.close();
|
||||
mV2XWindow = null;
|
||||
mV2XMarker = null;
|
||||
mV2XButton = null;
|
||||
}
|
||||
|
||||
private volatile boolean isShown = false;
|
||||
private ArrayBlockingQueue<List<V2XMarkerEntity>> blockingQueue = new ArrayBlockingQueue<>(5);
|
||||
private CountDownTimer faultHelpTimer;
|
||||
|
||||
private void countDownFaultHelpWindowCancel() {
|
||||
if (faultHelpTimer != null) {
|
||||
faultHelpTimer.cancel();
|
||||
faultHelpTimer = null;
|
||||
}
|
||||
blockingQueue.clear();
|
||||
isShown = false;
|
||||
}
|
||||
|
||||
private void countDownFaultHelpWindowStart() {
|
||||
if (faultHelpTimer == null) {
|
||||
faultHelpTimer = new CountDownTimer(20_000, 20_000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
// Logger.d(TAG, "故障求助倒计时: " + millisUntilFinished);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Logger.d(TAG, "故障求助倒计时: onFinish");
|
||||
isShown = false;
|
||||
List<V2XMarkerEntity> result = blockingQueue.poll();
|
||||
closeWindow();
|
||||
clearPOI();
|
||||
if (result != null) {
|
||||
mMarkerEntity = result;
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
faultHelpTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setOtherSeekHelpWindowShow(TAG, true);
|
||||
if (mV2XWindow != null && mMarkerEntity != null) {
|
||||
if (!isShown) {
|
||||
isShown = true;
|
||||
countDownFaultHelpWindowStart();
|
||||
View view = mV2XWindow.getView();
|
||||
Logger.d(TAG, "添加window= " + view);
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(mV2XWindow.getView(), layoutParams, this);
|
||||
mV2XWindow.show(mMarkerEntity);
|
||||
} else {
|
||||
blockingQueue.offer(mMarkerEntity);
|
||||
}
|
||||
if (getV2XWindow() != null && mMarkerEntity != null) {
|
||||
View view = getV2XWindow().getView();
|
||||
Logger.d(MODULE_NAME, "添加window= " + view);
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(mMarkerEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
|
||||
Logger.d(TAG, "关闭求助车辆的Window!");
|
||||
Logger.d(MODULE_NAME, "关闭求助车辆的Window!");
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setOtherSeekHelpWindowShow(TAG, false);
|
||||
if (mV2XWindow != null) {
|
||||
View view = mV2XWindow.getView();
|
||||
Logger.d(TAG, "移除window= " + view);
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.removeView(view);
|
||||
mV2XWindow.close();
|
||||
if (getV2XWindow() != null) {
|
||||
View view = getV2XWindow().getView();
|
||||
Logger.d(MODULE_NAME, "移除window= " + view);
|
||||
getV2XWindow().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,21 +118,22 @@ public class V2XSeekHelpScenario extends AbsV2XScenario<List<V2XMarkerEntity>> i
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (mV2XMarker != null && mMarkerEntity != null) {
|
||||
mV2XMarker.drawPOI(mMarkerEntity);
|
||||
if (getV2XMarker() != null && mMarkerEntity != null) {
|
||||
getV2XMarker().drawPOI(mMarkerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (mV2XMarker != null) {
|
||||
mV2XMarker.clearPOI();
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().clearPOI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
Logger.d(MODULE_NAME, "展示 Window 动画结束");
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setOtherSeekHelpWindowShow(TAG, true);
|
||||
drawPOI();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.mogo.module.v2x.scenario.scene.seek;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@@ -13,54 +12,50 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.module.common.entity.V2XEventShowEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XWindowTypeEnum;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.adapter.V2XSeekHelpAdapter;
|
||||
import com.mogo.module.v2x.adapter.V2XRoadEventAdapter;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* @ProjectName: MoGoModulSafeDriving
|
||||
* @Package: com.mogo.module.v2x.window
|
||||
* @ClassName: V2XFaultHelpWindow
|
||||
* @Description: 故障求助window
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/4/13 15:24
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/4/13 15:24
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/5/15 5:37 PM
|
||||
* desc : 他人发起的故障求助
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XSeekHelpWindow extends ConstraintLayout implements V2XSeekHelpAdapter.OnViewClickListener, IMogoNaviListener, IV2XWindow<List<V2XMarkerEntity>> {
|
||||
private static final String TAG = V2XSeekHelpWindow.class.getSimpleName();
|
||||
public class V2XSeekHelpWindow extends ConstraintLayout implements IV2XWindow<List<V2XMarkerEntity>> {
|
||||
private static final String TAG = "V2XSeekHelpWindow";
|
||||
|
||||
// 展示列表
|
||||
private RecyclerView mRecyclerView;
|
||||
private int mCurPosition;
|
||||
private V2XSeekHelpAdapter mAdapter;
|
||||
IMogoRegisterCenter mMogoRegisterCenter = null;
|
||||
private V2XMarkerEntity mMarkerEntity;
|
||||
// 弹窗状态监听
|
||||
private V2XWindowStatusListener mV2XWindowStatusListener;
|
||||
// 列表数据适配器
|
||||
private V2XRoadEventAdapter mV2XRoadEventAdapter;
|
||||
// 列表展示
|
||||
private List<V2XEventShowEntity> mItemList = new ArrayList<>();
|
||||
|
||||
// 直播30秒自动关闭
|
||||
private static Handler handlerV2XEvent = new Handler();
|
||||
private static Runnable runnableV2XEvent;
|
||||
|
||||
// 推荐的停车场
|
||||
private V2XPushMessageEntity mV2XPushMessageEntity;
|
||||
|
||||
public V2XSeekHelpWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
}
|
||||
|
||||
public V2XSeekHelpWindow(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -71,197 +66,73 @@ public class V2XSeekHelpWindow extends ConstraintLayout implements V2XSeekHelpAd
|
||||
|
||||
public V2XSeekHelpWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
private void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "初始化道路故障求助窗口View。。。。。");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_fault_help, this);
|
||||
initRecyclerView(context);
|
||||
initVoice();
|
||||
mMogoRegisterCenter = V2XServiceManager.getMogoRegisterCenter();
|
||||
}
|
||||
|
||||
private void initRecyclerView(Context context) {
|
||||
mRecyclerView = findViewById(R.id.rvFaultHelp);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
|
||||
// 详情列表
|
||||
mRecyclerView = findViewById(R.id.rvRoadEventList);
|
||||
mV2XRoadEventAdapter = new V2XRoadEventAdapter(mItemList);
|
||||
mRecyclerView.setAdapter(mV2XRoadEventAdapter);
|
||||
// 设置切换样式
|
||||
new PagerSnapHelper().attachToRecyclerView(mRecyclerView);
|
||||
// 配置列表朝向
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mAdapter = new V2XSeekHelpAdapter(context);
|
||||
mAdapter.setOnViewClickListener(this);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (recyclerView.getChildCount() > 0 && newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
mCurPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
|
||||
Logger.d(TAG, "v2x 故障求助 当前显示位置===" + mCurPosition);
|
||||
if (recyclerView.getChildCount() > 0) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// 用户处于交互的时候延后隐藏时间
|
||||
countDownV2XEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new PagerSnapHelper().attachToRecyclerView(mRecyclerView);
|
||||
}
|
||||
|
||||
private V2XVoiceCallbackListener mChatCb = new V2XVoiceCallbackListener() {
|
||||
@Override
|
||||
public void onCallback(String command, Intent intent) {
|
||||
if (mMarkerEntity != null) {
|
||||
callChatting(mMarkerEntity);
|
||||
}
|
||||
}
|
||||
};
|
||||
private V2XVoiceCallbackListener mNaviCb = new V2XVoiceCallbackListener() {
|
||||
@Override
|
||||
public void onCallback(String command, Intent intent) {
|
||||
if (mMarkerEntity != null) {
|
||||
startNavi(mMarkerEntity.getLat(), mMarkerEntity.getLon());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册语音
|
||||
*/
|
||||
private void initVoice() {
|
||||
registerVoiceCmd();
|
||||
}
|
||||
|
||||
private void registerVoiceCmd() {
|
||||
V2XVoiceManager.INSTANCE.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING, mChatCb);
|
||||
V2XVoiceManager.INSTANCE.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP, mChatCb);
|
||||
V2XVoiceManager.INSTANCE.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI, mNaviCb);
|
||||
V2XVoiceManager.INSTANCE.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP, mNaviCb);
|
||||
}
|
||||
|
||||
private void unregisterVoiceCmd() {
|
||||
V2XVoiceManager.INSTANCE.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING);
|
||||
V2XVoiceManager.INSTANCE.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP);
|
||||
V2XVoiceManager.INSTANCE.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI);
|
||||
V2XVoiceManager.INSTANCE.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP);
|
||||
}
|
||||
|
||||
|
||||
private void callChatting(V2XMarkerEntity entity) {
|
||||
try {
|
||||
Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_SN, entity.getSn());
|
||||
V2XMarkerEntity.UserInfoBean infoBean = entity.getUserInfo();
|
||||
if (infoBean != null) {
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_USER_IMG, infoBean.getHeadImgUrl());
|
||||
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_USER_AGE, infoBean.getAge() + "");
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_USER_SEX, infoBean.getSex() + "");
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_NICK_NAME, infoBean.getDisplayName());
|
||||
}
|
||||
// params.put(CallChattingProviderConstant.CCPROVIDER_CAR_TYPE, );
|
||||
|
||||
//params.put(CallChattingProviderConstant.CCPROVIDER_ADDRESS, location.getAddress());
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_LAT, entity.getLat() + "");
|
||||
params.put(CallChattingProviderConstant.CCPROVIDER_LON, entity.getLon() + "");
|
||||
|
||||
|
||||
Logger.d(TAG, "调用车聊聊传入参数==$params===" + params);
|
||||
V2XServiceManager.getCarsChattingProvider().call(params);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewChatClick(V2XMarkerEntity entity) {
|
||||
Log.d(TAG, "点击:调用车聊聊通话!");
|
||||
callChatting(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewNaviClick(double lat, double lng) {
|
||||
startNavi(lat, lng);
|
||||
}
|
||||
|
||||
private void startNavi(double lat, double lng) {
|
||||
Log.d(TAG, "去导航!");
|
||||
MogoLatLng endPoint = new MogoLatLng(lat, lng);
|
||||
V2XServiceManager.getNavi().naviTo(endPoint);
|
||||
synchronized (V2XSeekHelpWindow.class) {
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(MODULE_NAME);
|
||||
mMogoRegisterCenter.registerMogoNaviListener(MODULE_NAME, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
unregisterVoiceCmd();
|
||||
mAdapter.clearData();
|
||||
mAdapter.setOnViewClickListener(null);
|
||||
synchronized (V2XSeekHelpWindow.class) {
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(MODULE_NAME);
|
||||
}
|
||||
mMarkerEntity = null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
V2XServiceManager.getNavi().startNavi(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic(MogoTraffic traffic) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void show(List<V2XMarkerEntity> entityList) {
|
||||
// TODO: 2020/4/13 根据需求仅展示一个,默认显示第一个
|
||||
if (entityList != null && !entityList.isEmpty()) {
|
||||
V2XMarkerEntity entity = entityList.get(0);
|
||||
mAdapter.addData(entityList.get(0));
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mMarkerEntity = entity;
|
||||
V2XMarkerEntity markerEntity = entityList.get(0);
|
||||
|
||||
mV2XPushMessageEntity = new V2XPushMessageEntity();
|
||||
mV2XPushMessageEntity.setLon(markerEntity.getLon());
|
||||
mV2XPushMessageEntity.setLat(markerEntity.getLat());
|
||||
mV2XPushMessageEntity.setDisplayName(markerEntity.getUserInfo().getDisplayName());
|
||||
mV2XPushMessageEntity.setHeadImgUrl(markerEntity.getUserInfo().getHeadImgUrl());
|
||||
mV2XPushMessageEntity.setSex(markerEntity.getUserInfo().getSex());
|
||||
mV2XPushMessageEntity.setSn(markerEntity.getUserInfo().getSn());
|
||||
mV2XPushMessageEntity.setCreateTime(markerEntity.getCreateTime());
|
||||
mV2XPushMessageEntity.setDistance(markerEntity.getDistance());
|
||||
mV2XPushMessageEntity.setExpireTime(20000);
|
||||
|
||||
// 清空数据
|
||||
mItemList.clear();
|
||||
|
||||
//Logger.d(MODULE_NAME, "V2X===推送消息:" + v2XRoadEventEntity);
|
||||
V2XEventShowEntity v2XEventShowEntity = new V2XEventShowEntity();
|
||||
v2XEventShowEntity.setV2XPushMessageEntity(mV2XPushMessageEntity);
|
||||
v2XEventShowEntity.setViewType(V2XWindowTypeEnum.SEEK_HELP_WINDOW);
|
||||
mItemList.add(v2XEventShowEntity);
|
||||
// 刷新列表
|
||||
mV2XRoadEventAdapter.notifyDataSetChanged();
|
||||
|
||||
countDownV2XEvent();
|
||||
}
|
||||
//mAdapter.addDataList(entityList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
/* Logger.d(TAG,"移除window= "+this);
|
||||
Logger.d(TAG, "移除window= " + this);
|
||||
//移除窗体
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.removeView(this);*/
|
||||
.getMogoTopViewManager()
|
||||
.removeView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,6 +142,26 @@ public class V2XSeekHelpWindow extends ConstraintLayout implements V2XSeekHelpAd
|
||||
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
mV2XWindowStatusListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 窗体倒计时
|
||||
*/
|
||||
public void countDownV2XEvent() {
|
||||
if (mV2XPushMessageEntity != null) {
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
|
||||
// 移出Window详细信息
|
||||
close();
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
}
|
||||
int expireTime = mV2XPushMessageEntity.getExpireTime();
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 展示开始倒计时:" + expireTime);
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, expireTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/rvFaultHelp"
|
||||
android:id="@+id/rvRoadEventList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/module_v2x_fatigue_driving_window_height_ground"
|
||||
android:orientation="vertical"
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
"zoom": true,
|
||||
"zoomScale": 15,
|
||||
"location": {
|
||||
"lat": 39.951326,
|
||||
"lon": 116.343487
|
||||
"lat": 39.968678,
|
||||
"lon": 116.405467
|
||||
},
|
||||
"lat": 39.951326,
|
||||
"lon": 116.343487,
|
||||
"lat": 39.968678,
|
||||
"lon": 116.405467,
|
||||
"userHead": "https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/5.png",
|
||||
"msgImgUrl": "https://upload.jianshu.io/users/upload_avatars/7663825/7c28763e-002b-4e89-8dea-5b8da210ef2c.jpg"
|
||||
}
|
||||
Reference in New Issue
Block a user