完成了疲劳驾驶的展示移植
This commit is contained in:
@@ -140,12 +140,12 @@ public class V2XModuleProvider implements
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// // TODO 这是测试页面
|
||||
// V2XServiceManager
|
||||
// .getIMogoWindowManager()
|
||||
// .addView(new V2XTestConsoleWindow(context), 0, 0, false);
|
||||
// }
|
||||
if (BuildConfig.DEBUG) {
|
||||
// TODO 这是测试页面
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.addView(new V2XTestConsoleWindow(context), 0, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void initVoice(Context context) {
|
||||
|
||||
@@ -75,6 +75,9 @@ public class V2XRoadEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
if (holder instanceof V2XPushEventDetailVH) {
|
||||
((V2XPushEventDetailVH) holder).initView(itemList.get(position));
|
||||
}
|
||||
if (holder instanceof V2XFatigueDrivingDetailVH) {
|
||||
((V2XFatigueDrivingDetailVH) holder).initView(itemList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.mogo.module.v2x.utils.RoadConditionUtils;
|
||||
import com.mogo.module.v2x.utils.TrackUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
@@ -132,13 +133,13 @@ public abstract class V2XBaseViewHolder
|
||||
*/
|
||||
public void triggerStartNavi(MarkerExploreWay noveltyInfo) {
|
||||
try {
|
||||
V2XServiceManager.getMogoRegisterCenter().registerMogoNaviListener(MODULE_NAME, this);
|
||||
|
||||
MogoLatLng endPoint = new MogoLatLng(
|
||||
noveltyInfo.getLocation().getLat(),
|
||||
noveltyInfo.getLocation().getLon());
|
||||
|
||||
V2XServiceManager.getNavi().naviTo(endPoint);
|
||||
V2XServiceManager.getMogoRegisterCenter().unregisterMogoNaviListener(MODULE_NAME);
|
||||
V2XServiceManager.getMogoRegisterCenter().registerMogoNaviListener(MODULE_NAME, this);
|
||||
|
||||
TrackUtils.trackV2xRoadEvent(
|
||||
noveltyInfo.getInfoId(),
|
||||
@@ -187,7 +188,9 @@ public abstract class V2XBaseViewHolder
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
Logger.w("V2XBaseViewHolder", "onCalculateSuccess");
|
||||
V2XServiceManager.getNavi().startNavi(true);
|
||||
V2XServiceManager.getMogoRegisterCenter().unregisterMogoNaviListener(MODULE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
package com.mogo.module.v2x.adapter.holder;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
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.v2x.R;
|
||||
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
|
||||
import com.mogo.module.v2x.utils.SpanUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
|
||||
/**
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -21,14 +30,67 @@ public class V2XFatigueDrivingDetailVH extends V2XBaseViewHolder {
|
||||
|
||||
private TextView mTvAddress, mTvAddressDistance;
|
||||
private ImageView mIvToNav;
|
||||
private MarkerExploreWay mNoveltyInfo;
|
||||
private V2XPushMessageEntity mV2XPushMessageEntity;
|
||||
|
||||
// 语音控制导航
|
||||
private V2XVoiceCallbackListener mNaviCb = (command, intent) -> triggerStartNavi(mNoveltyInfo);
|
||||
|
||||
public V2XFatigueDrivingDetailVH(ViewGroup viewGroup) {
|
||||
super(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.window_fatigue_driving, viewGroup, false));
|
||||
mTvAddress = itemView.findViewById(R.id.tvAddress);
|
||||
mTvAddressDistance = itemView.findViewById(R.id.tvAddressDistance);
|
||||
mIvToNav = itemView.findViewById(R.id.ivToNav);
|
||||
mIvToNav.setOnClickListener(v -> triggerStartNavi(mNoveltyInfo));
|
||||
|
||||
// 设置视图状态监听
|
||||
itemView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View v) {
|
||||
//Logger.w(MODULE_NAME, "列表View V2XPushEventDetailVH 触发 onViewAttachedToWindow");
|
||||
// 注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI,
|
||||
mNaviCb)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP,
|
||||
mNaviCb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View v) {
|
||||
//Logger.w(MODULE_NAME, "列表View V2XPushEventDetailVH 触发 onViewDetachedFromWindow");
|
||||
// 反注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_NAVI)
|
||||
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_NAVI_UN_WAKEUP);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initView(V2XEventShowEntity v2XEventShowEntity) {
|
||||
mV2XPushMessageEntity = v2XEventShowEntity.getV2XPushMessageEntity();
|
||||
try {
|
||||
MarkerLocation markerLocation = new MarkerLocation();
|
||||
markerLocation.setLon(mV2XPushMessageEntity.getLon());
|
||||
markerLocation.setLat(mV2XPushMessageEntity.getLat());
|
||||
mNoveltyInfo = new MarkerExploreWay();
|
||||
mNoveltyInfo.setLocation(markerLocation);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mV2XPushMessageEntity.getAddress())) {
|
||||
mTvAddress.setText(mV2XPushMessageEntity.getAddress());
|
||||
} else {
|
||||
mTvAddress.setText("");
|
||||
}
|
||||
SpanUtils.with(mTvAddressDistance)
|
||||
.append("" + (int) mV2XPushMessageEntity.getDistance())
|
||||
.setFontSize((int) itemView.getResources().getDimension(R.dimen.dp_80))
|
||||
.append("M")
|
||||
.setFontSize((int) itemView.getResources().getDimension(R.dimen.dp_30))
|
||||
.create();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +98,7 @@ public class V2XFatigueDrivingDetailVH extends V2XBaseViewHolder {
|
||||
*/
|
||||
@Override
|
||||
public void delayedCloseWindow() {
|
||||
itemView.postDelayed(() -> V2XPushEventScenario.getInstance().close(), 1000);
|
||||
itemView.postDelayed(() -> V2XFatigueDrivingScenario.getInstance().close(), 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,28 +2,31 @@ package com.mogo.module.v2x.scenario.scene.fatigue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
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.V2XRoadEventAdapter;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.module.v2x.utils.SpanUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
@@ -34,10 +37,13 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XFatigueDrivingWindow extends RelativeLayout
|
||||
implements IV2XWindow<V2XPushMessageEntity>, IMogoNaviListener {
|
||||
|
||||
private TextView mTvAddress, mTvAddressDistance;
|
||||
private ImageView mIvToNav;
|
||||
implements IV2XWindow<V2XPushMessageEntity> {
|
||||
// 展示列表
|
||||
private RecyclerView mRecyclerView;
|
||||
// 列表数据适配器
|
||||
private V2XRoadEventAdapter mV2XRoadEventAdapter;
|
||||
// 列表展示
|
||||
private List<V2XEventShowEntity> mItemList = new ArrayList<>();
|
||||
|
||||
// 直播30秒自动关闭
|
||||
private static Handler handlerV2XEvent = new Handler();
|
||||
@@ -65,44 +71,49 @@ public class V2XFatigueDrivingWindow extends RelativeLayout
|
||||
|
||||
public void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "V2X-初始化疲劳驾驶");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_fatigue_driving, this);
|
||||
mTvAddress = findViewById(R.id.tvAddress);
|
||||
mTvAddressDistance = findViewById(R.id.tvAddressDistance);
|
||||
mIvToNav = findViewById(R.id.ivToNav);
|
||||
V2XServiceManager.getMogoRegisterCenter().registerMogoNaviListener( "test", this );
|
||||
mIvToNav.setOnClickListener(v -> startNavi());
|
||||
LayoutInflater.from(context).inflate(R.layout.window_road_event_detail, this);
|
||||
// 详情列表
|
||||
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);
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (recyclerView.getChildCount() > 0) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// 用户处于交互的时候延后隐藏时间
|
||||
countDownV2XEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航规划路线
|
||||
*/
|
||||
private void startNavi() {
|
||||
if (mV2XPushMessageEntity != null) {
|
||||
MogoLatLng endPoint = new MogoLatLng(mV2XPushMessageEntity.getLat(), mV2XPushMessageEntity.getLon());
|
||||
V2XServiceManager.getNavi().naviTo(endPoint);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示道路事件详情Windows
|
||||
*/
|
||||
@Override
|
||||
public void show(V2XPushMessageEntity entity) {
|
||||
mV2XPushMessageEntity = entity;
|
||||
if (entity != null) {
|
||||
if (!TextUtils.isEmpty(entity.getAddress())) {
|
||||
mTvAddress.setText(entity.getAddress());
|
||||
} else {
|
||||
mTvAddress.setText("");
|
||||
}
|
||||
SpanUtils.with(mTvAddressDistance)
|
||||
.append("" + (int) entity.getDistance())
|
||||
.setFontSize((int) getResources().getDimension(R.dimen.dp_80))
|
||||
.append("M")
|
||||
.setFontSize((int) getResources().getDimension(R.dimen.dp_30))
|
||||
.create();
|
||||
countDownV2XEvent(entity);
|
||||
mV2XPushMessageEntity = entity;
|
||||
// 清空数据
|
||||
mItemList.clear();
|
||||
//Logger.d(MODULE_NAME, "V2X===推送消息:" + v2XRoadEventEntity);
|
||||
V2XEventShowEntity v2XEventShowEntity = new V2XEventShowEntity();
|
||||
v2XEventShowEntity.setV2XPushMessageEntity(mV2XPushMessageEntity);
|
||||
v2XEventShowEntity.setViewType(V2XWindowTypeEnum.FATIGUE_DRIVING_WINDOW);
|
||||
mItemList.add(v2XEventShowEntity);
|
||||
// 刷新列表
|
||||
mV2XRoadEventAdapter.notifyDataSetChanged();
|
||||
|
||||
countDownV2XEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,60 +149,21 @@ public class V2XFatigueDrivingWindow extends RelativeLayout
|
||||
/**
|
||||
* 窗体倒计时
|
||||
*/
|
||||
public void countDownV2XEvent(V2XPushMessageEntity v2XPushMessageEntity) {
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
|
||||
// 移出Window详细信息
|
||||
close();
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
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);
|
||||
}
|
||||
int expireTime = v2XPushMessageEntity.getExpireTime();
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 展示开始倒计时:" + expireTime);
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, expireTime);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
V2XServiceManager.getNavi().startNavi(true);
|
||||
}
|
||||
|
||||
@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 onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic(MogoTraffic traffic) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user