merge of gradle.pro

This commit is contained in:
unknown
2020-07-17 18:52:51 +08:00
465 changed files with 26116 additions and 248 deletions

View File

@@ -0,0 +1 @@
# 应用列表 + Launcher 模式下的左侧导航按钮

View File

@@ -4,15 +4,11 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import com.mogo.module.apps.model.AppEnum;
import com.mogo.module.apps.model.AppEnumHelper;
import com.mogo.module.common.utils.CarSeries;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author congtaowang

View File

@@ -10,12 +10,14 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.apps.adapter.AppIndicatorAdapter;
import com.mogo.module.apps.anim.AnimWrapper;
import com.mogo.module.apps.applaunch.AppLauncher;
import com.mogo.module.apps.applaunch.BaseAppLauncher;
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
import com.mogo.module.apps.model.AppEnum;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.model.NavigatorApps;
import com.mogo.module.apps.view.OnAiAssistClickListener;
@@ -128,7 +130,15 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
properties.put( "appname", appLabel );
}
if ( !TextUtils.equals( "全部应用", app.getName() ) ) {
properties.put( "appversion", CommonUtils.getVersionName( getContext(), app.getPackageName() ) );
if ( TextUtils.equals( "com.zhidao.music", app.getPackageName() ) ) {
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.KwMusic.getPkg() ) ) {
properties.put( "appversion", CommonUtils.getVersionName( getContext(), AppEnum.KwMusic.getPkg() ) );
} else if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.QQMusic.getPkg() ) ) {
properties.put( "appversion", CommonUtils.getVersionName( getContext(), AppEnum.QQMusic.getPkg() ) );
}
} else {
properties.put( "appversion", CommonUtils.getVersionName( getContext(), app.getPackageName() ) );
}
} else {
properties.put( "appversion", CommonUtils.getVersionName( getContext() ) );
}

View File

@@ -14,5 +14,7 @@ public interface AppLaunchFilter {
void launch( Context context, AppInfo appInfo );
void launch( Context context, String pkg );
void destroy();
}

View File

@@ -21,15 +21,7 @@ public class AppLauncher extends BaseAppLauncher {
@Override
public void launch( Context context, AppInfo appInfo ) {
try {
if ( LaunchUtils.getLaunchIntentForPackage( context, appInfo.getPackageName() ) != null ) {
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
}
LaunchUtils.launchByPkg( context, appInfo.getPackageName() );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
TipToast.shortTip( R.string.module_apps_str_no_app );
}
launch( context, appInfo.getPackageName() );
}
@Override

View File

@@ -1,5 +1,13 @@
package com.mogo.module.apps.applaunch;
import android.content.Context;
import com.mogo.module.apps.AppServiceHandler;
import com.mogo.module.apps.R;
import com.mogo.utils.LaunchUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
* @since 2020-02-09
@@ -8,6 +16,8 @@ package com.mogo.module.apps.applaunch;
*/
public abstract class BaseAppLauncher implements AppLaunchFilter {
private static final String TAG = "BaseAppLauncher";
private AppLaunchFilter mNext;
public AppLaunchFilter getNext() {
@@ -17,4 +27,17 @@ public abstract class BaseAppLauncher implements AppLaunchFilter {
public void setNext( AppLaunchFilter next ) {
this.mNext = next;
}
@Override
public void launch( Context context, String pkg ) {
try {
if ( LaunchUtils.getLaunchIntentForPackage( context, pkg ) != null ) {
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
}
LaunchUtils.launchByPkg( context, pkg );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
TipToast.shortTip( R.string.module_apps_str_no_app );
}
}
}

View File

@@ -5,12 +5,17 @@ import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.apps.AppServiceHandler;
import com.mogo.module.apps.AppsListActivity;
import com.mogo.module.apps.R;
import com.mogo.module.apps.model.AppEnum;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.utils.AppUtils;
import com.mogo.utils.LaunchUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
@@ -32,7 +37,7 @@ public class InternalFunctionLauncher extends BaseAppLauncher {
case "com.autonavi.amapauto":
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
try {
LaunchUtils.launchByPkg( context, "com.autonavi.amapauto" );
launch( context, AppEnum.AUTO_NAVI.getPkg() );
} catch ( Exception e ) {
e.printStackTrace();
}
@@ -50,6 +55,23 @@ public class InternalFunctionLauncher extends BaseAppLauncher {
startActivity( context, appInfo, "com.zhidao.bluetooth.ui.MainActivity" );
}
break;
case "com.zhidao.music":
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.KwMusic.getPkg() ) ) {
try {
launch( context, AppEnum.KwMusic.getPkg() );
} catch ( Exception e ) {
e.printStackTrace();
}
} else if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.QQMusic.getPkg() ) ) {
try {
launch( context, AppEnum.QQMusic.getPkg() );
} catch ( Exception e ) {
e.printStackTrace();
}
} else {
TipToast.shortTip( R.string.module_apps_str_no_app );
}
break;
default:
if ( getNext() != null ) {
getNext().launch( context, appInfo );

View File

@@ -16,7 +16,7 @@ public class NavigatorApps {
private static AppInfo app = new AppInfo( "高德地图", "com.autonavi.amapauto", "", 0, null, R.drawable.module_apps_ic_navigator_navi, 1 );
private static AppInfo app_ = new AppInfo( "高德地图", "com.autonavi.amapauto", "", 0, null, R.drawable.module_apps_ic_navigator_navi_disable, 1 );
// private static AppInfo app2 = new AppInfo( "音乐", "com.tencent.wecarflow", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
private static AppInfo app2 = new AppInfo( "酷我音乐", "cn.kuwo.kwmusiccar", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
private static AppInfo app2 = new AppInfo( "音乐", "com.zhidao.music", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
private static AppInfo app3 = new AppInfo( "车聊聊", "com.zhidao.imdemo", "", 0, null, R.drawable.module_apps_ic_navigator_im, 6 );
private static AppInfo app4 = new AppInfo( "全部应用", "com.mogo.launcher.applist", "", 0, null, R.drawable.module_apps_ic_navigator_applist, 4 );

View File

@@ -18,6 +18,9 @@
<item>com.iflytek.inputmethod.pad</item>
<item>com.nwd.tools.reboot</item>
<item>com.android.car.setting</item>
<item>com.zhidao.bootmanager</item>
<item>com.zhidao.services</item>
<item>com.android.settings</item>
</string-array>
<string-array name="module_apps_array_filter_packages">
<item>com.mogo.launcher</item>

View File

@@ -0,0 +1 @@
# Launcher 模式下分体机F系列的返回桌面悬浮按钮 和 "返回桌面"语音指令

View File

@@ -0,0 +1,11 @@
# 基础框架
## 基于 WindowManger.addView 方式实现的弹窗
## 大而全数据定义
## 地图中心点控制策略
## 自研车机类型判断
## 模块加载类

View File

@@ -1,9 +1,9 @@
# launcher头部模块
## 小智语音
## 通知
## 天气
## 时间
## 时间
## 入口按钮高德SDK导航控制

View File

@@ -6,6 +6,7 @@ import android.transition.AutoTransition;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.util.ArrayMap;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
@@ -394,6 +395,11 @@ public class TopViewAnimHelper {
constraintSet.connect(naviBg.getId(), ConstraintSet.TOP,
R.id.module_entrance_id_top_motion_layout, ConstraintSet.TOP,
computeNaviMarginTop(params.height));
// 动态改变相关字体大小
tvNextDistance.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_textSize_small));
tvNextDistanceUnit.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_unit_textSize_small));
}
constraintSet.applyTo(topMotionLayout);
ivTurnIcon.getLayoutParams().height =
@@ -487,6 +493,9 @@ public class TopViewAnimHelper {
remainDistanceGroup.setVisibility(View.VISIBLE);
remainTimeGroup.setVisibility(View.VISIBLE);
arriveTimeGroup.setVisibility(View.VISIBLE);
tvNextDistance.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_textSize));
tvNextDistanceUnit.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_unit_textSize));
}
constraintSet.clone(topMotionLayout);
@@ -547,6 +556,9 @@ public class TopViewAnimHelper {
remainDistanceGroup.setVisibility(View.VISIBLE);
remainTimeGroup.setVisibility(View.VISIBLE);
arriveTimeGroup.setVisibility(View.VISIBLE);
tvNextDistance.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_textSize));
tvNextDistanceUnit.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_unit_textSize));
// 调整约束
constraintSet.clone(topMotionLayout);
constraintSet.clear(tvNextDistance.getId(), ConstraintSet.BOTTOM);
@@ -576,6 +588,8 @@ public class TopViewAnimHelper {
remainDistanceGroup.setVisibility(View.GONE);
remainTimeGroup.setVisibility(View.GONE);
arriveTimeGroup.setVisibility(View.GONE);
tvNextDistance.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_textSize_small));
tvNextDistanceUnit.setTextSize(TypedValue.COMPLEX_UNIT_PX,getDimen(R.dimen.module_ext_navi_info_panel_next_info_distance_unit_textSize_small));
// 调整约束
constraintSet.clone(topMotionLayout);
constraintSet.connect(tvNextDistance.getId(), ConstraintSet.BOTTOM,
@@ -655,7 +669,7 @@ public class TopViewAnimHelper {
}
private float getDimen(int resId) {
return (int) topMotionLayout.getContext().getResources().getDimension(resId);
return (int) topMotionLayout.getContext().getResources().getDimensionPixelSize(resId);
}
private int computeNaviMarginTop(int height) {

View File

@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<View
android:id="@+id/module_map_id_navi_bg"
android:layout_width="match_parent"
android:layout_height="@dimen/module_ext_navi_info_panel_height"
android:background="@drawable/module_ext_dw_navi_info_panel_bkg"
android:focusable="true"
android:clickable="true"
android:focusable="true"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintLeft_toLeftOf="@id/module_entrance_id_top_container"
app:layout_constraintRight_toRightOf="@id/module_entrance_id_top_container"
@@ -88,17 +89,17 @@
android:id="@+id/module_map_id_remaining_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_657"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_navi_bg"
android:layout_marginStart="@dimen/dp_627"
android:text="3599"
android:textColor="#F1F1F1"
android:textSize="@dimen/module_ext_remaining_distance_textSize"
android:textStyle="bold"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintBottom_toTopOf="@+id/module_map_id_remaining_distance_notice"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_navi_bg"
app:layout_constraintRight_toLeftOf="@+id/module_map_id_remaining_time"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_bg"
app:layout_constraintVertical_chainStyle="packed"/>
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/module_map_id_remaining_distance_unit"
@@ -114,12 +115,13 @@
android:id="@+id/module_map_id_remaining_distance_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintTop_toTopOf="@+id/module_map_id_remaining_distance_notice"
android:src="@drawable/module_ext_ic_navi_info1"
app:layout_constraintBottom_toBottomOf="@+id/module_map_id_remaining_distance_notice"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_remaining_distance"
app:layout_constraintRight_toLeftOf="@+id/module_map_id_remaining_distance_notice"
android:src="@drawable/module_ext_ic_navi_info1" />
app:layout_constraintTop_toTopOf="@+id/module_map_id_remaining_distance_notice" />
<TextView
android:id="@+id/module_map_id_remaining_distance_notice"
android:layout_width="wrap_content"
@@ -128,8 +130,8 @@
android:textColor="#7FFFFFFF"
android:textSize="@dimen/module_ext_remaining_distance_unit_textSize"
app:layout_constraintBottom_toBottomOf="@+id/module_map_id_navi_bg"
app:layout_constraintRight_toRightOf="@+id/module_map_id_remaining_distance_unit"
app:layout_constraintLeft_toRightOf="@id/module_map_id_remaining_distance_icon"
app:layout_constraintRight_toRightOf="@+id/module_map_id_remaining_distance_unit"
app:layout_constraintTop_toBottomOf="@id/module_map_id_remaining_distance" />
<androidx.constraintlayout.widget.Group
@@ -146,11 +148,11 @@
android:textColor="#F1F1F1"
android:textSize="@dimen/module_ext_remaining_time_textSize"
android:textStyle="bold"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_bg"
app:layout_constraintRight_toLeftOf="@+id/module_map_id_arrive_time"
app:layout_constraintBottom_toTopOf="@id/module_map_id_remaining_time_notice"
app:layout_constraintLeft_toRightOf="@+id/module_map_id_remaining_distance"
app:layout_constraintBottom_toTopOf="@id/module_map_id_remaining_time_notice" />
app:layout_constraintRight_toLeftOf="@+id/module_map_id_arrive_time"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_bg"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/module_map_id_remaining_time_unit"
@@ -161,17 +163,18 @@
android:textSize="@dimen/module_ext_remaining_time_unit_textSize"
app:layout_constraintBaseline_toBaselineOf="@id/module_map_id_remaining_time"
app:layout_constraintLeft_toRightOf="@id/module_map_id_remaining_time" />
<ImageView
android:id="@+id/module_map_id_remaining_time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_ext_ic_navi_info2"
app:layout_constraintBottom_toBottomOf="@id/module_map_id_remaining_time_notice"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_remaining_time"
app:layout_constraintRight_toLeftOf="@id/module_map_id_remaining_time_notice"
app:layout_constraintTop_toTopOf="@id/module_map_id_remaining_time_notice"
app:layout_constraintBottom_toBottomOf="@id/module_map_id_remaining_time_notice"
/>
app:layout_constraintTop_toTopOf="@id/module_map_id_remaining_time_notice" />
<TextView
android:id="@+id/module_map_id_remaining_time_notice"
android:layout_width="wrap_content"
@@ -195,26 +198,28 @@
android:id="@+id/module_map_id_arrive_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_76"
android:text="3599"
android:textColor="#F1F1F1"
android:textSize="@dimen/module_ext_arrive_time_textSize"
android:layout_marginEnd="@dimen/dp_96"
android:textStyle="bold"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_bg"
app:layout_constraintRight_toRightOf="@id/module_map_id_navi_bg"
app:layout_constraintBottom_toTopOf="@id/module_map_id_arrive_time_notice"
app:layout_constraintLeft_toRightOf="@+id/module_map_id_remaining_time"
app:layout_constraintBottom_toTopOf="@id/module_map_id_arrive_time_notice"/>
app:layout_constraintRight_toRightOf="@id/module_map_id_navi_bg"
app:layout_constraintTop_toTopOf="@id/module_map_id_navi_bg"
app:layout_constraintVertical_chainStyle="packed" />
<ImageView
android:id="@+id/module_map_id_arrive_time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_arrive_time"
app:layout_constraintTop_toTopOf="@+id/module_map_id_arrive_time_notice"
android:src="@drawable/module_ext_ic_navi_info3"
app:layout_constraintBottom_toBottomOf="@+id/module_map_id_arrive_time_notice"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="@id/module_map_id_arrive_time"
app:layout_constraintRight_toLeftOf="@+id/module_map_id_arrive_time_notice"
android:src="@drawable/module_ext_ic_navi_info3" />
app:layout_constraintTop_toTopOf="@+id/module_map_id_arrive_time_notice" />
<TextView
android:id="@+id/module_map_id_arrive_time_notice"
android:layout_width="wrap_content"
@@ -222,8 +227,8 @@
android:text="到达"
android:textColor="#7FFFFFFF"
android:textSize="@dimen/module_ext_remaining_distance_unit_textSize"
app:layout_constraintBottom_toBottomOf="@+id/module_map_id_navi_bg"
app:layout_constraintLeft_toRightOf="@id/module_map_id_arrive_time_icon"
app:layout_constraintRight_toRightOf="@id/module_map_id_arrive_time"
app:layout_constraintBottom_toBottomOf="@+id/module_map_id_navi_bg"
app:layout_constraintTop_toBottomOf="@id/module_map_id_arrive_time" />
</merge>

View File

@@ -89,9 +89,11 @@
<dimen name="module_ext_navi_info_panel_turn_icon_marginTop">24px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_marginTop">40px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize">60px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize_small">50px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginLeft">12px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginBottom">10px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize">40px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize_small">30px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_road_textSize">34px</dimen>
<dimen name="module_ext_navi_info_panel__arrive_destination_estimate_info_marginTop">24px</dimen>
<dimen name="module_ext_navi_info_panel__arrive_destination_estimate_info_textSize">28px</dimen>

View File

@@ -89,9 +89,11 @@
<dimen name="module_ext_navi_info_panel_turn_icon_marginTop">24px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_marginTop">40px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize">60px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize_small">50px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginLeft">12px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginBottom">10px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize">40px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize_small">30px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_road_textSize">34px</dimen>
<dimen name="module_ext_navi_info_panel__arrive_destination_estimate_info_marginTop">24px</dimen>
<dimen name="module_ext_navi_info_panel__arrive_destination_estimate_info_textSize">28px</dimen>

View File

@@ -91,9 +91,11 @@
<dimen name="module_ext_navi_info_panel_turn_icon_marginTop">13px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_marginTop">20px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize">32px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_textSize_small">32px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginLeft">7px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_marginBottom">5px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize">22px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_distance_unit_textSize_small">22px</dimen>
<dimen name="module_ext_navi_info_panel_next_info_road_textSize">18px</dimen>
<dimen name="module_ext_navi_info_panel__arrive_destination_estimate_info_marginTop">24px
</dimen>

View File

@@ -0,0 +1 @@
# GPS 轨迹模拟接口 Debug 实现

View File

@@ -0,0 +1 @@
# GPS 轨迹模拟接口 Release 实现

View File

@@ -0,0 +1,5 @@
# GPS 轨迹模拟接口抽象
## 常量定义
## 接口

View File

@@ -0,0 +1,18 @@
# 主模块
## 子模块加载管理
## 加载地图
## 事件分发
## service 后台服务
开启定位、加载基础服务模块v2x、刷新策略、事件上报模块、初始化 ADAS 服务
## 应用内浮窗管理:车聊聊、音乐等
## 顶部弹窗管理
## scheme 跳转管理

View File

@@ -52,7 +52,6 @@ dependencies {
api rootProject.ext.dependencies.mogoservice
api rootProject.ext.dependencies.moduleservice
api rootProject.ext.dependencies.moduleapps
api rootProject.ext.dependencies.mogoconnection
api rootProject.ext.dependencies.moduleextensions
api rootProject.ext.dependencies.mogomoduleback
} else {
@@ -64,7 +63,6 @@ dependencies {
api project(':services:mogo-service-api')
api project(':services:mogo-service')
api project(':modules:mogo-module-apps')
api project(':foudations:mogo-connection')
api project(':modules:mogo-module-extensions')
api project(':modules:mogo-module-back')
}

View File

@@ -43,12 +43,10 @@
<!--快捷操作浮层-->
<FrameLayout
android:id="@+id/module_main_id_entrance_fragment_container"
android:layout_width="@dimen/module_main_entrance_fragment_container_width"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:paddingRight="@dimen/module_main_entrance_fragment_container_padding"
android:paddingBottom="@dimen/module_main_entrance_fragment_container_padding"
android:paddingTop="@dimen/module_main_entrance_fragment_container_padding" />
android:layout_marginLeft="@dimen/module_main_id_entrance_fragment_container_marginLeft"
android:padding="@dimen/module_main_entrance_fragment_container_padding" />
<FrameLayout
android:id="@+id/module_main_id_event_panel_fragment_container"

View File

@@ -0,0 +1,8 @@
# 地图模块
## 地图 Fragment
## 地图状态和小智交互部分
## 语音控制地图

View File

@@ -0,0 +1,16 @@
# 地图导航搜索模块
## poi 搜索
## 导航设置
## 路径规划
## 家和公司设置
## 地图选点
## 存储家和公司地址
## 分类搜索

View File

@@ -0,0 +1,10 @@
# 刷新策略 + 地图事件点刷新
## 刷新策略:自动刷新、手动刷新、刷新接口
## 大而全数据:道路事件
## 在线车辆数据
## 大部分广播的接口小智语音广播、acc 状态

View File

@@ -15,6 +15,9 @@ import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.search.geo.IMogoGeoSearchListener;
import com.mogo.map.search.geo.MogoGeocodeResult;
@@ -154,6 +157,49 @@ public class MockIntentHandler implements IntentHandler {
case 13: {
double lat = intent.getFloatExtra( "lat", 0.0f );
double lon = intent.getFloatExtra( "lon", 0.0f );
boolean real = intent.getBooleanExtra( "real", false );
MarkerServiceHandler.getRegisterCenter().registerMogoNaviListener( TAG, new IMogoNaviListener() {
@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() {
MarkerServiceHandler.getRegisterCenter().unregisterMogoNaviListener( TAG );
MarkerServiceHandler.getNavi().startNavi( real );
}
@Override
public void onoCalculateFailed() {
}
@Override
public void onUpdateTraffic( MogoTraffic traffic ) {
}
} );
MarkerServiceHandler.getNavi().naviTo( new MogoLatLng( lat, lon ) );
}
case 14: {

View File

@@ -96,6 +96,8 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
mContent = mInfoWindowView.findViewById( R.id.module_service_id_content );
mTag = mInfoWindowView.findViewById( R.id.module_service_id_tag );
mCall = mInfoWindowView.findViewById( R.id.module_service_id_call );
mCall.setVisibility( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ? View.GONE : View.VISIBLE );
}
try {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#000" />
<size
android:width="@dimen/dp_100"
android:height="@dimen/dp_100" />
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient android:startColor="#256BFF" android:endColor="#5CC1FF" android:angle="45" />
<corners android:radius="@dimen/dp_46" />
<padding android:bottom="@dimen/dp_12" android:left="@dimen/dp_75" android:top="@dimen/dp_12" android:right="@dimen/dp_75" />
</shape>
</item>
</selector>

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -2,32 +2,37 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/module_byd_splash" />
<TextView
android:id="@+id/tvByd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#fff"
android:drawableTop="@drawable/binli"
android:drawablePadding="10dp"
android:gravity="center"
android:text="比亚迪"
android:textSize="40sp"
android:background="@drawable/byd_enter_btn_bg"
android:textColor="#0D172C"
android:text="开启行程"
android:textSize="@dimen/dp_48"
android:layout_marginStart="@dimen/dp_182"
android:layout_marginBottom="@dimen/dp_251"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="parent"/>
<TextView
android:id="@+id/tvCountDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="5"
android:textColor="#000"
android:textSize="30sp"
android:gravity="center"
android:textColor="#fff"
android:textSize="@dimen/dp_54"
android:layout_marginTop="@dimen/dp_48"
android:layout_marginEnd="@dimen/dp_60"
android:background="@drawable/byd_count_down_bg"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

1
modules/mogo-module-v2x/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,25 @@
#### 项目介绍
本项目是V2X模块必须依附于Launcher进行集成使用无法单独使用且需要车机安装AutopilotADAS一起使用。
#### 项目结构
- adapter --- 展示视图适配
- alarm --- 提醒计算
- entity --- 数据实体
- listener --- Socket监听
- manager --- 管理工具绘制marker绘制连接线记录状态
- marker --- 地图marker视图适配
- network --- 网络请求
- scenario --- 场景,可以简单的理解为每一种弹窗是一种场景
- scene
- animation --- 场景动画 H5 推送下来的
- fatigue --- 疲劳驾驶
- help --- 自车故障求助
- livecar --- 直播场景H5推送的和道路事件预警的
- park --- 违章停车
- push --- 推送的演示场景,取快递、政府公告、顺风车、行人点赞
- road --- 道路事件预警
- seek --- 他人故障求助预警
- test --- 测试页面,一堆按钮,自己点击触发以上场景
- utils --- 工具类
- view --- 自定义视图
- voice --- 语音注册

View File

@@ -0,0 +1,74 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.tencent.liteavsdk:LiteAVSDK_Smart:7.2.8927'
implementation 'ch.hsr:geohash:1.4.0'
implementation rootProject.ext.dependencies.flexbox
implementation "com.zhidao.auto.lib:sqlite:0.1.1"
compileOnly rootProject.ext.dependencies.kotlinstdlibjdk7
compileOnly rootProject.ext.dependencies.androidxccorektx
compileOnly rootProject.ext.dependencies.androidxrecyclerview
compileOnly rootProject.ext.dependencies.mogomap
compileOnly rootProject.ext.dependencies.mogoutils
compileOnly rootProject.ext.dependencies.mogocommons
compileOnly rootProject.ext.dependencies.mogoservice
compileOnly rootProject.ext.dependencies.mogoserviceapi
compileOnly rootProject.ext.dependencies.modulecommon
compileOnly rootProject.ext.dependencies.moduleservice
compileOnly rootProject.ext.dependencies.androidxappcompat
compileOnly rootProject.ext.dependencies.androidxconstraintlayout
compileOnly rootProject.ext.dependencies.arouter
compileOnly rootProject.ext.dependencies.carcallprovider
compileOnly rootProject.ext.dependencies.carcall
annotationProcessor rootProject.ext.dependencies.aroutercompiler
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,2 @@
-keep class com.tencent.** { *; }
-keep com.mogo.module.v2x.entity.** { *; }

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-v2x
VERSION_CODE=1

View File

@@ -0,0 +1,23 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.tencent.* { *; }
-keep class com.mogo.module.v2x.entity.* { *; }

View File

@@ -0,0 +1,26 @@
package com.mogo.module.blackbox;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.mogo.module.blackbox.test", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.v2x">
<application>
<receiver android:name=".receiver.SceneBroadcastReceiver">
<intent-filter>
<action android:name="com.v2x.scene_handler_broadcast" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -0,0 +1,34 @@
package com.mogo.module.v2x;
import androidx.annotation.Keep;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 7:35 PM
* desc : 对外服务模块路径
* version: 1.0
* 使用方式:
* Arouter.getInstance().path("").navigate()
*/
@Keep
public class MoGoV2XServicePaths {
/**
* V2X 状态管理
*/
@Keep
public static final String PATH_V2X_STATUS_MANAGER = "/v2xStatusManager/api";
/**
* V2X 道路事件POI点
*/
@Keep
public static final String PATH_V2X_MARKER_MANAGER = "/v2xMarkerManager/api";
/**
* V2X 道路事件与车辆的连接线
*/
@Keep
public static final String PATH_V2X_POLYLINE_MANAGER = "/v2xPolylineManager/api";
}

View File

@@ -0,0 +1,107 @@
package com.mogo.module.v2x;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-2114:10
* desc : V2X使用到的常量
* version: 1.0
*/
public class V2XConst {
/**
* 类型
*/
public static final String MODULE_NAME = "V2X_UI";
/**
* V2X模块地址
*/
public static final String PATH_V2X_UI = "/v2x/ui";
public static final String SEEK_HELP_TIME = "seek_help_time";
/**
* V2X 场景广播 Action
*/
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";
public static final String V2X_ACC_ON_TIME_STR = "v2x_acc_on_time_str";
public static final String V2X_ACC_OFF_TIME_STR = "v2x_acc_off_time_str";
public static final String V2X_STRATEGY_PUSH = "v2x_strategy_push";
public static final int STATE_ERROR = -1;
public static final int STATE_IDLE = 0;
public static final int STATE_PREPARING = 1;
public static final int STATE_PREPARED = 2;
public static final int STATE_PLAYING = 3;
public static final int STATE_PAUSED = 4;
public static final int STATE_PLAYBACK_COMPLETED = 5;
public static final int STATE_SEEKING = 6;
/**
* V2X 埋点
*/
public static final String V2X_ROAD_SHOW = "v2x_road_show";
public static final String V2X_ROAD_EVET = "v2x_road_event";
/**
* V2X 道路事件操作类型
*/
public static final String V2X_ROAD_ZAN = "1";
public static final String V2X_ROAD_CHAT = "2";
public static final String V2X_ROAD_VIDEO = "3";
public static final String V2X_ROAD_NAVI = "4";
public static final String V2X_ROAD_REPORT_RIGHT = "5";
public static final String V2X_ROAD_REPORT_ERROR = "6";
/**
* V2X 地图上发出警告的POI
*/
public static final String V2X_ILLEGAL_PARK_POI = "V2X_ILLEGAL_PARK_POI";
/**
* V2X 地图上发出警告的POI
*/
public static final String V2X_EVENT_ALARM_POI = "V2X_EVENT_ALARM_POI";
/**
* V2X 探路数据
*/
public static final String V2X_CARD_TYPE_ROAD_CONDITION = "V2X_CARD_TYPE_ROAD_CONDITION";
/**
* V2X 用户数据
*/
public static final String V2X_CARD_TYPE_USER_DATA = "V2X_CARD_TYPE_USER_DATA";
/**
* V2X 新鲜事
*/
public static final String V2X_CARD_TYPE_NOVELTY = "V2X_CARD_TYPE_NOVELTY";
/**
* V2X 特殊车辆
*/
public static final String V2X_MARKER_SPECIAL_CAR = "V2X_MARKER_SPECIAL_CAR";
/**
* V2X 可直播车辆
*/
public static final String V2X_MARKER_LIVE_CAR = "V2X_MARKER_LIVE_CAR";
/**
* V2X 取快递
*/
public static final String V2X_MARKER_EXPRESS = "V2X_MARKER_EXPRESS";
/**
* V2X 顺风车
*/
public static final String V2X_MARKER_TAXI = "V2X_MARKER_TAXI";
/**
* V2X 政府推送消息
*/
public static final String V2X_MARKER_GOVERNMENT = "V2X_MARKER_GOVERNMENT";
}

View File

@@ -0,0 +1,139 @@
package com.mogo.module.v2x;
import android.content.Intent;
import android.text.TextUtils;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.voice.V2XVoiceConstants;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.utils.logger.Logger;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/28 12:24 PM
* desc : 演示DEMO管理
* version: 1.0
*/
public class V2XDemoManager {
private List<V2XDemoUserInfoRes.ResultBean.UserListBean> userListBeanList;
private V2XDemoUserInfoRes.ResultBean.UserListBean mV2XDemoUserInfoEntity1;
private V2XDemoUserInfoRes.ResultBean.UserListBean mV2XDemoUserInfoEntity2;
private V2XDemoUserInfoRes.ResultBean.UserListBean mV2XDemoUserInfoEntity3;
private static V2XDemoManager mV2XDemoManager;
private V2XDemoManager() {
}
public static V2XDemoManager getInstance() {
if (mV2XDemoManager == null) {
synchronized (V2XDemoManager.class) {
if (mV2XDemoManager == null) {
mV2XDemoManager = new V2XDemoManager();
}
}
}
return mV2XDemoManager;
}
public void initData() {
// 获取演示车辆信息
V2XServiceManager
.getV2XRefreshModel()
.getMockUserInfos(new V2XRefreshCallback<V2XDemoUserInfoRes>() {
@Override
public void onSuccess(V2XDemoUserInfoRes result) {
userListBeanList = result.getResult().getUserList();
Logger.w(MODULE_NAME, "V2X演示用户数据" + userListBeanList);
for (V2XDemoUserInfoRes.ResultBean.UserListBean userListBean : userListBeanList) {
switch (userListBean.getSceneType()) {
case "1":
mV2XDemoUserInfoEntity1 = userListBean;
break;
case "2":
mV2XDemoUserInfoEntity2 = userListBean;
break;
case "3":
mV2XDemoUserInfoEntity3 = userListBean;
break;
}
}
// 呼叫前方车辆
V2XVoiceManager.INSTANCE.registerWakeCmd(
V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR,
(String command, Intent intent) -> {
String dataStr = intent.getStringExtra("data");
Logger.w(MODULE_NAME, "mData。。。。" + dataStr);
if (!TextUtils.isEmpty(dataStr)) {
if (dataStr.contains("address")) {
roadCallChart(mV2XDemoUserInfoEntity2);
}
} else {
roadCallChart(mV2XDemoUserInfoEntity1);
}
}
);
}
@Override
public void onFail(String msg) {
}
});
}
public void release() {
// 呼叫前方车辆
V2XVoiceManager.INSTANCE.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR);
}
/**
* 打电话
*/
private void roadCallChart(V2XDemoUserInfoRes.ResultBean.UserListBean mV2XDemoUserInfoEntity) {
Logger.w(MODULE_NAME, "正在拨打电话。。。。" + mV2XDemoUserInfoEntity);
try {
if (mV2XDemoUserInfoEntity != null) {
MarkerUserInfo mUserInfo = new MarkerUserInfo();
MarkerLocation location = new MarkerLocation();
location.setLon(mV2XDemoUserInfoEntity.getLocation().getLon());
location.setLat(mV2XDemoUserInfoEntity.getLocation().getLat());
mUserInfo.setSn(mV2XDemoUserInfoEntity.getUserInfo().getSn());
mUserInfo.setUserHead(mV2XDemoUserInfoEntity.getUserInfo().getUserHead());
mUserInfo.setUserName(mV2XDemoUserInfoEntity.getUserInfo().getUserName());
mUserInfo.setGender(mV2XDemoUserInfoEntity.getUserInfo().getGender());
mUserInfo.setAge(mV2XDemoUserInfoEntity.getUserInfo().getAge());
ChartingUtil.callChatting(mUserInfo, location);
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 1-拨打前方车辆,
public V2XDemoUserInfoRes.ResultBean.UserListBean getV2XDemoUserInfoEntity1() {
return mV2XDemoUserInfoEntity1;
}
// 2-拨打中关村附近好友,
public V2XDemoUserInfoRes.ResultBean.UserListBean getV2XDemoUserInfoEntity2() {
return mV2XDemoUserInfoEntity2;
}
// 3-点击地图图标拨打电话
public V2XDemoUserInfoRes.ResultBean.UserListBean getV2XDemoUserInfoEntity3() {
return mV2XDemoUserInfoEntity3;
}
}

View File

@@ -0,0 +1,108 @@
package com.mogo.module.v2x;
import android.content.Context;
import android.os.Handler;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.v2x.listener.V2XLocationListener;
import com.mogo.module.v2x.network.V2XRefreshModel;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/6 5:37 PM
* desc :
* version: 1.0
*/
public class V2XMarkerService {
private final String TAG = "V2XMarkerService";
// 一分钟获取一次最新的路况信息
private final int refreshTime = 60_000;
private static V2XMarkerService mV2XMarkerService;
private V2XRefreshModel mV2XRefreshModel;
private Handler refreshHandler;
private Runnable refreshRunnable;
public synchronized static V2XMarkerService getInstance(Context context) {
if (mV2XMarkerService == null) {
mV2XMarkerService = new V2XMarkerService();
mV2XMarkerService.init(context);
}
return mV2XMarkerService;
}
private void init(Context context) {
mV2XRefreshModel = V2XRefreshModel.getInstance(context);
}
public V2XRefreshModel getV2XRefreshModel() {
return mV2XRefreshModel;
}
public void refreshMarkerData(MogoLocation location) {
try {
if (mV2XRefreshModel != null && location != null) {
//Logger.d(MODULE_NAME, "V2X道路事件执行气泡刷新操作。");
// 获取目前最新的周边的poi点
mV2XRefreshModel.querySnapshotAsync(
new MogoLatLng(location.getLatitude(), location.getLongitude()),
(int) getMapCameraFactWidth(),
999);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 地图视图对应的实际宽度
*/
private float getMapCameraFactWidth() {
return 1_000;
}
/**
* 关闭自动刷新
*/
public void stopAutoRefresh() {
Logger.w(MODULE_NAME, "V2X道路事件关闭V2X地图气泡自动刷新。");
V2XServiceManager
.getMogoRegisterCenter()
.unregisterMogoLocationListener(MODULE_NAME);
if (refreshHandler != null) {
refreshHandler.removeCallbacks(refreshRunnable);
}
refreshRunnable = null;
}
/**
* 开始刷新
*/
public void startAutoRefresh() {
// 设置地图定位监听
V2XServiceManager.getMogoRegisterCenter()
.registerMogoLocationListener(MODULE_NAME, V2XLocationListener.getInstance());
Logger.d(MODULE_NAME, "V2X道路事件开启V2X地图气泡自动绘制。");
if (refreshHandler == null) {
refreshHandler = new Handler();
}
if (refreshRunnable == null) {
refreshRunnable = new Runnable() {
@Override
public void run() {
refreshMarkerData(V2XLocationListener.getInstance().getLastCarLocation());
refreshHandler.postDelayed(this, refreshTime);
}
};
}
refreshHandler.post(refreshRunnable);
}
}

View File

@@ -0,0 +1,294 @@
package com.mogo.module.v2x;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.v2x.entity.net.V2XSeekHelpRes;
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.receiver.SceneBroadcastReceiver;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkWindow;
import com.mogo.module.v2x.scenario.scene.test.V2XTestConsoleWindow;
import com.mogo.module.v2x.utils.FatigueDrivingUtils;
import com.mogo.module.v2x.utils.TimeUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.mogo.utils.storage.SharedPrefsMgr;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-2114:03
* desc : V2X的管理
* version: 2.0
*/
@Route(path = V2XConst.PATH_V2X_UI)
public class V2XModuleProvider implements
IMogoModuleProvider,
IMogoStatusChangedListener {
private final String TAG = "V2XMocduleProvider";
private Context mContext;
@Override
public Fragment createFragment(Context context, Bundle data) {
return null;
}
@Override
public View createView(Context context) {
return null;
}
@NonNull
@Override
public String getModuleName() {
return ServiceConst.TYPE;
}
@Override
public IMogoModuleLifecycle getCardLifecycle() {
return null;
}
@Override
public IMogoMapListener getMapListener() {
return null;
}
@Override
public int getType() {
return ModuleType.TYPE_SERVICE;
}
@Override
public IMogoNaviListener getNaviListener() {
return null;
}
@Override
public IMogoLocationListener getLocationListener() {
return null;
}
@Override
public IMogoMarkerClickListener getMarkerClickListener() {
return null;
}
@Override
public String getAppPackage() {
return null;
}
@Override
public String getAppName() {
return null;
}
@Override
public void init(Context context) {
Logger.e(MODULE_NAME, "V2X模块初始化。。。。");
mContext = context;
V2XUtils.init(context);
V2XServiceManager.init(context);
initVoice(context);
handleAdas();
initData();
// 注册广播接收场景弹窗使用的
SceneBroadcastReceiver localReceiver = new SceneBroadcastReceiver();
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
// TODO 这是测试页面
V2XServiceManager
.getIMogoWindowManager()
.addView(new V2XTestConsoleWindow(context), 0, 0, false);
}
private void initVoice(Context context) {
V2XVoiceManager.INSTANCE.init(context);
}
private void initData() {
//初始化获得自车求助状态
initCarForHelpStatus();
try {
// 查询ACC状态
SharedPrefsMgr.getInstance(V2XUtils.getApp()).putBoolean("descriptor_ACC_STATUS", isAccOn());
if (isAccOn()) {
// 记录开机时间
FatigueDrivingUtils.refreshAccOnTime();
initCarForHelpStatus();
// 刷新配置文件
refreshStrategyConfig();
} else {
// 记录关机时间
SharedPrefsMgr.getInstance(V2XUtils.getApp())
.putString(V2XConst.V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString());
}
} catch (Exception e) {
e.printStackTrace();
}
// 刷新配置文件
refreshStrategyConfig();
// 响应违章停车的POI点击
V2XServiceManager
.getMogoRegisterCenter()
.registerMogoMarkerClickListener(V2XConst.MODULE_NAME,
new IMogoMarkerClickListener() {
@Override
public boolean onMarkerClicked(IMogoMarker marker) {
try {
MarkerExploreWay markerExploreWay =
(MarkerExploreWay) ((MarkerShowEntity) marker.getObject()).getBindObj();
Logger.d(V2XConst.MODULE_NAME,
"V2X===违章停车:onMarkerClicked=" + markerExploreWay);
((V2XIllegalParkWindow) V2XIllegalParkScenario.getInstance()
.getV2XWindow())
.show(markerExploreWay, false);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
});
}
private void refreshStrategyConfig() {
// 获取疲劳驾驶的配置
V2XServiceManager
.getV2XRefreshModel()
.getStrategyPush(new V2XRefreshCallback<V2XStrategyPushRes>() {
@Override
public void onSuccess(V2XStrategyPushRes result) {
Logger.w(MODULE_NAME, "V2X疲劳驾驶配置数据更新" + GsonUtil.jsonFromObject(result));
V2XStrategyPushRes.ResultBean resultBean = result.getResult();
if (resultBean != null) {
// 更新本地的v2x提醒策略
SharedPrefsMgr.getInstance(V2XUtils.getApp())
.putString(V2XConst.V2X_STRATEGY_PUSH, GsonUtil.jsonFromObject(resultBean));
}
}
@Override
public void onFail(String msg) {
}
});
}
private void handleAdas() {
V2XServiceManager.getMoGoStatusManager()
.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.ACC_STATUS, this);
V2XServiceManager.getMoGoStatusManager()
.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.SEEK_HELPING, this);
// 注册V2X场景Socket
V2XServiceManager.getV2XSocketManager().registerSocketMessage();
// 开启自动刷新
V2XServiceManager.getV2XMarkerService().startAutoRefresh();
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
V2XServiceManager.getMapUIController().recoverLockMode();
}
private void handleSeekHelp(boolean isTrue) {
V2XMessageEntity<Boolean> entity = new V2XMessageEntity<>();
entity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP);
entity.setContent(isTrue);
V2XScenarioManager.getInstance().handlerMessage(entity);
}
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
Logger.d(MODULE_NAME, "状态发生改变\ndescriptor:" + descriptor + "\nisTrue:" + isTrue);
// 记录状态更改
SharedPrefsMgr.getInstance(V2XUtils.getApp()).putBoolean("descriptor_" + descriptor, isTrue);
if (descriptor == StatusDescriptor.ACC_STATUS) {
if (isTrue) {
// 记录开机时间
FatigueDrivingUtils.refreshAccOnTime();
initCarForHelpStatus();
} else {
// 记录关机时间
SharedPrefsMgr.getInstance(V2XUtils.getApp())
.putString(V2XConst.V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString());
}
} else if (descriptor == StatusDescriptor.SEEK_HELPING) {
handleSeekHelp(isTrue);
}
}
public boolean isAccOn() {
int accState = Settings.System.getInt(mContext.getContentResolver(), "mcu_state", -0x02);
Logger.d(MODULE_NAME, "状态发生改变\ndescriptor:ACC_STSTUS" + "\nisTrue:" + accState);
return accState == 1;
}
private void initCarForHelpStatus() {
//本地查询是否超时
V2XServiceManager.getV2XRefreshModel().getHelpSignal(new V2XRefreshCallback<V2XSeekHelpRes>() {
@Override
public void onSuccess(V2XSeekHelpRes result) {
if (result != null) {
V2XSeekHelpRes.ResultBean resultBean = result.getResult();
if (resultBean != null) {
int vehicleType = resultBean.getVehicleType();
//故障车
if (vehicleType == 4) {
if (!V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
handleSeekHelp(true);
V2XServiceManager.getMoGoStatusManager().setSeekHelping(MODULE_NAME, true);
}
} else {
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
handleSeekHelp(false);
V2XServiceManager.getMoGoStatusManager().setSeekHelping(MODULE_NAME, false);
}
}
}
}
}
@Override
public void onFail(String msg) {
}
});
}
}

View File

@@ -0,0 +1,246 @@
package com.mogo.module.v2x;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.overlay.IMogoOverlayManager;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.carchattingprovider.ICarsChattingProvider;
import com.mogo.module.v2x.alarm.V2XCalculateServer;
import com.mogo.module.v2x.network.V2XRefreshModel;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.connection.IMogoSocketManager;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoActionManager;
import com.mogo.service.module.IMogoMarkerService;
import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.module.IMogoSearchManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
import com.mogo.service.windowview.IMogoTopViewManager;
import com.mogo.service.windowview.IMogoWindowManager;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-2114:01
* desc : V2X 服务
* version: 1.0
*/
public class V2XServiceManager {
private static final String TAG = "V2XServiceManager";
private static Context mContext;
private static IMogoServiceApis mMogoServiceApis;
private static IMogoMapService mMapService;
private static IMogoMarkerManager mMarkerManager;
private static IMogoNavi mNavi;
private static IMogoMapUIController mMapUIController;
private static IMogoLocationClient mMogoLocationClient;
private static IMogoGeoSearch mIMogoGeoSearch;
private static IMogoSearchManager mIMogoSearchManager;
private static IMogoTopViewManager mMogoTopViewManager;
private static IMogoStatusManager mMogoStatusManager;
private static IMogoWindowManager mIMogoWindowManager;
private static IMogoImageloader mImageLoader;
private static IMogoSocketManager mMogoSocketManager;
private static IMogoAnalytics mMogoAnalytics;
private static IMogoOverlayManager mMogoOverlayManager;
private static IMogoRegisterCenter mMogoRegisterCenter;
private static IMogoRefreshStrategyController mIMogoRefreshStrategyController;
private static IMogoMarkerService mIMogoMarkerService;
private static IMogoActionManager mMogoActionManager;
private static ICarsChattingProvider mCarsChattingProvider;
private static IMogoADASController mIMogoADASController;
private static IMogoIntentManager mMogoIntentManager;
private static IMogoEntranceButtonController mMogoEntranceButtonController;
private static V2XRefreshModel mV2XRefreshModel;
private static V2XMarkerService mV2XMarkerService;
private static V2XStatusManager mV2XStatusManager;
private static V2XSocketManager mV2XSocketManager;
private static V2XCalculateServer mV2XCalculateServer;
// 下面的是重构后的代码,建议
private static IMoGoV2XMarkerManager moGoV2XMarkerManager;
private static IMoGoV2XPolylineManager moGoV2XPolylineManager;
private static IMoGoV2XStatusManager moGoV2XStatusManager;
public static void init(final Context context) {
mContext = context;
mMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
mMapService = mMogoServiceApis.getMapServiceApi();
mImageLoader = mMogoServiceApis.getImageLoaderApi();
mMogoStatusManager = mMogoServiceApis.getStatusManagerApi();
mMogoSocketManager = mMogoServiceApis.getSocketManagerApi(context);
mMogoAnalytics = mMogoServiceApis.getAnalyticsApi();
mIMogoWindowManager = mMogoServiceApis.getWindowManagerApi();
mMogoRegisterCenter = mMogoServiceApis.getRegisterCenterApi();
mIMogoRefreshStrategyController = mMogoServiceApis.getRefreshStrategyControllerApi();
mIMogoADASController = mMogoServiceApis.getAdasControllerApi();
mMogoEntranceButtonController = mMogoServiceApis.getEntranceButtonController();
mMogoActionManager = mMogoServiceApis.getActionManagerApi();
mMogoTopViewManager = mMogoServiceApis.getTopViewManager();
mIMogoSearchManager = mMogoServiceApis.getSearchManagerApi();
mIMogoMarkerService = mMogoServiceApis.getMarkerService();
mMarkerManager = mMapService.getMarkerManager(context);
mNavi = mMapService.getNavi(context);
mMapUIController = mMapService.getMapUIController();
mMogoLocationClient = mMapService.getSingletonLocationClient(context);
mMogoOverlayManager = mMapService.getOverlayManager(context);
mIMogoGeoSearch = mMapService.getGeoSearch(context);
mCarsChattingProvider = (ICarsChattingProvider) ARouter.getInstance().build(CallChattingProviderConstant.CAR_CALL_PROVIDER).navigation();
mMogoIntentManager = mMogoServiceApis.getIntentManagerApi();
mV2XRefreshModel = V2XRefreshModel.getInstance(context);
mV2XMarkerService = V2XMarkerService.getInstance(context);
mV2XStatusManager = V2XStatusManager.getInstance();
mV2XSocketManager = V2XSocketManager.getInstance();
mV2XCalculateServer = V2XCalculateServer.getInstance();
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
}
public static Context getContext() {
return mContext;
}
public static IMogoTopViewManager getMogoTopViewManager() {
return mMogoTopViewManager;
}
public static IMogoEntranceButtonController getMogoEntranceButtonController() {
return mMogoEntranceButtonController;
}
public static IMogoMapService getMapService() {
return mMapService;
}
public static IMogoOverlayManager getMogoOverlayManager() {
return mMogoOverlayManager;
}
public static IMogoRegisterCenter getMogoRegisterCenter() {
return mMogoRegisterCenter;
}
public static IMogoMarkerManager getMarkerManager() {
return mMarkerManager;
}
public static IMogoNavi getNavi() {
return mNavi;
}
public static IMogoMapUIController getMapUIController() {
return mMapUIController;
}
public static IMogoLocationClient getMogoLocationClient() {
return mMogoLocationClient;
}
public static IMogoImageloader getImageLoader() {
return mImageLoader;
}
public static IMogoSocketManager getMoGoSocketManager() {
return mMogoSocketManager;
}
public static IMogoStatusManager getMoGoStatusManager() {
return mMogoStatusManager;
}
public static IMogoWindowManager getIMogoWindowManager() {
return mIMogoWindowManager;
}
public static ICarsChattingProvider getCarsChattingProvider() {
return mCarsChattingProvider;
}
public static IMogoIntentManager getMogoIntentManager() {
return mMogoIntentManager;
}
public static V2XMarkerService getV2XMarkerService() {
return mV2XMarkerService;
}
public static V2XRefreshModel getV2XRefreshModel() {
return mV2XRefreshModel;
}
public static V2XStatusManager getV2XStatusManager() {
return mV2XStatusManager;
}
public static V2XSocketManager getV2XSocketManager() {
return mV2XSocketManager;
}
public static IMoGoV2XMarkerManager getMoGoV2XMarkerManager() {
return moGoV2XMarkerManager;
}
public static IMoGoV2XPolylineManager getMoGoV2XPolylineManager() {
return moGoV2XPolylineManager;
}
public static IMoGoV2XStatusManager getMoGoV2XStatusManager() {
return moGoV2XStatusManager;
}
public static IMogoActionManager getMogoActionManager() {
return mMogoActionManager;
}
public static IMogoGeoSearch getMogoGeoSearch() {
return mIMogoGeoSearch;
}
public static IMogoSearchManager getSearchManager() {
return mIMogoSearchManager;
}
public static IMogoRefreshStrategyController getIMogoRefreshStrategyController() {
return mIMogoRefreshStrategyController;
}
public static IMogoAnalytics getMogoAnalytics() {
return mMogoAnalytics;
}
public static IMogoMarkerService getIMogoMarkerService() {
return mIMogoMarkerService;
}
public static V2XCalculateServer getV2XCalculateServer() {
return mV2XCalculateServer;
}
}

View File

@@ -0,0 +1,209 @@
package com.mogo.module.v2x;
import com.mogo.module.v2x.listener.V2XMessageListener_401003;
import com.mogo.module.v2x.listener.V2XMessageListener_401005;
import com.mogo.module.v2x.listener.V2XMessageListener_401006;
import com.mogo.module.v2x.listener.V2XMessageListener_401007;
import com.mogo.module.v2x.listener.V2XMessageListener_401009;
import com.mogo.module.v2x.listener.V2XMessageListener_401010;
import com.mogo.module.v2x.listener.V2XMessageListener_401011;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/31 5:59 PM
* desc : V2X报警事件管理这里进行报警事件的分发处理TODO 这里是准备重构使用的
* version: 1.0
*/
public class V2XSocketManager {
private static V2XSocketManager mV2XSocketManager;
private V2XMessageListener_401011 v2XMessageListener_401001;
private V2XMessageListener_401003 v2XMessageListener_401003;
private V2XMessageListener_401005 v2XMessageListener_401005;
private V2XMessageListener_401006 v2XMessageListener_401006;
private V2XMessageListener_401007 v2XMessageListener_401007;
private V2XMessageListener_401009 v2XMessageListener_401009;
private V2XMessageListener_401010 v2XMessageListener_401010;
private V2XSocketManager() {
}
/**
* 获取操作实体
*/
public static synchronized V2XSocketManager getInstance() {
synchronized (V2XSocketManager.class) {
if (mV2XSocketManager == null) {
mV2XSocketManager = new V2XSocketManager();
}
}
return mV2XSocketManager;
}
/**
* 注册长链接消息处理
*/
public void registerSocketMessage() {
Logger.d(MODULE_NAME, "开始注册Socket通道....");
register401011();
register401005();
register401007();
register401009();
// TODO 这里是前瞻需求,量产版本需要注释
//register401003();
// TODO 旧版本的一种V2X预警形式已经废弃了
//register401006();
}
/**
* 反注册消息通道,不再进行接受
*/
public void unregisterSocketMessage() {
Logger.w(MODULE_NAME, "反注册Socket通道....");
if (v2XMessageListener_401001 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401011, v2XMessageListener_401001);
}
if (v2XMessageListener_401003 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401003, v2XMessageListener_401003);
}
if (v2XMessageListener_401005 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401005, v2XMessageListener_401005);
}
if (v2XMessageListener_401006 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401006, v2XMessageListener_401006);
}
if (v2XMessageListener_401007 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401007, v2XMessageListener_401007);
}
if (v2XMessageListener_401009 != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(401009, v2XMessageListener_401009);
}
}
/**
* 道路事件,在线车辆绘制
*/
private void register401011() {
v2XMessageListener_401001 = new V2XMessageListener_401011();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401011,
v2XMessageListener_401001
);
}
/**
* ADAS & V2X 场景触发push
* TODO 这里是后台下发 http://h5service.zhidaohulian.com/v2x_remoteControl/#/
*/
private void register401003() {
v2XMessageListener_401003 = new V2XMessageListener_401003();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401003,
v2XMessageListener_401003
);
}
/**
* 特殊车辆推送绘制
*/
private void register401005() {
v2XMessageListener_401005 = new V2XMessageListener_401005();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401005,
v2XMessageListener_401005
);
}
/**
* * 3.2.1、前方静止or慢速车辆报警
* * 3.2.2、道路危险状况告警 / 前方拥堵告警
*/
@Deprecated
private void register401006() {
v2XMessageListener_401006 = new V2XMessageListener_401006();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401006,
v2XMessageListener_401006
);
}
/**
* 限行通知
*/
private void register401007() {
v2XMessageListener_401007 = new V2XMessageListener_401007();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401007,
v2XMessageListener_401007
);
}
/**
* * 2.0.2
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=35786774
* * 注册点赞通信接收
*/
public void register401009() {
v2XMessageListener_401009 = new V2XMessageListener_401009();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401009,
v2XMessageListener_401009
);
}
/**
* * 2.0.3
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=35788659
* * TODO 停车场、加油站推送心跳,这里是前瞻的功能,目前仅在分体机使用,
*/
@Deprecated
private void register401010() {
v2XMessageListener_401010 = new V2XMessageListener_401010();
// 道路事件,在线车辆绘制
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
401010,
v2XMessageListener_401010
);
}
}

View File

@@ -0,0 +1,62 @@
package com.mogo.module.v2x;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.V2XRoadEventEntity;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/3 2:34 PM
* desc : V2X状态管理
* version: 1.0
*/
@Deprecated
public class V2XStatusManager {
private static V2XStatusManager mV2XStatusManager;
// 正在进行的告警事件详情
private V2XRoadEventEntity mAlarmInfo;
private MogoLocation mLocation;
private V2XStatusManager() {
}
/**
* 获取操作实体
*/
public static synchronized V2XStatusManager getInstance() {
synchronized (V2XStatusManager.class) {
if (mV2XStatusManager == null) {
mV2XStatusManager = new V2XStatusManager();
}
}
return mV2XStatusManager;
}
public void setAlarmInfo(V2XRoadEventEntity eventEntity) {
this.mAlarmInfo = eventEntity;
}
// 获取目标事件经纬度
public MogoLatLng getTargetMoGoLatLng() {
if (mAlarmInfo != null) {
return new MogoLatLng(
mAlarmInfo.getLocation().getLat(),
mAlarmInfo.getLocation().getLon()
);
}
return null;
}
public MogoLocation getLocation() {
if (mLocation == null) {
mLocation = new MogoLocation();
}
return mLocation;
}
public void setLocation(MogoLocation mLocation) {
this.mLocation = mLocation;
}
}

View File

@@ -0,0 +1,49 @@
package com.mogo.module.v2x.adapter;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.module.v2x.adapter.holder.V2XPushEventDetailVH;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:05 PM
* desc : V2X 场景事件列表中的数据适配器
* version: 1.0
*/
public class V2XPushEventAdapter extends RecyclerView.Adapter<V2XPushEventDetailVH> {
private List<V2XPushMessageEntity> itemList;
public V2XPushEventAdapter(List<V2XPushMessageEntity> itemList) {
this.itemList = itemList;
}
@NonNull
@Override
public V2XPushEventDetailVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new V2XPushEventDetailVH(parent);
}
@Override
public void onBindViewHolder(@NonNull V2XPushEventDetailVH holder, int position) {
holder.initView(itemList.get(position));
}
@Override
public int getItemViewType(int position) {
return itemList.get(position).getViewType();
}
@Override
public int getItemCount() {
return itemList == null ? 0 : itemList.size();
}
}

View File

@@ -0,0 +1,67 @@
package com.mogo.module.v2x.adapter;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.v2x.adapter.holder.V2XLiveVideoVH;
import com.mogo.module.v2x.adapter.holder.V2XRoadEventDetailVH;
import com.mogo.module.common.entity.V2XWindowTypeEnum;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:05 PM
* desc : V2X 场景事件列表中的数据适配器
* version: 1.0
*/
public class V2XRoadEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<V2XEventShowEntity> itemList;
public V2XRoadEventAdapter(List<V2XEventShowEntity> itemList) {
this.itemList = itemList;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder;
switch (viewType) {
case V2XWindowTypeEnum.LIVE_CAR_WINDOW:
holder = new V2XLiveVideoVH(parent);
break;
case V2XWindowTypeEnum.ROAD_EVENT_WINDOW:
holder = new V2XRoadEventDetailVH(parent);
break;
default:
holder = new V2XRoadEventDetailVH(parent);
}
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof V2XLiveVideoVH) {
((V2XLiveVideoVH) holder).initView(itemList.get(position));
}
if (holder instanceof V2XRoadEventDetailVH) {
((V2XRoadEventDetailVH) holder).initView(itemList.get(position));
}
}
@Override
public int getItemViewType(int position) {
return itemList.get(position).getViewType();
}
@Override
public int getItemCount() {
return itemList == null ? 0 : itemList.size();
}
}

View File

@@ -0,0 +1,217 @@
package com.mogo.module.v2x.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.module.carchattingprovider.ICarsChattingProvider;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.ICallChatResponse;
import org.jetbrains.annotations.Nullable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
/**
* author : fenghualong
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:05 PM
* desc : V2X 其他车辆发起的故障求助
* version: 1.0
*/
public class V2XSeekHelpAdapter extends RecyclerView.Adapter<V2XSeekHelpAdapter.MyViewHolder> {
private static final String TAG = V2XSeekHelpAdapter.class.getSimpleName();
private List<V2XMarkerEntity> itemList;
private LayoutInflater mInflater;
public V2XSeekHelpAdapter(Context context) {
itemList = new ArrayList<>();
mInflater = LayoutInflater.from(context);
}
public void addDataList(List<V2XMarkerEntity> list) {
if (itemList == null) {
itemList = new ArrayList<>();
}
itemList.addAll(list);
}
public void addData(V2XMarkerEntity entity) {
if (itemList == null) {
itemList = new ArrayList<>();
}
itemList.add(entity);
}
public void removeData(V2XMarkerEntity entity) {
if (itemList != null) {
itemList.remove(entity);
}
}
public void removeData(int position) {
if (isPositionValid(position)) {
itemList.remove(position);
}
}
public void clearData() {
if (itemList != null) {
itemList.clear();
}
}
public boolean isPositionValid(int position) {
return position > -1 && itemList != null && itemList.size() > position;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_v2x_fault_help, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
if (isPositionValid(position)) {
V2XMarkerEntity entity = itemList.get(position);
if (entity != null) {
V2XMarkerEntity.UserInfoBean infoBean = entity.getUserInfo();
if (infoBean != null) {
long time = entity.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.CHINA);
String eventDistance = String.format("距离%d m", entity.getDistance());
String eventTime = String.format("%s发布求助信息", sdf.format(new Date(time)));
holder.initView(infoBean.getHeadImgUrl(), infoBean.getDisplayName(), eventDistance, eventTime);
}
}
Log.d(TAG, "onBindViewHolder position=$position, entity= " + entity);
setCallData(holder.ivCall, entity);
//setCallDataWait(holder.ivCall, entity);
holder.ivNavi.setOnClickListener(v -> {
if (mListener != null && !V2XUtils.isFastClick()) {
mListener.onViewNaviClick(entity.getLat(), entity.getLon());
}
});
}
}
private void setCallData(ImageView ivCall, V2XMarkerEntity entity) {
ICarsChattingProvider provider = V2XServiceManager.getCarsChattingProvider();
// 判断是否可以打电话
ChartingUtil.isCanCall(b -> {
if (b) {
// 判断是否可以打电话
ChartingUtil.isOnLine(entity.getSn(), b1 -> {
if (b1) {
ivCall.setVisibility(VISIBLE);
} else {
ivCall.setVisibility(GONE);
}
});
} else {
ivCall.setVisibility(GONE);
}
});
ivCall.setOnClickListener(v -> {
if (!V2XUtils.isFastClick()) {
provider.isOnLine(V2XConst.MODULE_NAME, ivCall.getContext(), entity.getSn(), new ICallChatResponse() {
@Override
public void isOnLine(boolean isOnline, @Nullable String s) {
provider.canCall(V2XConst.MODULE_NAME, ivCall.getContext(), new ICallChatResponse() {
@Override
public void canCall(boolean canCall) {
Logger.d(TAG, "调用车聊聊,查询状态! SN=" + entity.getSn() + " is online: " + isOnline + " canCall: " + canCall + ", thread: " + Thread.currentThread().getName());
V2XUtils.runOnUiThread(() -> {
if (mListener != null && isOnline && canCall) {
mListener.onViewChatClick(entity);
}
});
}
});
}
}
);
}
});
}
@Override
public int getItemCount() {
return itemList != null ? itemList.size() : 0;
}
static class MyViewHolder extends RecyclerView.ViewHolder {
MogoImageView ivHead;
TextView tvName;
TextView tvDistance;
TextView tvEventTime;
ImageView ivCall;
ImageView ivNavi;
MyViewHolder(@NonNull View itemView) {
super(itemView);
ivHead = itemView.findViewById(R.id.ivFaultHelpHead);
tvName = itemView.findViewById(R.id.tvFaultHelpName);
tvDistance = itemView.findViewById(R.id.tvFaultHelpDistance);
tvEventTime = itemView.findViewById(R.id.tvFaultHelpEventTime);
ivCall = itemView.findViewById(R.id.ivFaultHelpEventCall);
ivNavi = itemView.findViewById(R.id.ivFaultHelpEventNavi);
}
void initView(String headUrl, String name, String distance, String eventTime) {
if (!TextUtils.isEmpty(headUrl)) {
V2XServiceManager.getImageLoader()
.displayImage(headUrl, ivHead);
}
tvName.setText(name);
tvDistance.setText(distance);
tvEventTime.setText(eventTime);
}
}
private OnViewClickListener mListener;
public void setOnViewClickListener(OnViewClickListener listener) {
mListener = listener;
}
public interface OnViewClickListener {
/**
* 点击事件,打电话给车聊聊
*
* @param entity
*/
void onViewChatClick(V2XMarkerEntity entity);
/**
* 点击事件,导航去故障车位置
*/
void onViewNaviClick(double lat, double lng);
}
}

View File

@@ -0,0 +1,244 @@
package com.mogo.module.v2x.adapter.holder;
import android.content.Intent;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.module.common.entity.MarkerCarInfo;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.common.entity.V2XLiveCarInfoEntity;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XUserInfoRes;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.TrackUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.view.V2XLiveGSYVideoView;
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.imageloader.MogoImageView;
import com.mogo.utils.logger.Logger;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:35 PM
* desc : 直播类型的卡片
* version: 1.0
*/
public class V2XLiveVideoVH extends RecyclerView.ViewHolder {
private V2XLiveGSYVideoView videoPlayer;
private MogoImageView ivReportHead;
// 控制按钮
private ImageView ivRoadCallChart;
private ImageView ivRoadEventLike;
// 上传事件的用户信息
private MarkerUserInfo mUserInfo = new MarkerUserInfo();
// 直播车机数据
private V2XLiveCarInfoEntity mV2XLiveCarEntity;
// 预警的道路事件数据
private V2XRoadEventEntity mV2XRoadEventEntity;
// 拨打车聊聊语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackCallListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
if (mUserInfo != null && !TextUtils.isEmpty(mUserInfo.getSn())) {
roadCallChart();
}
}
};
// 点赞语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackLickListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
if (mV2XLiveCarEntity != null) {
handlerZan(mV2XLiveCarEntity.getSn());
}
}
};
public V2XLiveVideoVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_v2x_live_video, viewGroup, false));
videoPlayer = itemView.findViewById(R.id.videoPlayer);
ivReportHead = itemView.findViewById(R.id.ivReportHead);
ivRoadCallChart = itemView.findViewById(R.id.ivRoadCallChart);
ivRoadEventLike = itemView.findViewById(R.id.ivRoadEventLike);
// 设置视图状态监听
itemView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
//Logger.w(MODULE_NAME, "列表View V2XLiveVideoVH 触发 onViewAttachedToWindow");
// 注册语音交互
V2XVoiceManager.INSTANCE
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING,
v2XVoiceCallbackCallListener)
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_ZAN,
v2XVoiceCallbackLickListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP,
v2XVoiceCallbackCallListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_ZAN_UN_WAKEUP,
v2XVoiceCallbackLickListener);
}
@Override
public void onViewDetachedFromWindow(View v) {
//Logger.w(MODULE_NAME, "列表View V2XLiveVideoVH 触发 onViewDetachedFromWindow");
}
});
}
public void initView(V2XEventShowEntity v2XLiveCarEntity) {
mV2XRoadEventEntity = v2XLiveCarEntity.getV2XRoadEventEntity();
mV2XLiveCarEntity = v2XLiveCarEntity.getV2XLiveCarInfoRes();
initView(mV2XLiveCarEntity);
}
public void initView(V2XLiveCarInfoEntity v2XLiveCarEntity) {
mV2XLiveCarEntity = v2XLiveCarEntity;
// 由于车机自身推流的原因这里为了浪费用户不必要的流量用户滑动到了那个view展示了再进行直播信息的获取及展示
MarkerCarInfo.CarLiveInfo carLiveInfo = new MarkerCarInfo.CarLiveInfo();
carLiveInfo.setVideoSn(v2XLiveCarEntity.getSn());
videoPlayer.setCarLiveInfo(carLiveInfo);
ivRoadEventLike.setVisibility(VISIBLE);
ivRoadCallChart.setOnClickListener(v -> {
ivRoadCallChart.setVisibility(GONE);
roadCallChart();
});
ivRoadEventLike.setOnClickListener(v -> {
handlerZan(v2XLiveCarEntity.getSn());
});
requestUserInfo(v2XLiveCarEntity);
}
private void roadCallChart() {
MarkerLocation location = new MarkerLocation();
ChartingUtil.callChatting(mUserInfo, location);
}
/**
* 请求用户信息
*
* @param v2XLiveCarEntity 直播信息
*/
private void requestUserInfo(V2XLiveCarInfoEntity v2XLiveCarEntity) {
Logger.d(MODULE_NAME, "上报事件的用户SN" + v2XLiveCarEntity.getSn());
TrackUtils.trackV2xRoadEvent(mV2XRoadEventEntity.getNoveltyInfo().getInfoId(), v2XLiveCarEntity.getSn(), V2XConst.V2X_ROAD_VIDEO);
// 获取道路事件周边的直播车机
if (!TextUtils.isEmpty(v2XLiveCarEntity.getSn())) {
V2XServiceManager
.getV2XRefreshModel()
.queryUserInfoBySn(
v2XLiveCarEntity.getSn(),
new V2XRefreshCallback<V2XUserInfoRes>() {
@Override
public void onSuccess(V2XUserInfoRes result) {
//Logger.d(MODULE_NAME, "上报事件的用户:" + result);
if (result != null &&
result.getResult() != null &&
result.getResult().getInfo() != null) {
V2XUserInfoRes.Result.Info infoBean = result.getResult().getInfo();
if (mUserInfo == null) {
mUserInfo = new MarkerUserInfo();
}
mUserInfo.setSn(infoBean.getSn());
try {
if (!TextUtils.isEmpty(infoBean.getCardIdAge())) {
mUserInfo.setAge(Integer.parseInt(infoBean.getCardIdAge()));
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
mUserInfo.setUserName(infoBean.getUserNickName());
mUserInfo.setUserHead(infoBean.getHeadImgUrl());
mUserInfo.setGender(infoBean.getCardIdSex());
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
// 判断是否可以打电话
ChartingUtil.isCanCall(b -> {
if (b) {
// 判断是否可以打电话
ChartingUtil.isOnLine(mUserInfo.getSn(), b1 -> {
if (b1) {
ivRoadCallChart.setVisibility(VISIBLE);
} else {
ivRoadCallChart.setVisibility(GONE);
}
});
} else {
ivRoadCallChart.setVisibility(GONE);
}
});
}
if (!TextUtils.isEmpty(mUserInfo.getUserHead())) {
V2XServiceManager.getImageLoader()
.displayImage(mUserInfo.getUserHead(), ivReportHead);
}
}
}
@Override
public void onFail(String msg) {
ivRoadCallChart.setVisibility(GONE);
}
});
}
}
private void handlerZan(String sn) {
try {
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已点赞", null);
showTip("已点赞");
V2XServiceManager.getV2XMarkerService()
.getV2XRefreshModel()
.giveLikeLiveVideo(null, sn);
ivReportHead.postDelayed(new Runnable() {
@Override
public void run() {
V2XRoadEventScenario.getInstance().close();
}
}, 2000);
} catch (Exception e) {
e.printStackTrace();
}
}
private void showTip(String msg) {
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
View toastView = LayoutInflater.from(V2XServiceManager.getContext()).inflate(R.layout.toast_view, null);
TextView msgView = toastView.findViewById(R.id.tvFeedbackContent);
msgView.setText(msg);
ToastUtils.showCustomShort(toastView);
}
}

View File

@@ -0,0 +1,297 @@
package com.mogo.module.v2x.adapter.holder;
import android.content.Intent;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.voice.AIAssist;
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.MarkerLocation;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.V2XUtils;
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.imageloader.MogoImageView;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:35 PM
* desc : TODO 这里是前瞻演示需求,推送的消息,
* version: 1.0
*/
public class V2XPushEventDetailVH extends RecyclerView.ViewHolder implements IMogoNaviListener {
private MogoImageView ivImg;
private MogoImageView ivReportHead;
// 控制按钮
private ImageView ivRoadReportTrue;
private ImageView ivRoadReportErr;
private ImageView ivRoadCallChart;
private ImageView ivRoadEventNav;
private ImageView ivRoadEventLike;
// 上传事件的用户信息
private MarkerUserInfo mUserInfo = new MarkerUserInfo();
private V2XPushMessageEntity mV2XRoadEventEntity;
// 语音控制导航
private V2XVoiceCallbackListener mNaviCb = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
startNavi();
}
};
// 语音控制拨打电话
private V2XVoiceCallbackListener mCallChartingCb = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
roadCallChart();
}
};
// 点赞语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackLickListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
handlerZan();
}
};
public V2XPushEventDetailVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_push_event_detail, viewGroup, false));
ivImg = itemView.findViewById(R.id.ivImg);
ivReportHead = itemView.findViewById(R.id.ivReportHead);
ivRoadReportTrue = itemView.findViewById(R.id.ivRoadReportTrue);
ivRoadReportErr = itemView.findViewById(R.id.ivRoadReportErr);
ivRoadCallChart = itemView.findViewById(R.id.ivRoadCallChart);
ivRoadEventNav = itemView.findViewById(R.id.ivRoadEventNav);
ivRoadEventLike = itemView.findViewById(R.id.ivRoadEventLike);
ivRoadEventNav.getParent().getParent().requestDisallowInterceptTouchEvent(true);
ivRoadEventNav.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startNavi();
}
});
ivRoadCallChart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
roadCallChart();
}
});
ivRoadEventLike.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handlerZan();
}
});
// 设置视图状态监听
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)
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING,
mCallChartingCb)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP,
mCallChartingCb)
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_ZAN,
v2XVoiceCallbackLickListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_ZAN_UN_WAKEUP,
v2XVoiceCallbackLickListener);
}
@Override
public void onViewDetachedFromWindow(View v) {
//Logger.w(MODULE_NAME, "列表View V2XPushEventDetailVH 触发 onViewDetachedFromWindow");
V2XServiceManager.getMogoRegisterCenter().unregisterMogoNaviListener(MODULE_NAME);
// 反注册语音交互
V2XVoiceManager.INSTANCE
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CLOSE_WINDOW)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CLOSE_WINDOW_UN_WAKEUP)
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING)
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_ZAN)
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REPORT)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_ZAN_UN_WAKEUP)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_TRUE)
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_ERROR)
.unRegisterPagingCallback();
}
});
}
public void initView(V2XPushMessageEntity v2XRoadEventEntity) {
mV2XRoadEventEntity = v2XRoadEventEntity;
if (!TextUtils.isEmpty(v2XRoadEventEntity.getMsgImgUrl())) {
V2XServiceManager.getImageLoader()
.displayImage(v2XRoadEventEntity.getMsgImgUrl(), ivImg);
}
if (!TextUtils.isEmpty(v2XRoadEventEntity.getHeadImgUrl())) {
V2XServiceManager.getImageLoader()
.displayImage(v2XRoadEventEntity.getHeadImgUrl(), ivReportHead);
}
switch (v2XRoadEventEntity.getSceneId()) {
case "100015"://取快递
case "100016"://顺风车
ivRoadEventNav.setVisibility(View.VISIBLE);
ivRoadCallChart.setVisibility(View.VISIBLE);
ivRoadReportTrue.setVisibility(View.GONE);
ivRoadReportErr.setVisibility(View.GONE);
ivRoadEventLike.setVisibility(View.GONE);
break;
case "100017"://政府公告
ivRoadEventLike.setVisibility(View.VISIBLE);
ivRoadCallChart.setVisibility(View.GONE);
ivRoadEventNav.setVisibility(View.GONE);
ivRoadReportTrue.setVisibility(View.GONE);
ivRoadReportErr.setVisibility(View.GONE);
break;
}
}
/**
* 打电话
*/
private void roadCallChart() {
Logger.w(MODULE_NAME, "正在拨打电话。。。。");
if (mV2XRoadEventEntity != null) {
MarkerLocation location = new MarkerLocation();
location.setLon(mV2XRoadEventEntity.getLon());
location.setLat(mV2XRoadEventEntity.getLat());
mUserInfo.setSn(mV2XRoadEventEntity.getSn());
mUserInfo.setUserHead(mV2XRoadEventEntity.getHeadImgUrl());
mUserInfo.setUserName("蘑菇用户");
mUserInfo.setGender("");
mUserInfo.setAge(30);
ChartingUtil.callChatting(mUserInfo, location);
delayedCloseWindow();
}
}
/**
* 点赞
*/
private void handlerZan() {
try {
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已点赞", null);
showTip("已点赞");
if (mV2XRoadEventEntity != null) {
V2XServiceManager.getV2XMarkerService()
.getV2XRefreshModel()
.giveLikeLiveVideo(null, mV2XRoadEventEntity.getSn());
}
delayedCloseWindow();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 延迟关闭窗体
*/
private void delayedCloseWindow() {
itemView.postDelayed(new Runnable() {
@Override
public void run() {
V2XPushEventScenario.getInstance().close();
}
}, 1000);
}
/**
* 导航规划路线
*/
private void startNavi() {
if (mV2XRoadEventEntity != null) {
MogoLatLng endPoint = new MogoLatLng(mV2XRoadEventEntity.getLat(), mV2XRoadEventEntity.getLon());
V2XServiceManager.getNavi().naviTo(endPoint);
V2XServiceManager.getMogoRegisterCenter().unregisterMogoNaviListener(MODULE_NAME);
V2XServiceManager.getMogoRegisterCenter().registerMogoNaviListener(MODULE_NAME, this);
delayedCloseWindow();
}
}
private void showTip(String msg) {
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
View toastView = LayoutInflater.from(V2XServiceManager.getContext()).inflate(R.layout.toast_view, null);
TextView msgView = toastView.findViewById(R.id.tvFeedbackContent);
msgView.setText(msg);
ToastUtils.showCustomShort(toastView);
}
@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) {
}
}

View File

@@ -0,0 +1,435 @@
package com.mogo.module.v2x.adapter.holder;
import android.content.Intent;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.elegant.utils.ArrayUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XUserInfoRes;
import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.common.entity.V2XLiveCarInfoEntity;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWindowTypeEnum;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.scenario.scene.livecar.V2XRoadLiveCarScenario;
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventWindow;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.utils.EventTypeUtils;
import com.mogo.module.v2x.utils.RoadConditionUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.TrackUtils;
import com.mogo.module.v2x.utils.V2XUtils;
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.imageloader.MogoImageView;
import com.mogo.utils.DateTimeUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:35 PM
* desc : 道路事件详情
* version: 1.0
*/
public class V2XRoadEventDetailVH extends RecyclerView.ViewHolder {
private MogoImageView ivEventImg;
private MogoImageView ivReportHead;
private ImageView ivEventPlay;
// 控制按钮
private TextView tvEventTypeTitle;
private TextView tvEventAddress;
private TextView tvEventDistance;
private TextView tvEventTime;
private ImageView ivEventLive;
private ImageView ivEventCallChart;
private ImageView ivEventReportTrue;
private ImageView ivEventReportErr;
private ImageView ivEventZan;
// 上传事件的用户信息
private MarkerUserInfo mUserInfo = new MarkerUserInfo();
// 当前的新鲜事儿信息
private MarkerExploreWay mNoveltyInfo;
private V2XRoadEventEntity mV2XRoadEventEntity;
private V2XEventShowEntity mV2XEventShowEntity;
// 拨打车聊聊语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackCallListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
roadCallChart(mNoveltyInfo);
}
};
// 点赞语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackLickListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
handlerZan(mNoveltyInfo);
}
};
// 反馈"正确"语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackReportTrueListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
roadReportTrue(mNoveltyInfo);
}
};
// 反馈"错误"语音回调
private V2XVoiceCallbackListener v2XVoiceCallbackReportErrorListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
roadReportErr(mNoveltyInfo);
}
};
// 反馈"错误"语音回调
private V2XVoiceCallbackListener v2XVoiceOpenLiveListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
showLiveCar(mV2XEventShowEntity);
}
};
private void init(View itemView) {
ivEventImg = itemView.findViewById(R.id.ivEventImg);
ivReportHead = itemView.findViewById(R.id.ivEventHead);
ivEventPlay = itemView.findViewById(R.id.ivEventPlay);
tvEventTypeTitle = itemView.findViewById(R.id.tvEventTypeTitle);
tvEventAddress = itemView.findViewById(R.id.tvEventAddress);
tvEventDistance = itemView.findViewById(R.id.tvEventDistance);
tvEventTime = itemView.findViewById(R.id.tvEventTime);
ivEventLive = itemView.findViewById(R.id.ivEventLive);
ivEventCallChart = itemView.findViewById(R.id.ivEventCallChart);
ivEventZan = itemView.findViewById(R.id.ivEventZan);
ivEventReportTrue = itemView.findViewById(R.id.ivEventReportTrue);
ivEventReportErr = itemView.findViewById(R.id.ivEventReportErr);
}
public V2XRoadEventDetailVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_v2x_event_detail, viewGroup, false));
init(itemView);
// 设置视图状态监听
itemView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
// Logger.w(MODULE_NAME, "列表View V2XRoadEventDetailVH 触发 onViewAttachedToWindow");
// 注册语音交互
V2XVoiceManager.INSTANCE
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_CHATTING,
v2XVoiceCallbackCallListener)
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_ZAN,
v2XVoiceCallbackLickListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_CHAT_MORE_UN_WAKEUP,
v2XVoiceCallbackCallListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_ZAN_UN_WAKEUP,
v2XVoiceCallbackLickListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_TRUE,
v2XVoiceCallbackReportTrueListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_V2X_TO_FEEDBACK_ERROR,
v2XVoiceCallbackReportErrorListener);
}
@Override
public void onViewDetachedFromWindow(View v) {
// Logger.w(MODULE_NAME, "列表View V2XRoadEventDetailVH 触发 onViewDetachedFromWindow");
}
});
}
public void initView(V2XEventShowEntity v2XEventShowEntity) {
try {
if (v2XEventShowEntity == null) {
return;
}
mV2XEventShowEntity = v2XEventShowEntity;
mV2XRoadEventEntity = v2XEventShowEntity.getV2XRoadEventEntity();
if (mV2XRoadEventEntity == null) {
return;
}
mNoveltyInfo = mV2XRoadEventEntity.getNoveltyInfo();
if (mNoveltyInfo != null) {
//Logger.d(MODULE_NAME, "mContentData" + mContentData);
if (!ArrayUtils.isEmpty(mNoveltyInfo.getItems())) {
String imgUrl = mNoveltyInfo.getItems().get(0).getThumbnail();
if (TextUtils.isEmpty(imgUrl)) {
imgUrl = mNoveltyInfo.getItems().get(0).getUrl();
}
if (!TextUtils.isEmpty(imgUrl)) {
V2XServiceManager.getImageLoader()
.displayImage(imgUrl, ivEventImg);
}
}
if (mNoveltyInfo.getUserInfo() != null &&
!TextUtils.isEmpty(mNoveltyInfo.getUserInfo().getUserHead())) {
V2XServiceManager.getImageLoader()
.displayImage(mNoveltyInfo.getUserInfo().getUserHead(), ivReportHead);
}
String poiType = EventTypeUtils.getPoiTypeStr(mNoveltyInfo.getPoiType());
if (!TextUtils.isEmpty(poiType)) {
tvEventTypeTitle.setText(poiType);
tvEventTypeTitle.setBackgroundResource(EventTypeUtils.getPoiTypeBg(mNoveltyInfo.getPoiType()));
}
tvEventAddress.setText(mNoveltyInfo.getAddr());
tvEventDistance.setText("距离 " + (int) mNoveltyInfo.getDistance() + "M");
Calendar c = Calendar.getInstance();
c.setTimeInMillis(mNoveltyInfo.getGenerateTime());
String eventTime = DateTimeUtils.printCalendarByPattern(c, "yyyy/MM/dd HH:mm");
if (!TextUtils.isEmpty(eventTime)) {
tvEventTime.setText(eventTime);
}
// 事件距离车辆小于50米的时候可以用户纠错
if (mV2XRoadEventEntity.getDistance() < 50) {
ivEventReportTrue.setVisibility(VISIBLE);
ivEventReportErr.setVisibility(VISIBLE);
ivEventLive.setVisibility(GONE);
ivEventZan.setVisibility(GONE);
} else {
if (!ArrayUtils.isEmpty(mV2XEventShowEntity.getV2XLiveCarList())) {
ivEventLive.setVisibility(VISIBLE);
V2XVoiceManager.INSTANCE
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_LIVE_ROAD,
v2XVoiceOpenLiveListener)
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_LIVE_UN_WAKEUP,
v2XVoiceOpenLiveListener);
ivEventLive.setOnClickListener(v -> {
showLiveCar(v2XEventShowEntity);
});
} else {
ivEventLive.setVisibility(GONE);
}
ivEventReportTrue.setVisibility(GONE);
ivEventReportErr.setVisibility(GONE);
ivEventZan.setVisibility(VISIBLE);
// 用户上报的才会展示拨打电话
if (!TextUtils.isEmpty(mNoveltyInfo.getUploadType())
&& mNoveltyInfo.getUploadType().equals("1")) {
requestUserInfo(mNoveltyInfo);
}
}
ivEventReportTrue.setOnClickListener(v -> {
roadReportTrue(mNoveltyInfo);
});
ivEventReportErr.setOnClickListener(v -> {
roadReportErr(mNoveltyInfo);
});
ivEventCallChart.setOnClickListener(v -> {
ivEventCallChart.setVisibility(GONE);
roadCallChart(mNoveltyInfo);
});
ivEventZan.setOnClickListener(v -> {
handlerZan(mNoveltyInfo);
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 展示直播信息
*
* @param v2XEventShowEntity
*/
private void showLiveCar(V2XEventShowEntity v2XEventShowEntity) {
if (v2XEventShowEntity != null) {
// 展示周边的直播车辆
List<V2XEventShowEntity> eventShowEntityArrayList = new ArrayList<>();
for (V2XLiveCarInfoEntity v2XLiveCarInfoRes : v2XEventShowEntity.getV2XLiveCarList()) {
V2XEventShowEntity showEntity = new V2XEventShowEntity();
showEntity.setViewType(V2XWindowTypeEnum.LIVE_CAR_WINDOW);
showEntity.setV2XLiveCarInfoRes(v2XLiveCarInfoRes);
showEntity.setV2XRoadEventEntity(mV2XRoadEventEntity);
eventShowEntityArrayList.add(showEntity);
}
Logger.d(MODULE_NAME, "要展示的直播:" + GsonUtil.jsonFromObject(eventShowEntityArrayList));
V2XMessageEntity<List<V2XEventShowEntity>> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_LIVE_CAR_WARNING);
v2XMessageEntity.setContent(eventShowEntityArrayList);
v2XMessageEntity.setShowState(true);
V2XRoadLiveCarScenario.getInstance().init(v2XMessageEntity);
// 打开直播后,窗口倒计时暂停关闭,直播被关闭后继续倒计时
V2XRoadEventWindow window = (V2XRoadEventWindow) V2XRoadEventScenario.getInstance().getV2XWindow();
window.stopCountDown();
}
}
private void requestUserInfo(MarkerExploreWay noveltyInfo) {
Logger.d(MODULE_NAME, "上报事件的用户SN" + noveltyInfo.getSn());
// 获取道路事件周边的直播车机
if (!TextUtils.isEmpty(noveltyInfo.getSn())) {
V2XServiceManager
.getV2XRefreshModel()
.queryUserInfoBySn(
noveltyInfo.getSn(),
new V2XRefreshCallback<V2XUserInfoRes>() {
@Override
public void onSuccess(V2XUserInfoRes result) {
if (result != null && result.getResult() != null && result.getResult().getInfo() != null) {
V2XUserInfoRes.Result.Info infoBean = result.getResult().getInfo();
if (mUserInfo == null) {
mUserInfo = new MarkerUserInfo();
}
mUserInfo.setSn(infoBean.getSn());
try {
if (!TextUtils.isEmpty(infoBean.getCardIdAge())) {
mUserInfo.setAge(Integer.parseInt(infoBean.getCardIdAge()));
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
mUserInfo.setUserName(infoBean.getUserNickName());
mUserInfo.setUserHead(infoBean.getHeadImgUrl());
mUserInfo.setGender(infoBean.getCardIdSex());
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
// 判断是否可以打电话
ChartingUtil.isCanCall(b -> {
if (b) {
// 判断是否可以打电话
ChartingUtil.isOnLine(mUserInfo.getSn(), b1 -> {
if (b1) {
ivEventCallChart.setVisibility(VISIBLE);
} else {
ivEventCallChart.setVisibility(GONE);
}
});
} else {
ivEventCallChart.setVisibility(GONE);
}
});
}
}
}
@Override
public void onFail(String msg) {
ivEventCallChart.setVisibility(GONE);
}
});
}
}
/**
* 打电话
*/
private void roadCallChart(MarkerExploreWay noveltyInfo) {
MarkerLocation location = new MarkerLocation();
mUserInfo.setSn(noveltyInfo.getSn());
ChartingUtil.callChatting(mUserInfo, location);
TrackUtils.trackV2xRoadEvent(noveltyInfo.getInfoId(), noveltyInfo.getUserInfo().getSn(), V2XConst.V2X_ROAD_CHAT);
}
/**
* 反馈路况错误
*/
private void roadReportErr(MarkerExploreWay noveltyInfo) {
if (noveltyInfo != null) {
RoadConditionUtils.sendDataErrorReceiverInfo(
noveltyInfo.getPoiType(),
noveltyInfo.getInfoId(),
"1");
TrackUtils.trackV2xRoadEvent(noveltyInfo.getInfoId(), noveltyInfo.getUserInfo().getSn(), V2XConst.V2X_ROAD_REPORT_ERROR);
}
delayedCloseWindow();
}
/**
* 反馈路况正确
*/
private void roadReportTrue(MarkerExploreWay noveltyInfo) {
if (noveltyInfo != null) {
RoadConditionUtils.sendDataErrorReceiverInfo(
noveltyInfo.getPoiType(),
noveltyInfo.getInfoId(),
"2");
TrackUtils.trackV2xRoadEvent(noveltyInfo.getInfoId(), noveltyInfo.getUserInfo().getSn(), V2XConst.V2X_ROAD_REPORT_RIGHT);
}
delayedCloseWindow();
}
/**
* 点赞
*/
private void handlerZan(MarkerExploreWay noveltyInfo) {
try {
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已点赞", null);
showTip("已点赞");
if (noveltyInfo != null) {
V2XServiceManager.getV2XMarkerService()
.getV2XRefreshModel()
.giveLikeLiveVideo(null, noveltyInfo.getSn());
}
delayedCloseWindow();
} catch (Exception e) {
e.printStackTrace();
}
TrackUtils.trackV2xRoadEvent(noveltyInfo.getInfoId(), noveltyInfo.getUserInfo().getSn(), V2XConst.V2X_ROAD_ZAN);
}
/**
* 延迟关闭窗体
*/
private void delayedCloseWindow() {
itemView.postDelayed(new Runnable() {
@Override
public void run() {
// 移除窗体
V2XServiceManager
.getIMogoWindowManager()
.removeView(V2XRoadEventScenario.getInstance().getV2XWindow().getView());
V2XRoadEventScenario.getInstance().close();
}
}, 1000);
}
private void showTip(String msg) {
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
View toastView = LayoutInflater.from(V2XServiceManager.getContext()).inflate(R.layout.toast_view, null);
TextView msgView = toastView.findViewById(R.id.tvFeedbackContent);
msgView.setText(msg);
ToastUtils.showCustomShort(toastView);
}
}

View File

@@ -0,0 +1,408 @@
package com.mogo.module.v2x.alarm;
import android.text.TextUtils;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.search.geo.IMogoGeoSearchListener;
import com.mogo.map.search.geo.MogoGeocodeResult;
import com.mogo.map.search.geo.MogoPoiItem;
import com.mogo.map.search.geo.MogoRegeocodeResult;
import com.mogo.map.search.poisearch.IMogoPoiSearch;
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
import com.mogo.map.search.poisearch.MogoPoiResult;
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.service.Utils;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.FatigueDrivingUtils;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.module.v2x.utils.TimeConstants;
import com.mogo.module.v2x.utils.TimeUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.utils.ArrayUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
import com.zhidao.utils.common.GsonUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.CopyOnWriteArrayList;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/13 11:02 AM
* desc :
* 这里是车机端自己实现预警信息的触发操作首先获取当前车位置周围2公里范围的道路事件
* 普通模式根据当前「车辆位置」及「行驶方向」判断「车辆前方」「500米」是否有道路事件需要触发。
* 导航模式根据当前「路径规划」及「行驶方向」判断「路径前方」「500米」是否有道路事件需要触发。
* version: 1.0
*/
public class V2XAlarmServer {
// 记录道路播报的事件
private static HashMap<V2XRoadEventEntity, String> mAlertRoadEventList = new HashMap<>();
private static HashSet<V2XRoadEventEntity> mAlertRoadEventCorrectionList = new HashSet<>();
// 记录违章停车播报事件
private static HashMap<MarkerExploreWay, String> mAlertIllegalParkEventList = new HashMap<>();
// 记录疲劳驾驶播报的事件
private static HashSet<String> mV2XFatigueDrivingEventLevel = new HashSet<>();
/**
* 获取当前车辆前方距离最近的道路事件
*/
public static V2XRoadEventEntity getDriveFrontAlarmEvent(
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
MogoLocation currentLocation) {
try {
// Logger.w(MODULE_NAME, "V2X预警--车辆状态:" + currentLocation);
// Logger.w(MODULE_NAME, "V2X预警--车辆速度:" + currentLocation.getSpeed());
// Logger.w(MODULE_NAME, "V2X预警--v2XRoadEventEntityList" + GsonUtil.jsonFromObject(v2XRoadEventEntityList));
// 60(km/h)
if (currentLocation != null && v2XRoadEventEntityList != null) {
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
for (V2XRoadEventEntity v2XRoadEventEntity : v2XRoadEventEntityList) {
// 先计算当前车辆的车头朝向是否与事件方向相同这里采用的是区间值只要在20度上下即可使用
// 道路事件必须有朝向,角度>=0;
//Logger.w(MODULE_NAME,
// "V2X预警--车辆与事件信息:" +
// "\n事件名称" + markerNoveltyInfo.getNoveltyInfo().getContentData().getTitle() +
// "\n事件角度" + markerNoveltyInfo.getLocation().getAngle() +
// "\n车头角度" + currentLocation.getAngle() +
// "\n角度差值" + Math.abs(currentLocation.getAngle() - markerNoveltyInfo.getLocation().getAngle()));
if (v2XRoadEventEntity.getLocation().getAngle() >= 0 &&
Math.abs(currentLocation.getBearing() - v2XRoadEventEntity.getLocation().getAngle()) <= 10) {
// 计算车辆距离指定气泡的距离
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
// 判断是否到达了触发距离,20 ~ 500,
if (v2XRoadEventEntity.getDistance() <= 500) {
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
currentLocation.getLongitude(),
currentLocation.getLatitude(),
eventLocation.getLon(),
eventLocation.getLat(),
(int) currentLocation.getBearing()
);
// Logger.w(MODULE_NAME, "V2X预警--事件位置===" + eventLocation);
if (0 <= eventAngle && eventAngle <= 20) {
// 判断是否已经提示过道路事件
boolean isAlreadyAlert = false;
String lastTime = mAlertRoadEventList.get(v2XRoadEventEntity);
if (!TextUtils.isEmpty(lastTime)) {
long timeSpan = TimeUtils.getTimeSpanByNow(lastTime, TimeConstants.MIN);
// Logger.w(MODULE_NAME,
// "V2X预警--事件ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n上一次预警时间" + lastTime +
// "\n距离当前时间" + timeSpan);
// 5分钟内不重复提醒
if (timeSpan < 5) {
isAlreadyAlert = true;
}
}
// 判断是否是纠错,如果是纠错就忽略掉带有时间段的道路提醒
if (v2XRoadEventEntity.getDistance() <= 50) {
if (!mAlertRoadEventCorrectionList.contains(v2XRoadEventEntity)) {
mAlertRoadEventCorrectionList.add(v2XRoadEventEntity);
isAlreadyAlert = false;
}
}
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n是否已经提醒" + isAlreadyAlert +
// "\n事件ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n事件详情" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo())
// );
// 进行提醒
if (!isAlreadyAlert) {
mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
return v2XRoadEventEntity;
}
return null;
} else {
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n角度" + eventAngle + " 度" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
} else {
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
} else {
// Logger.w(MODULE_NAME,
// "车头方向: " + currentLocation.getAngle() +
// "\n事件方向" + v2XRoadEventEntity.getLocation().getAngle()
// );
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 疲劳驾驶的展示数据
* 分级说明:
* 1驾驶时段 0-2小时为正常状态
* 2驾驶时段2-3小时为轻度疲劳
* 3驾驶时段3-4小时为中度疲劳
* 4驾驶时段4小时以上为重度疲劳
*/
public static void getFatigueDrivingShow(MogoLocation location, OnFatigueDrivingListener onFatigueDrivingListener) {
try {
long drivingTime = FatigueDrivingUtils.getDrivingTime();
//Logger.i(V2XConst.MODULE_NAME, "车机已经开机: " + drivingTime + " 分钟");
V2XStrategyPushRes.ResultBean strategyPushEntity =
GsonUtil.objectFromJson(SharedPrefsMgr.getInstance(V2XUtils.getApp())
.getString(V2XConst.V2X_STRATEGY_PUSH), V2XStrategyPushRes.ResultBean.class);
V2XPushMessageEntity drivingShowEntity = new V2XPushMessageEntity();
drivingShowEntity.setSceneId(V2XPoiTypeEnum.ALERT_FATIGUE_DRIVING);
if (strategyPushEntity != null &&
!ArrayUtils.isEmpty(strategyPushEntity.getLevelList())) {
for (V2XStrategyPushRes.ResultBean.LevelListBean levelListBean :
strategyPushEntity.getLevelList()) {
// 找到当前驾驶时常对应的疲劳等级
if (drivingTime >= levelListBean.getMinMinute()
&& drivingTime < levelListBean.getMaxMinute()) {
//疲劳等级NORMAL-正常、SLIGHT-轻度、MODERATE-中度、SEVERE-重度
switch (levelListBean.getLevel()) {
//正常
case "NORMAL":
Logger.d(MODULE_NAME, "驾驶疲劳程度: 正常");
break;
//轻度
case "SLIGHT":
Logger.w(MODULE_NAME, "驾驶疲劳程度: 轻度");
if (!mV2XFatigueDrivingEventLevel.contains("SLIGHT")) {
mV2XFatigueDrivingEventLevel.add("SLIGHT");
drivingShowEntity.setShowWindow(false);
drivingShowEntity.setAlarmContent(levelListBean.getContent());
drivingShowEntity.setTts(levelListBean.getTts());
drivingShowEntity.setExpireTime(levelListBean.getShowSeconds());
// 回调提醒
if (onFatigueDrivingListener != null) {
onFatigueDrivingListener.onAlarmMessage(drivingShowEntity);
}
}
break;
//中度
case "MODERATE":
Logger.e(MODULE_NAME, "驾驶疲劳程度: 中度");
warningParkPoi(location, onFatigueDrivingListener, drivingShowEntity, levelListBean);
break;
//重度
case "SEVERE":
Logger.e(MODULE_NAME, "驾驶疲劳程度: 重度");
break;
default:
Logger.e(MODULE_NAME, "驾驶疲劳程度: 超出定义范围");
break;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 提醒停车
private static void warningParkPoi(MogoLocation location,
OnFatigueDrivingListener onFatigueDrivingListener,
V2XPushMessageEntity drivingShowEntity,
V2XStrategyPushRes.ResultBean.LevelListBean levelListBean) {
if (!mV2XFatigueDrivingEventLevel.contains("MODERATE")) {
mV2XFatigueDrivingEventLevel.add("MODERATE");
// 定位当前位置是否是高速
LocationUtils.geoCodeSearch(location, new IMogoGeoSearchListener() {
@Override
public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) {
Logger.i(MODULE_NAME, "根据经纬度查询结果为:" + regeocodeResult.getRegeocodeAddress().getFormatAddress());
String keyword = "停车场";
boolean isHighWay = false;
// 如果当前位置是高速则推荐服务区
if (regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("高速")) {
keyword = "停车场|服务区";
isHighWay = true;
}
MogoPoiSearchQuery poiSearchQuery = new MogoPoiSearchQuery(keyword, keyword);
poiSearchQuery.setPageSize(5);
poiSearchQuery.setLocation(LocationUtils.getCurrentLatLon());
IMogoPoiSearch poiSearch = V2XServiceManager.getMapService().getPoiSearch(V2XUtils.getApp(), poiSearchQuery);
boolean finalIsHighWay = isHighWay;
poiSearch.setPoiSearchListener(new IMogoPoiSearchListener() {
@Override
public void onPoiSearched(MogoPoiResult result, int errorCode) {
Logger.i(MODULE_NAME, "附近的停车场/服务区:" + GsonUtil.jsonFromObject(result));
drivingShowEntity.setAlarmContent(levelListBean.getContent());
ArrayList<MogoPoiItem> pois = result.getPois();
if (pois.size() > 0) {
MogoPoiItem mogoPoiItem = getFrontPoi(finalIsHighWay, pois, location);
Logger.e(MODULE_NAME, "推荐车头前方最近的停车场/服务区:" + GsonUtil.jsonFromObject(mogoPoiItem));
if (mogoPoiItem != null) {
drivingShowEntity.setExpireTime(levelListBean.getShowSeconds());
drivingShowEntity.setShowWindow(true);
drivingShowEntity.setTts(levelListBean.getTts());
drivingShowEntity.setLon(mogoPoiItem.getPoint().getLon());
drivingShowEntity.setLat(mogoPoiItem.getPoint().getLat());
drivingShowEntity.setAddress(mogoPoiItem.getTitle());
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(mogoPoiItem.getPoint().getLat(), mogoPoiItem.getPoint().getLon()),
LocationUtils.getCurrentLatLon()
);
drivingShowEntity.setDistance(calculateDistance);
} else {
drivingShowEntity.setShowWindow(false);
drivingShowEntity.setTts(levelListBean.getNoReTts());
}
} else {
drivingShowEntity.setShowWindow(false);
drivingShowEntity.setTts(levelListBean.getNoReTts());
}
// 回调提醒
if (onFatigueDrivingListener != null) {
onFatigueDrivingListener.onAlarmMessage(drivingShowEntity);
}
}
@Override
public void onPoiItemSearched(MogoPoiItem item, int errorCode) {
}
});
poiSearch.searchPOIAsyn();
}
@Override
public void onGeocodeSearched(MogoGeocodeResult geocodeResult) {
}
});
}
}
public interface OnFatigueDrivingListener {
void onAlarmMessage(V2XPushMessageEntity drivingShowEntity);
}
// 计算出与车头朝向相同的poi点
public static MogoPoiItem getFrontPoi(boolean isHighWay, ArrayList<MogoPoiItem> pois, MogoLocation location) {
if (location != null && pois != null) {
// (高速道路)推荐道路前方180度服务区限定30公里
// (非高速推荐停车场限定5公里内
for (MogoPoiItem poiItem : pois) {
// 计算距离
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(poiItem.getPoint().getLat(), poiItem.getPoint().getLon()),
LocationUtils.getCurrentLatLon()
);
Logger.e(MODULE_NAME, "车辆距离POI点距离" + calculateDistance);
Logger.e(MODULE_NAME, "当前车辆是否在高速:" + isHighWay);
if (isHighWay) {
if (calculateDistance > 100 && calculateDistance < 30000) {
// 计算角度
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
location.getLongitude(),
location.getLatitude(),
poiItem.getPoint().getLon(),
poiItem.getPoint().getLat(),
(int) location.getBearing()
);
Logger.e(MODULE_NAME, "车辆距离POI角度" + eventAngle);
// 车辆前方180度
if (0 <= eventAngle && eventAngle <= 90) {
return poiItem;
}
}
} else {
if (calculateDistance < 5000) {
return poiItem;
}
}
}
}
return null;
}
/**
* 获取车辆的前方的违章停车事件
*/
public static MarkerExploreWay getIllegalParkAlarmEvent(
ArrayList<MarkerExploreWay> v2XExploreWayEntityList,
MogoLocation currentLocation) {
try {
Logger.w(MODULE_NAME, "V2X预警--车辆状态:" + currentLocation);
// 60(km/h)
if (currentLocation != null && v2XExploreWayEntityList != null) {
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
for (MarkerExploreWay markerExploreWay : v2XExploreWayEntityList) {
// 计算车辆距离
float distance = Utils.calculateLineDistance(
new MogoLatLng(markerExploreWay.getLocation().getLat(), markerExploreWay.getLocation().getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
Logger.w(MODULE_NAME, "V2X预警--车辆与违章道路信息:" +
"\n当前车辆距离违章停车点" + distance);
// 判断是否到达了触发距离,50 米
if (distance <= 50) {
Logger.w(MODULE_NAME, "V2X预警--车辆与违章道路信息:" +
"\n违章道路名称" + markerExploreWay.getAddr() +
"\n车头角度" + currentLocation.getBearing());
// 判断是否已经提示过道路事件
boolean isAlreadyAlert = false;
String lastTime = mAlertIllegalParkEventList.get(markerExploreWay);
Logger.w(MODULE_NAME,
"V2X预警--事件ID" + markerExploreWay.getInfoId() +
"\n上一次预警时间" + lastTime);
if (!TextUtils.isEmpty(lastTime)) {
long timeSpan = TimeUtils.getTimeSpanByNow(lastTime, TimeConstants.MIN);
Logger.w(MODULE_NAME,
"V2X预警--事件ID" + markerExploreWay.getInfoId() +
"\n距离当前时间" + timeSpan);
// 5分钟内不重复提醒
if (timeSpan < 5) {
isAlreadyAlert = true;
}
}
// 进行提醒
if (!isAlreadyAlert) {
mAlertIllegalParkEventList.put(markerExploreWay, TimeUtils.getNowString());
return markerExploreWay;
}
return null;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -0,0 +1,150 @@
package com.mogo.module.v2x.alarm;
import android.os.Handler;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XStatusManager;
import com.mogo.module.v2x.listener.CarStatusListener;
import com.mogo.utils.logger.Logger;
import java.util.HashMap;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/13 11:02 AM
* desc :
* 这里充当计算服务
* 计算 当前 车速变化回调、方向角度
* version: 1.0
*/
public class V2XCalculateServer {
private static final String TAG = "V2XCalculateServer";
// 当前的车辆位置,主要用 经纬度,角度,速度
private static MogoLocation mCurrentLocation;
// 是否处于停车状态
private static boolean mIsPark = true;
// 没有行驶的次数
private static int mNoDriveCount = 0;
private static HashMap<String, CarStatusListener> mCarStatusListener = new HashMap<>();
private static V2XCalculateServer mV2XCalculateServer;
// 一分钟获取一次最新的路况信息
private static final int refreshTime = 5_000;
private static Handler refreshHandler;
private static Runnable refreshRunnable;
private V2XCalculateServer() {
}
public synchronized static V2XCalculateServer getInstance() {
synchronized (V2XCalculateServer.class) {
if (mV2XCalculateServer == null) {
mV2XCalculateServer = new V2XCalculateServer();
if (refreshHandler == null) {
refreshHandler = new Handler();
}
if (refreshRunnable == null) {
refreshRunnable = new Runnable() {
@Override
public void run() {
calculateCarStatus();
refreshHandler.postDelayed(this, refreshTime);
}
};
}
refreshHandler.post(refreshRunnable);
}
}
return mV2XCalculateServer;
}
/**
* 添加车辆状态监听
*
* @param tag 标记
* @param carStatusListener 回调
*/
public void addCarStatusListener(String tag, CarStatusListener carStatusListener) {
if (mCarStatusListener == null) {
mCarStatusListener = new HashMap<>();
}
mCarStatusListener.put(tag, carStatusListener);
}
/**
* 移除指定的标记的回调
*
* @param tag 标记
*/
public void removeCarStatusListener(String tag) {
if (mCarStatusListener != null) {
mCarStatusListener.remove(tag);
}
}
/**
* 记录车辆行驶轨迹
*
* @param location 车辆位置
*/
public void addCarTrajectory(MogoLocation location) {
// 记录最后一次车辆位置信息
mCurrentLocation = location;
// 车辆状态计算
calculateCarStatus();
}
/**
* 计算车辆状态
*/
private static void calculateCarStatus() {
if (mCurrentLocation != null) {
// 获取当前的车速
float currentSpeed = mCurrentLocation.getSpeed();
// Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "车辆状态:" +
// "\n当前车辆位置->" + V2XStatusManager.getInstance().getLocation().getAddress() +
// "\ncurrentSpeed 速度->" + currentSpeed +
// "\n车辆行驶状态mIsPark->" + mIsPark +
// "\nmNoDriveCount->" + mNoDriveCount);
// 获取没有车速
if (currentSpeed == 0) {
// 防止重复播报
if (!mIsPark) {
// 超过 2 次的速度为 0 ,判定为 行驶->停止
if ((++mNoDriveCount) > 2) {
if (mCarStatusListener != null) {
Logger.d(V2XConst.MODULE_NAME, "车辆状态:车辆从 行驶->停止");
mIsPark = true;
for (CarStatusListener statusListener : mCarStatusListener.values()) {
statusListener.onCarDriving2Stop(mCurrentLocation);
}
}
}
}
}
// 获取到了车速 大于 3m/s = 10公里/小时 判定为行驶状态
else if (currentSpeed > 3) {
mNoDriveCount = 0;
if (mIsPark) {
if (mCarStatusListener != null) {
Logger.d(V2XConst.MODULE_NAME, "车辆状态:车辆从 停止->行驶");
mIsPark = false;
for (CarStatusListener statusListener : mCarStatusListener.values()) {
statusListener.onCarStop2Driving(mCurrentLocation);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,280 @@
package com.mogo.module.v2x.entity.net;
import android.text.TextUtils;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.mogo.commons.data.BaseData;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerOnlineCar;
import java.io.Serializable;
import java.util.ArrayList;
@SuppressWarnings("unused")
public class V2XAlarmEventRes extends BaseData implements Serializable {
@Expose
private Result result;
public Result getResult() {
return result;
}
public void setResult(Result result) {
this.result = result;
}
public class Result {
@Expose
@SerializedName(value = "recommendInfo", alternate = {"alarmInfo"})
private AlarmInfo alarmInfo;
@Expose
private ArrayList<MarkerOnlineCar> onlineCar;
public ArrayList<MarkerOnlineCar> getOnlineCar() {
return onlineCar;
}
public void setOnlineCar(ArrayList<MarkerOnlineCar> onlineCar) {
this.onlineCar = onlineCar;
}
public AlarmInfo getAlarmInfo() {
return alarmInfo;
}
public void setAlarmInfo(AlarmInfo alarmInfo) {
this.alarmInfo = alarmInfo;
}
@Override
public String toString() {
return "Result{" +
"alarmInfo=" + alarmInfo +
", onlineCar=" + onlineCar +
'}';
}
}
public static class AlarmInfo {
@Expose
private ContentData contentData;
@Expose
private Double distance;
@Expose
private MarkerLocation location;
@Expose
private String poiType;
@Expose
private String tts;
@Expose
private String type;
@Expose
private String alarmContent;
@Expose
private int expireTime;
@Expose
private int parkingSpaceSurplusNum;
public ContentData getContentData() {
return contentData;
}
public void setContentData(ContentData contentData) {
this.contentData = contentData;
}
public Double getDistance() {
return distance;
}
public void setDistance(Double distance) {
this.distance = distance;
}
public MarkerLocation getLocation() {
return location;
}
public void setLocation(MarkerLocation location) {
this.location = location;
}
public String getPoiType() {
if (TextUtils.isEmpty(poiType)) {
return "";
}
return poiType;
}
public void setPoiType(String poiType) {
this.poiType = poiType;
}
public String getTts() {
if (TextUtils.isEmpty(tts)) {
return "";
}
return tts;
}
public void setTts(String tts) {
this.tts = tts;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAlarmContent() {
return alarmContent;
}
public void setAlarmContent(String alarmContent) {
this.alarmContent = alarmContent;
}
public int getExpireTime() {
return expireTime;
}
public void setExpireTime(int expireTime) {
this.expireTime = expireTime;
}
public int getParkingSpaceSurplusNum() {
return parkingSpaceSurplusNum;
}
public void setParkingSpaceSurplusNum(int parkingSpaceSurplusNum) {
this.parkingSpaceSurplusNum = parkingSpaceSurplusNum;
}
@Override
public String toString() {
return "AlarmInfo{" +
"contentData=" + contentData +
", distance=" + distance +
", location=" + location +
", poiType='" + poiType + '\'' +
", tts='" + tts + '\'' +
", type='" + type + '\'' +
", alarmContent='" + alarmContent + '\'' +
", expireTime=" + expireTime +
", parkingSpaceSurplusNum=" + parkingSpaceSurplusNum +
'}';
}
}
public class ContentData {
@Expose
private String iconUrl;
@Expose
private String imgUrl;
@Expose
private String infoId = ""; // POI 唯一标示 「纠错」或「确认」「点赞」使用
@Expose
private String title;
@Expose
private String content;
@Expose
private String gasPrices;//"[{\"gasCode\":\"95\",\"gasPrice\":10.0},{\"gasCode\":\"98\",\"gasPrice\":23.0}]"
@Expose
private String styleType;// 内容类型image-图片类型video-视频类型
@Expose
private String carSn;// 如果是用户上报的,则需要返回该字段
public String getIconUrl() {
return iconUrl;
}
public void setIconUrl(String iconUrl) {
this.iconUrl = iconUrl;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getInfoId() {
return infoId;
}
public void setInfoId(String infoId) {
this.infoId = infoId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getGasPrices() {
return gasPrices;
}
public void setGasPrices(String gasPrices) {
this.gasPrices = gasPrices;
}
public String getStyleType() {
return styleType;
}
public void setStyleType(String styleType) {
this.styleType = styleType;
}
public String getCarSn() {
return carSn;
}
public void setCarSn(String carSn) {
this.carSn = carSn;
}
@Override
public String toString() {
return "ContentData{" +
"iconUrl='" + iconUrl + '\'' +
", imgUrl='" + imgUrl + '\'' +
", infoId='" + infoId + '\'' +
", title='" + title + '\'' +
", content='" + content + '\'' +
", gasPrices='" + gasPrices + '\'' +
", styleType='" + styleType + '\'' +
", carSn='" + carSn + '\'' +
'}';
}
}
@Override
public String toString() {
return "V2XAlarmEventMessage{" +
"result=" + result +
'}';
}
}

View File

@@ -0,0 +1,258 @@
package com.mogo.module.v2x.entity.net;
import com.mogo.commons.data.BaseData;
import java.io.Serializable;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/24 4:20 PM
* desc : TODO 前瞻需求演示使用的用户数据
* version: 1.0
*/
public class V2XDemoUserInfoRes extends BaseData implements Serializable {
/**
* code : 0
* msg :
* detailMsg :
* result : {"userList":[{"sceneType":"1","location":{"lat":39.97541,"lon":116.41782761},"userInfo":{"sn":"ZD801B1920L00818","userId":1,"userName":"用户昵称","userHead":"https://www.baidu.com/img/baidu_jgylogo3.png","gender":"男","age":20,"lastActiveweekAvgscore":"96","safeLabel":"老司机","safeLabelType":1}},{"sceneType":"2","location":{"lat":39.97541,"lon":116.41782761},"userInfo":{"sn":"ZD802B1932L00779","userId":1,"userName":"用户昵称","userHead":"https://www.baidu.com/img/baidu_jgylogo3.png","gender":"男","age":20,"lastActiveweekAvgscore":"96","safeLabel":"老司机","safeLabelType":1}},{"sceneType":"3","location":{"lat":39.97541,"lon":116.41782761},"userInfo":{"sn":"ZD802B1932L00779","userId":1,"userName":"用户昵称","userHead":"https://www.baidu.com/img/baidu_jgylogo3.png","gender":"男","age":20,"lastActiveweekAvgscore":"96","safeLabel":"老司机","safeLabelType":1}}]}
*/
private ResultBean result;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public static class ResultBean {
private List<UserListBean> userList;
public List<UserListBean> getUserList() {
return userList;
}
public void setUserList(List<UserListBean> userList) {
this.userList = userList;
}
public static class UserListBean {
/**
* sceneType : 1
* location : {"lat":39.97541,"lon":116.41782761}
* userInfo : {"sn":"ZD801B1920L00818","userId":1,"userName":"用户昵称","userHead":"https://www.baidu.com/img/baidu_jgylogo3.png","gender":"男","age":20,"lastActiveweekAvgscore":"96","safeLabel":"老司机","safeLabelType":1}
*/
private String sceneType;
private LocationBean location;
private UserInfoBean userInfo;
public String getSceneType() {
return sceneType;
}
public void setSceneType(String sceneType) {
this.sceneType = sceneType;
}
public LocationBean getLocation() {
return location;
}
public void setLocation(LocationBean location) {
this.location = location;
}
public UserInfoBean getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfoBean userInfo) {
this.userInfo = userInfo;
}
public static class LocationBean {
/**
* lat : 39.97541
* lon : 116.41782761
*/
private double lat;
private double lon;
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
@Override
public String toString() {
return "LocationBean{" +
"lat=" + lat +
", lon=" + lon +
'}';
}
}
public static class UserInfoBean {
/**
* sn : ZD801B1920L00818
* userId : 1
* userName : 用户昵称
* userHead : https://www.baidu.com/img/baidu_jgylogo3.png
* gender : 男
* age : 20
* lastActiveweekAvgscore : 96
* safeLabel : 老司机
* safeLabelType : 1
*/
private String sn;
private int userId;
private String userName;
private String userHead;
private String gender;
private int age;
private String lastActiveweekAvgscore;
private String safeLabel;
private int safeLabelType;
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserHead() {
return userHead;
}
public void setUserHead(String userHead) {
this.userHead = userHead;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getLastActiveweekAvgscore() {
return lastActiveweekAvgscore;
}
public void setLastActiveweekAvgscore(String lastActiveweekAvgscore) {
this.lastActiveweekAvgscore = lastActiveweekAvgscore;
}
public String getSafeLabel() {
return safeLabel;
}
public void setSafeLabel(String safeLabel) {
this.safeLabel = safeLabel;
}
public int getSafeLabelType() {
return safeLabelType;
}
public void setSafeLabelType(int safeLabelType) {
this.safeLabelType = safeLabelType;
}
@Override
public String toString() {
return "UserInfoBean{" +
"sn='" + sn + '\'' +
", userId=" + userId +
", userName='" + userName + '\'' +
", userHead='" + userHead + '\'' +
", gender='" + gender + '\'' +
", age=" + age +
", lastActiveweekAvgscore='" + lastActiveweekAvgscore + '\'' +
", safeLabel='" + safeLabel + '\'' +
", safeLabelType=" + safeLabelType +
'}';
}
}
@Override
public String toString() {
return "UserListBean{" +
"sceneType='" + sceneType + '\'' +
", location=" + location +
", userInfo=" + userInfo +
'}';
}
}
}
@Override
public String toString() {
return "V2XDemoUserInfoEntity{" +
"result=" + result +
'}';
}
}

View File

@@ -0,0 +1,52 @@
package com.mogo.module.v2x.entity.net;
import com.google.gson.annotations.Expose;
import java.io.Serializable;
@SuppressWarnings("unused")
public class V2XGiveLike implements Serializable {
@Expose
private Long code;
@Expose
private String msg;
@Expose
private String result;
@Expose
private String sign;
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}

View File

@@ -0,0 +1,25 @@
package com.mogo.module.v2x.entity.net
/**
* 直播心跳请求
*/
class V2XLiveCarBroadcastReq {
var eventId: String? = null
var sn: String
var type: Int = 0
var videoChannel: String
constructor(sn: String, videoChannel: String) {
this.sn = sn
this.videoChannel = videoChannel
}
constructor(eventId: String, sn: String, type: Int, videoChannel: String) {
this.eventId = eventId
this.sn = sn
this.type = type
this.videoChannel = videoChannel
}
}

View File

@@ -0,0 +1,56 @@
package com.mogo.module.v2x.entity.net;
import com.google.gson.annotations.Expose;
import com.mogo.commons.data.BaseData;
import com.mogo.module.common.entity.V2XLiveCarInfoEntity;
import java.io.Serializable;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/14 2:58 PM
* desc : 根据经纬度查询附近可直播车机直播信息
* version: 1.0
*/
public class V2XLiveCarRes extends BaseData implements Serializable {
@Expose
private ResultBean result;
public static class ResultBean {
private List<V2XLiveCarInfoEntity> info;
public List<V2XLiveCarInfoEntity> getInfo() {
return info;
}
public void setInfo(List<V2XLiveCarInfoEntity> info) {
this.info = info;
}
@Override
public String toString() {
return "ResultBean{" +
"info=" + info +
'}';
}
}
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
@Override
public String toString() {
return "V2XLiveCarRes{" +
"result=" + result +
'}';
}
}

View File

@@ -0,0 +1,113 @@
package com.mogo.module.v2x.entity.net;
import com.mogo.commons.data.BaseData;
import java.io.Serializable;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/16 1:43 PM
* desc : 推流与停止推流接口
* version: 1.0
*/
public class V2XLivePushVoRes extends BaseData implements Serializable {
public V2XLivePushVoEntity result;
public V2XLivePushVoEntity getResult() {
return result;
}
public void setResult(V2XLivePushVoEntity result) {
this.result = result;
}
@Override
public String toString() {
return "V2XLivePushVoRes{" +
"result=" + result +
", code=" + code +
", msg='" + msg + '\'' +
'}';
}
public class V2XLivePushVoEntity {
private String livePlayUrl;
private PlayUrl playUrl;
private String videoChannel;
public String getLivePlayUrl() {
return livePlayUrl;
}
public void setLivePlayUrl(String livePlayUrl) {
this.livePlayUrl = livePlayUrl;
}
public PlayUrl getPlayUrl() {
return playUrl;
}
public void setPlayUrl(PlayUrl playUrl) {
this.playUrl = playUrl;
}
public String getVideoChannel() {
return videoChannel;
}
public void setVideoChannel(String videoChannel) {
this.videoChannel = videoChannel;
}
public class PlayUrl {
private String flv;
private String hls;
private String rtmp;
public String getFlv() {
return flv;
}
public void setFlv(String flv) {
this.flv = flv;
}
public String getHls() {
return hls;
}
public void setHls(String hls) {
this.hls = hls;
}
public String getRtmp() {
return rtmp;
}
public void setRtmp(String rtmp) {
this.rtmp = rtmp;
}
@Override
public String toString() {
return "PlayUrl{" +
"flv='" + flv + '\'' +
", hls='" + hls + '\'' +
", rtmp='" + rtmp + '\'' +
'}';
}
}
@Override
public String toString() {
return "V2XLivePushVoEntity{" +
"livePlayUrl='" + livePlayUrl + '\'' +
", playUrl=" + playUrl +
", videoChannel='" + videoChannel + '\'' +
'}';
}
}
}

View File

@@ -0,0 +1,52 @@
package com.mogo.module.v2x.entity.net;
import com.mogo.commons.data.BaseData;
import java.io.Serializable;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/11 4:25 PM
* desc : 故障求助查询,当前车辆是否处于求助中
* version: 1.0
*/
public class V2XSeekHelpRes extends BaseData implements Serializable {
private ResultBean result;
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public static class ResultBean {
private int vehicleType;
public int getVehicleType() {
return vehicleType;
}
public void setVehicleType(int vehicleType) {
this.vehicleType = vehicleType;
}
@Override
public String toString() {
return "ResultBean{" +
"vehicleType=" + vehicleType +
'}';
}
}
@Override
public String toString() {
return "V2XSeekHelpResult{" +
"result=" + result +
", code=" + code +
", msg='" + msg + '\'' +
'}';
}
}

View File

@@ -0,0 +1,205 @@
package com.mogo.module.v2x.entity.net;
import java.io.Serializable;
import java.util.List;
@SuppressWarnings("unused")
public class V2XSpecialCarRes implements Serializable {
private List<V2XMarkerEntity> coordinates;
public List<V2XMarkerEntity> getCoordinates() {
return coordinates;
}
public void setCoordinates(List<V2XMarkerEntity> coordinates) {
this.coordinates = coordinates;
}
@Override
public String toString() {
return "V2XMarkerResult{" +
"coordinates=" + coordinates +
'}';
}
public class V2XMarkerEntity implements Serializable {
/**
* createTime : 1587111513507
* distance : 100
* lat : 39.96911187
* lon : 116.41777396
* sn : ZD802B1932L00681
* targetId : 20007
* targetName : 故障车
* userInfo : {"age":33,"displayName":"飞","headImgUrl":"http://img.zhidaohulian.com/fileServer/api/qa/user_info/1068057333299/67933ffb9a7e237c8cc2d8d9f66efcd0.jpg","sex":1,"sn":"ZD801B1920L00568","userId":1068057333299}
*/
private long createTime;
private int distance;
private double lat;
private double lon;
private String sn;
private int targetId;
private String targetName;
private V2XMarkerEntity.UserInfoBean userInfo;
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public int getTargetId() {
return targetId;
}
public void setTargetId(int targetId) {
this.targetId = targetId;
}
public String getTargetName() {
return targetName;
}
public void setTargetName(String targetName) {
this.targetName = targetName;
}
public V2XMarkerEntity.UserInfoBean getUserInfo() {
return userInfo;
}
public void setUserInfo(V2XMarkerEntity.UserInfoBean userInfo) {
this.userInfo = userInfo;
}
public class UserInfoBean implements Serializable {
/**
* age : 33
* displayName : 飞
* headImgUrl : http://img.zhidaohulian.com/fileServer/api/qa/user_info/1068057333299/67933ffb9a7e237c8cc2d8d9f66efcd0.jpg
* sex : 1
* sn : ZD801B1920L00568
* userId : 1068057333299
*/
private int age;
private String displayName;
private String headImgUrl;
private int sex;
private String sn;
private long userId;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "UserInfoBean{" +
"age=" + age +
", displayName='" + displayName + '\'' +
", headImgUrl='" + headImgUrl + '\'' +
", sex=" + sex +
", sn='" + sn + '\'' +
", userId=" + userId +
'}';
}
}
@Override
public String toString() {
return "V2XMarkerEntity{" +
"createTime=" + createTime +
", distance=" + distance +
", lat=" + lat +
", lon=" + lon +
", sn='" + sn + '\'' +
", targetId=" + targetId +
", targetName='" + targetName + '\'' +
", userInfo=" + userInfo +
'}';
}
}
}

View File

@@ -0,0 +1,253 @@
package com.mogo.module.v2x.entity.net;
import com.mogo.commons.data.BaseData;
import java.io.Serializable;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/26 2:30 PM
* desc : 疲劳驾驶提醒策略
* version: 1.0
*/
public class V2XStrategyPushRes extends BaseData implements Serializable {
/**
* result : {"levelList":[{"level":"NORMAL","minMinute":0,"maxMinute":120},{"content":"已连续驾驶2小时请注意休息","level":"SLIGHT","tts":"已连续驾驶2小时听歌可以缓解疲劳可以对我说打开音乐","showSeconds":15,"minMinute":120,"maxMinute":180},{"content":"已连续驾驶3小时请注意停车休息","highSpeed":{"recommend":"REST_AREA","direction":"FRONT","angle":180,"distance":30},"level":"MODERATE","lowSpeed":{"recommend":"PARK","direction":"FRONT","angle":180,"distance":5},"tts":"已连续驾驶3小时已为您找到附近服务区/停车场,请停车休息,可以对我说导航前往","showSeconds":20,"noReTts":"已连续驾驶3小时为避免事故发生请尽快进入停车区休息","minMinute":180,"maxMinute":240}],"drivingIgnoreMinutes":20,"restIgnoreMinutes":20}
*/
private ResultBean result;
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public static class ResultBean {
/**
* levelList : [{"level":"NORMAL","minMinute":0,"maxMinute":120},{"content":"已连续驾驶2小时请注意休息","level":"SLIGHT","tts":"已连续驾驶2小时听歌可以缓解疲劳可以对我说打开音乐","showSeconds":15,"minMinute":120,"maxMinute":180},{"content":"已连续驾驶3小时请注意停车休息","highSpeed":{"recommend":"REST_AREA","direction":"FRONT","angle":180,"distance":30},"level":"MODERATE","lowSpeed":{"recommend":"PARK","direction":"FRONT","angle":180,"distance":5},"tts":"已连续驾驶3小时已为您找到附近服务区/停车场,请停车休息,可以对我说导航前往","showSeconds":20,"noReTts":"已连续驾驶3小时为避免事故发生请尽快进入停车区休息","minMinute":180,"maxMinute":240}]
* drivingIgnoreMinutes : 20
* restIgnoreMinutes : 20
*/
private int drivingIgnoreMinutes;
private int restIgnoreMinutes;
private List<LevelListBean> levelList;
public int getDrivingIgnoreMinutes() {
return drivingIgnoreMinutes;
}
public void setDrivingIgnoreMinutes(int drivingIgnoreMinutes) {
this.drivingIgnoreMinutes = drivingIgnoreMinutes;
}
public int getRestIgnoreMinutes() {
return restIgnoreMinutes;
}
public void setRestIgnoreMinutes(int restIgnoreMinutes) {
this.restIgnoreMinutes = restIgnoreMinutes;
}
public List<LevelListBean> getLevelList() {
return levelList;
}
public void setLevelList(List<LevelListBean> levelList) {
this.levelList = levelList;
}
public static class LevelListBean {
/**
* level : NORMAL
* minMinute : 0
* maxMinute : 120
* content : 已连续驾驶2小时请注意休息
* tts : 已连续驾驶2小时听歌可以缓解疲劳可以对我说打开音乐
* showSeconds : 15
* highSpeed : {"recommend":"REST_AREA","direction":"FRONT","angle":180,"distance":30}
* lowSpeed : {"recommend":"PARK","direction":"FRONT","angle":180,"distance":5}
* noReTts : 已连续驾驶3小时为避免事故发生请尽快进入停车区休息
*/
private String level;
private int minMinute;
private int maxMinute;
private String content;
private String tts;
private int showSeconds;
private HighSpeedBean highSpeed;
private LowSpeedBean lowSpeed;
private String noReTts;
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public int getMinMinute() {
return minMinute;
}
public void setMinMinute(int minMinute) {
this.minMinute = minMinute;
}
public int getMaxMinute() {
return maxMinute;
}
public void setMaxMinute(int maxMinute) {
this.maxMinute = maxMinute;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTts() {
return tts;
}
public void setTts(String tts) {
this.tts = tts;
}
public int getShowSeconds() {
return showSeconds;
}
public void setShowSeconds(int showSeconds) {
this.showSeconds = showSeconds;
}
public HighSpeedBean getHighSpeed() {
return highSpeed;
}
public void setHighSpeed(HighSpeedBean highSpeed) {
this.highSpeed = highSpeed;
}
public LowSpeedBean getLowSpeed() {
return lowSpeed;
}
public void setLowSpeed(LowSpeedBean lowSpeed) {
this.lowSpeed = lowSpeed;
}
public String getNoReTts() {
return noReTts;
}
public void setNoReTts(String noReTts) {
this.noReTts = noReTts;
}
public static class HighSpeedBean {
/**
* recommend : REST_AREA
* direction : FRONT
* angle : 180
* distance : 30
*/
private String recommend;
private String direction;
private int angle;
private int distance;
public String getRecommend() {
return recommend;
}
public void setRecommend(String recommend) {
this.recommend = recommend;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public int getAngle() {
return angle;
}
public void setAngle(int angle) {
this.angle = angle;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
}
public static class LowSpeedBean {
/**
* recommend : PARK
* direction : FRONT
* angle : 180
* distance : 5
*/
private String recommend;
private String direction;
private int angle;
private int distance;
public String getRecommend() {
return recommend;
}
public void setRecommend(String recommend) {
this.recommend = recommend;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public int getAngle() {
return angle;
}
public void setAngle(int angle) {
this.angle = angle;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
}
}
}
}

View File

@@ -0,0 +1,344 @@
package com.mogo.module.v2x.entity.net;
import com.google.gson.annotations.Expose;
import com.mogo.commons.data.BaseData;
import java.io.Serializable;
public class V2XUserInfoRes extends BaseData implements Serializable {
@Expose
private Result result;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Result getResult() {
return result;
}
public void setResult(Result result) {
this.result = result;
}
public class Result {
@Expose
private Info info;
public Info getInfo() {
return info;
}
public void setInfo(Info info) {
this.info = info;
}
public class Info {
@Expose
private Long activeStatus;
@Expose
private Long bindStatus;
@Expose
private String bindType;
@Expose
private String bindUserId;
@Expose
private String erpSnGroup;
@Expose
private String erpSnType;
@Expose
private String iccid;
@Expose
private String ifCarcorder;
@Expose
private String ifImdemo;
@Expose
private String ifSocketservice;
@Expose
private String lastActiveCity;
@Expose
private Long lastBrandId;
@Expose
private String lastBrandName;
@Expose
private String lastCarNum;
@Expose
private String lastCarNumEn;
@Expose
private String lastFortaVersion;
@Expose
private Long lastModelId;
@Expose
private String lastModelName;
@Expose
private String sn;
@Expose
private String snGroupDetail;
@Expose
private String songTypeTop2;
@Expose
private String userNickName;
@Expose
private String cardIdAge;
@Expose
private String headImgUrl;
@Expose
private String cardIdSex;
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl;
}
public String getCardIdSex() {
return cardIdSex;
}
public void setCardIdSex(String cardIdSex) {
this.cardIdSex = cardIdSex;
}
public String getCardIdAge() {
return cardIdAge;
}
public void setCardIdAge(String cardIdAge) {
this.cardIdAge = cardIdAge;
}
public Long getActiveStatus() {
return activeStatus;
}
public void setActiveStatus(Long activeStatus) {
this.activeStatus = activeStatus;
}
public Long getBindStatus() {
return bindStatus;
}
public void setBindStatus(Long bindStatus) {
this.bindStatus = bindStatus;
}
public String getBindType() {
return bindType;
}
public void setBindType(String bindType) {
this.bindType = bindType;
}
public String getBindUserId() {
return bindUserId;
}
public void setBindUserId(String bindUserId) {
this.bindUserId = bindUserId;
}
@Override
public String toString() {
return "Info{" +
"activeStatus=" + activeStatus +
", bindStatus=" + bindStatus +
", bindType='" + bindType + '\'' +
", bindUserId='" + bindUserId + '\'' +
", erpSnGroup='" + erpSnGroup + '\'' +
", erpSnType='" + erpSnType + '\'' +
", iccid='" + iccid + '\'' +
", ifCarcorder='" + ifCarcorder + '\'' +
", ifImdemo='" + ifImdemo + '\'' +
", ifSocketservice='" + ifSocketservice + '\'' +
", lastActiveCity='" + lastActiveCity + '\'' +
", lastBrandId=" + lastBrandId +
", lastBrandName='" + lastBrandName + '\'' +
", lastCarNum='" + lastCarNum + '\'' +
", lastCarNumEn='" + lastCarNumEn + '\'' +
", lastFortaVersion='" + lastFortaVersion + '\'' +
", lastModelId=" + lastModelId +
", lastModelName='" + lastModelName + '\'' +
", sn='" + sn + '\'' +
", snGroupDetail='" + snGroupDetail + '\'' +
", songTypeTop2='" + songTypeTop2 + '\'' +
", userNickName='" + userNickName + '\'' +
", cardIdAge='" + cardIdAge + '\'' +
", headImgUrl='" + headImgUrl + '\'' +
", cardIdSex='" + cardIdSex + '\'' +
'}';
}
public String getErpSnGroup() {
return erpSnGroup;
}
public void setErpSnGroup(String erpSnGroup) {
this.erpSnGroup = erpSnGroup;
}
public String getErpSnType() {
return erpSnType;
}
public void setErpSnType(String erpSnType) {
this.erpSnType = erpSnType;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getIfCarcorder() {
return ifCarcorder;
}
public void setIfCarcorder(String ifCarcorder) {
this.ifCarcorder = ifCarcorder;
}
public String getIfImdemo() {
return ifImdemo;
}
public void setIfImdemo(String ifImdemo) {
this.ifImdemo = ifImdemo;
}
public String getIfSocketservice() {
return ifSocketservice;
}
public void setIfSocketservice(String ifSocketservice) {
this.ifSocketservice = ifSocketservice;
}
public String getLastActiveCity() {
return lastActiveCity;
}
public void setLastActiveCity(String lastActiveCity) {
this.lastActiveCity = lastActiveCity;
}
public Long getLastBrandId() {
return lastBrandId;
}
public void setLastBrandId(Long lastBrandId) {
this.lastBrandId = lastBrandId;
}
public String getLastBrandName() {
return lastBrandName;
}
public void setLastBrandName(String lastBrandName) {
this.lastBrandName = lastBrandName;
}
public String getLastCarNum() {
return lastCarNum;
}
public void setLastCarNum(String lastCarNum) {
this.lastCarNum = lastCarNum;
}
public String getLastCarNumEn() {
return lastCarNumEn;
}
public void setLastCarNumEn(String lastCarNumEn) {
this.lastCarNumEn = lastCarNumEn;
}
public String getLastFortaVersion() {
return lastFortaVersion;
}
public void setLastFortaVersion(String lastFortaVersion) {
this.lastFortaVersion = lastFortaVersion;
}
public Long getLastModelId() {
return lastModelId;
}
public void setLastModelId(Long lastModelId) {
this.lastModelId = lastModelId;
}
public String getLastModelName() {
return lastModelName;
}
public void setLastModelName(String lastModelName) {
this.lastModelName = lastModelName;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getSnGroupDetail() {
return snGroupDetail;
}
public void setSnGroupDetail(String snGroupDetail) {
this.snGroupDetail = snGroupDetail;
}
public String getSongTypeTop2() {
return songTypeTop2;
}
public void setSongTypeTop2(String songTypeTop2) {
this.songTypeTop2 = songTypeTop2;
}
public String getUserNickName() {
return userNickName;
}
public void setUserNickName(String userNickName) {
this.userNickName = userNickName;
}
}
@Override
public String toString() {
return "Result{" +
"info=" + info +
'}';
}
}
@Override
public String toString() {
return "UserInfoEntity{" +
"result=" + result +
'}';
}
}

View File

@@ -0,0 +1,23 @@
package com.mogo.module.v2x.listener;
import com.mogo.map.location.MogoLocation;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/13 11:02 AM
* desc : 车辆速度状态回调
* <p>
* version: 1.0
*/
public interface CarStatusListener {
/**
* 当车辆从 行驶状态 进入 的时候回调
*/
void onCarDriving2Stop(MogoLocation location);
/**
* 当车辆从 停车状态 进入 行驶状态 的时候回调
*/
void onCarStop2Driving(MogoLocation location);
}

View File

@@ -0,0 +1,296 @@
package com.mogo.module.v2x.listener;
import android.content.Context;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.search.geo.IMogoGeoSearchListener;
import com.mogo.map.search.geo.MogoGeocodeResult;
import com.mogo.map.search.geo.MogoRegeocodeResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.Utils;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.alarm.V2XAlarmServer;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/9 2:31 PM
* desc : V2X中用到的位置监听。处理刷新频率以及位置改变是否触发道路事件警报
* version: 1.0
*/
public class V2XLocationListener implements IMogoLocationListener, CarStatusListener {
private String TAG = "V2XLocationListener";
private MogoLocation mLastCarLocation;
// 记录历史行驶轨迹,用于车行驶方向计算,只保留两个数据
private MogoLocation[] historyPath = new MogoLocation[2];
// 触发刷新的距离
private final int minDistance = 200;
private static V2XLocationListener mV2XLocationListener;
private V2XLocationListener() {
}
public synchronized static V2XLocationListener getInstance() {
synchronized (V2XLocationListener.class) {
if (mV2XLocationListener == null) {
mV2XLocationListener = new V2XLocationListener();
}
}
return mV2XLocationListener;
}
@Override
public void onLocationChanged(MogoLocation location) {
try {
Logger.d(V2XConst.MODULE_NAME, "V2X预警--onLocationChanged: " + GsonUtil.jsonFromObject(location));
// 刷新角度
getCurrentCarAngle(location);
// 只有车速大于 5 的时候进行计算
if (location.getSpeed() >= 5) {
refreshCurrentCarState(location);
}
// 车速从10降为0 这里统一交到 计算中心服务 进行计算,相应的状态会通过回调的方式调用
V2XServiceManager.getV2XCalculateServer().addCarStatusListener(TAG, this);
V2XServiceManager.getV2XCalculateServer().addCarTrajectory(location);
// 下面是道路刷新逻辑
if (mLastCarLocation == null) {
V2XServiceManager.getV2XMarkerService().refreshMarkerData(location);
mLastCarLocation = location;
}
// 计算车辆距离指定气泡的距离
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(location.getLatitude(), location.getLongitude()),
new MogoLatLng(mLastCarLocation.getLatitude(), mLastCarLocation.getLongitude())
);
// 行驶距离 > 200M 重新请求
if (calculateDistance > minDistance) {
// Logger.d(MODULE_NAME, "V2X预警--移动距离>100米重新刷新道路事件");
V2XServiceManager.getV2XMarkerService().refreshMarkerData(location);
mLastCarLocation = location;
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param location 刷新当前车辆状态
*/
private void refreshCurrentCarState(MogoLocation location) {
// 如果有道路事件正在预警的时候这里实时进行更新绘制
IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoV2XPolylineManager().getMogoPolyline();
if (mMogoPolyline != null && (V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
mMogoPolyline.setPoints(Arrays.asList(new MogoLatLng(location.getLatitude(), location.getLongitude()),
V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng()));
float zoomLevel = V2XServiceManager.getMapUIController().getZoomLevel();
//Logger.d(V2XConst.MODULE_NAME, "当前地图的缩放比例为:" + zoomLevel);
if (zoomLevel <= 17 && !V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow()) {
// 缩放地图
Context context = V2XServiceManager.getContext();
MarkerUtils.zoomMap(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng(), context);
}
}
// 疲劳驾驶检测
V2XAlarmServer.getFatigueDrivingShow(location, drivingShowEntity -> {
Logger.i(V2XConst.MODULE_NAME, "疲劳驾驶POI查询结果为: " + GsonUtil.jsonFromObject(drivingShowEntity));
String style = V2XServiceManager.getMoGoStatusManager().isMainPageOnResume() ? "1" : "2";
trackWithType(V2XPoiTypeEnum.ALERT_FATIGUE_DRIVING, drivingShowEntity.getLon(), drivingShowEntity.getLat(), style);
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING);
v2XMessageEntity.setContent(drivingShowEntity);
v2XMessageEntity.setShowState(drivingShowEntity.isShowWindow());
// 广播给ADAS Launcher
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), drivingShowEntity);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
});
// 巡航处理
V2XRoadEventEntity v2XRoadEventEntity =
V2XAlarmServer.getDriveFrontAlarmEvent(
V2XServiceManager.getMoGoV2XMarkerManager().getV2XRoadEventEntityList(),
V2XServiceManager.getV2XStatusManager().getLocation());
// 距离是否大于10米 && 消息是否不为空
if (v2XRoadEventEntity != null && v2XRoadEventEntity.getDistance() >= 5) {
Logger.w(MODULE_NAME,
//"\nV2X预警--当前导航状态:" + V2XServiceManager.getNavi().isNaviing() +
//"\nV2X预警--roadEventIsNullCount:" + roadEventIsNullCount +
"\nV2X预警--当前预警事件:" + v2XRoadEventEntity
);
// Logger.w(MODULE_NAME, "V2X预警--前方数据距离:" + v2XRoadEventEntity.getDistance());
// 触发展示操作
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING);
v2XMessageEntity.setContent(v2XRoadEventEntity);
v2XMessageEntity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
}
}
public MogoLocation getLastCarLocation() {
try {
if (mLastCarLocation == null) {
MogoLatLng mogoLatLng = V2XServiceManager.getNavi().getCarLocation();
mLastCarLocation = new MogoLocation();
if (mogoLatLng != null) {
mLastCarLocation.setLongitude(mogoLatLng.getLon());
mLastCarLocation.setLatitude(mogoLatLng.getLat());
} else {
mLastCarLocation.setLongitude(0.0);
mLastCarLocation.setLatitude(0.0);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return mLastCarLocation;
}
/**
* 获取当前车辆的行驶方向 0<=Angle<=360
*
* @return 0<= Angle < = 3 6 0
*/
private void getCurrentCarAngle(MogoLocation location) {
// 记录位置轨迹
if (historyPath[0] != null) {
historyPath[1] = historyPath[0];
}
historyPath[0] = location;
if (historyPath[1] != null && historyPath[0] != null) {
double carAngle =
DrivingDirectionUtils.getCarAngle(
historyPath[1].getLatitude(), historyPath[1].getLongitude(),
historyPath[0].getLatitude(), historyPath[0].getLongitude()
);
//Logger.d(MODULE_NAME,
// "\n车辆经纬度" + Arrays.toString(historyPath) +
// "\n车辆角度" + carAngle);
// 这里是真实的车辆角度
location.setBearing((float) carAngle);
} else {
//Logger.e(MODULE_NAME,
// "\n首次获取经纬度默认车头朝北" + Arrays.toString(historyPath));
location.setBearing(0.0f);
}
V2XServiceManager.getV2XStatusManager().setLocation(location);
}
/**
* 获取定位相关信息
*/
private void getLocationInfo(MogoLocation location) {
// 定位当前位置是否是高速
LocationUtils.geoCodeSearch(location, new IMogoGeoSearchListener() {
@Override
public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) {
Logger.i(MODULE_NAME, " 根据经纬度查询结果为:" + regeocodeResult.getRegeocodeAddress().getFormatAddress());
location.setAddress(regeocodeResult.getRegeocodeAddress().getFormatAddress());
// 如果有 "高速"、"环线"、"快速路"等字眼的,视为封闭式道路,流程结束;
if (regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("高速")
|| regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("环线")
|| regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("快速路")) {
} else {
searchIllegalParkData();
}
}
@Override
public void onGeocodeSearched(MogoGeocodeResult geocodeResult) {
}
});
}
/**
* 查询50米的违章停车数据
*/
private void searchIllegalParkData() {
double lon = V2XServiceManager.getV2XStatusManager().getLocation().getLongitude();
double lat = V2XServiceManager.getV2XStatusManager().getLocation().getLatitude();
V2XServiceManager.getV2XRefreshModel()
.queryIllegalPark(new V2XRefreshCallback<MarkerResponse>() {
@Override
public void onSuccess(MarkerResponse result) {
Logger.i(MODULE_NAME, "搜索附近的违章停车点 成功:" + GsonUtil.jsonFromObject(result));
if (result != null) {
if (result.getResult().getExploreWay().size() > 0) {
V2XMessageEntity<List<MarkerExploreWay>> entity = new V2XMessageEntity<>();
entity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING);
entity.setContent(result.getResult().getExploreWay());
entity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(entity);
}
}
}
@Override
public void onFail(String msg) {
Logger.e(MODULE_NAME, "搜索附近的违章停车点 失败:" + msg);
}
}, lon, lat);
}
@Override
public void onCarDriving2Stop(MogoLocation location) {
// 推迟30s主Launcher中的大而全的POI刷新时间
V2XServiceManager.getIMogoRefreshStrategyController().restartAutoRefreshAtTime(30000);
getLocationInfo(location);
}
@Override
public void onCarStop2Driving(MogoLocation location) {
}
//埋点
private static void trackWithType(String type, double lon, double lat, String style) {
Map<String, Object> properties = new HashMap<>();
properties.put("type", type);
properties.put("lng", lon);
properties.put("lat", lat);
properties.put("style", style);
V2XServiceManager.getMogoAnalytics().track(V2XConst.V2X_ROAD_SHOW, properties);
}
}

View File

@@ -0,0 +1,129 @@
package com.mogo.module.v2x.listener;
import android.text.TextUtils;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/7 7:13 PM
* desc :
* version: 1.0
*/
public class V2XMarkerClickListener implements IMogoMarkerClickListener {
private static V2XMarkerClickListener markerClickListener;
// 最后一次选中的气泡
private IMogoMarker mLastCheckMarker;
private V2XMarkerClickListener() {
}
public synchronized static V2XMarkerClickListener getInstance() {
synchronized (V2XMarkerClickListener.class) {
if (markerClickListener == null) {
markerClickListener = new V2XMarkerClickListener();
}
}
return markerClickListener;
}
@Override
public boolean onMarkerClicked(IMogoMarker marker) {
try {
if (mLastCheckMarker != null) {
// 判断点击的是否是同一个
if (marker.equals(mLastCheckMarker)) {
Logger.d(MODULE_NAME, "onMarkerClicked 与上一次点击的Marker一样不做处理" + marker);
// 判断是在线车辆的时候处理打电话场景
try {
Object object = marker.getObject();
if (object != null) {
// 修改数据
MarkerShowEntity showEntity = (MarkerShowEntity) object;
if (showEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_USER_DATA)) {
Object bindObj = showEntity.getBindObj();
if (bindObj instanceof MarkerOnlineCar) {
MarkerLocation location = new MarkerLocation();
location.setLon(marker.getPosition().getLon());
location.setLat(marker.getPosition().getLat());
ChartingUtil.callChatting(
((MarkerOnlineCar) bindObj).getUserInfo(),
location
);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
// 关闭上次的气泡
V2XServiceManager.getMoGoV2XMarkerManager().closeMarker(V2XServiceManager.getContext(), mLastCheckMarker);
}
// 将当前的Marker设置为选中
mLastCheckMarker = V2XServiceManager.getMoGoV2XMarkerManager().openMarker(V2XServiceManager.getContext(), marker);
// marker点击展示上半部分的浮窗只加了道路事件
Object nov = marker.getObject();
Logger.d(MODULE_NAME, "marker点击====" + nov);
if (nov != null) {
MarkerShowEntity showEntity = (MarkerShowEntity) nov;
if (showEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_NOVELTY)) {
Object bindObj = showEntity.getBindObj();
if (bindObj instanceof MarkerExploreWay) {
MarkerExploreWay noveltyInfo = (MarkerExploreWay) bindObj;
Logger.d(MODULE_NAME, "新鲜事marker点击===" + bindObj);
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setLocation(noveltyInfo.getLocation());
v2XRoadEventEntity.setPoiType(noveltyInfo.getPoiType());
v2XRoadEventEntity.setNoveltyInfo(noveltyInfo);
v2XRoadEventEntity.setExpireTime(20000);
v2XRoadEventEntity.setDistance(1000);
//V2XServiceManager.getMoGoV2XScenarioManager().showRoadEventWindow(v2XRoadEventEntity, false);
return true;
}
} else if (showEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_ROAD_CONDITION)) {
Object bindObj = showEntity.getBindObj();
if (bindObj instanceof MarkerExploreWay) {
MarkerExploreWay markerExploreWay = (MarkerExploreWay) bindObj;
if (markerExploreWay.getItems().size() > 0
&& !TextUtils.isEmpty(markerExploreWay.getItems().get(0).getUrl())) {
Logger.d(MODULE_NAME, "MarkerExploreWay点击===" + bindObj);
// 记录道路事件
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setLocation(markerExploreWay.getLocation());
// 探路目前只有上报拥堵
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.FOURS_BLOCK_UP);
v2XRoadEventEntity.setDistance(1000);
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
v2XRoadEventEntity.setExpireTime(20000);
//V2XServiceManager.getMoGoV2XScenarioManager().showRoadEventWindow(v2XRoadEventEntity, false);
return true;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}

View File

@@ -0,0 +1,123 @@
package com.mogo.module.v2x.listener;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.mogo.module.v2x.R;
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.V2XScenarioManager;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc :
* ADAS & V2X 场景触发push
* TODO 前瞻需求,这里是后台下发 http://h5service.zhidaohulian.com/v2x_remoteControl/#/
* version: 1.0
*/
public class V2XMessageListener_401003 implements IMogoOnMessageListener<V2XPushMessageEntity> {
@Override
public Class<V2XPushMessageEntity> target() {
return V2XPushMessageEntity.class;
}
@Override
public void onMsgReceived(V2XPushMessageEntity message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401003" + GsonUtil.jsonFromObject(message));
V2XUtils.runOnUiThread(() -> {
try {
handlerV2XAlarm(message);
} catch (Exception e) {
e.printStackTrace();
}
});
}
/**
* 处理V2X场景
*
* @param alarmMessage V2X消息
*/
private void handlerV2XAlarm(V2XPushMessageEntity alarmMessage) {
// 绘制道路事件
//Logger.w(MODULE_NAME, "处理V2X场景SceneId==" + alarmMessage.getSceneId());
// 修改地图比例尺
if (alarmMessage.getZoomScale() > 0) {
V2XServiceManager.getMoGoStatusManager().setUserInteractionStatus(MODULE_NAME, true, true);
MarkerUtils.resetMapZoom(alarmMessage.getZoomScale());
}
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = new V2XMessageEntity<>();
switch (alarmMessage.getSceneId()) {
case "100000"://前车碰撞预警
case "100001"://车道偏离预警
//V2XWindowManager.removeAllV2XView();
break;
// 下面的场景地图缩小显示30秒直播小视频视频播放结束恢复地图比例尺
case "100002"://盲区换道警告
case "100003"://盲区行人碰撞预警
case "100009"://危险路段(施工)告警
case "100010"://拥堵告警
case "100004"://逆向超车碰撞预警
case "100011"://失控车辆告警
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_LIVE_CAR_WARNING);
v2XMessageEntity.setContent(alarmMessage);
v2XMessageEntity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
break;
// 下面的场景禁行动画效果展示
case "100005"://前车紧急制动告警
case "100006"://十字路口碰撞预警
case "100007"://岔路口碰撞预警
case "100008"://禁行车道预警
case "100012"://应急车辆优先通行
case "100013"://闯红灯预警
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ANIMATION_WARNING);
v2XMessageEntity.setContent(alarmMessage);
v2XMessageEntity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
break;
case "100015"://取快递
case "100016"://顺风车
case "100017"://政府公告
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
v2XMessageEntity.setContent(alarmMessage);
v2XMessageEntity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
break;
case "100014"://行人点赞
showTip(alarmMessage.getTts());
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;
default:
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;
}
}
private void showTip(String msg) {
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
View toastView = LayoutInflater.from(V2XServiceManager.getContext()).inflate(R.layout.toast_view, null);
TextView msgView = toastView.findViewById(R.id.tvFeedbackContent);
msgView.setText(msg);
ToastUtils.showCustomShort(toastView);
}
}

View File

@@ -0,0 +1,94 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc : 特殊车辆推送绘制
* version: 1.0
*/
public class V2XMessageListener_401005 implements IMogoOnMessageListener<V2XSpecialCarRes> {
@Override
public Class<V2XSpecialCarRes> target() {
return V2XSpecialCarRes.class;
}
@Override
public void onMsgReceived(V2XSpecialCarRes message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401005" + GsonUtil.jsonFromObject(message));
if (!V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow()) {
V2XUtils.runOnBackgroundThread(() -> {
try {
MarkerUtils.handlerV2XSpecialVehicleMarker(
message,
V2XServiceManager.getContext(),
V2XMarkerClickListener.getInstance());
//获取经纬度信息
//根据sn获取用户信息
//V2XWindowManager展示
handleSeekHelp(message);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
/**
* 处理故障求助
*/
private void handleSeekHelp(V2XSpecialCarRes message) {
if (message == null) {
return;
}
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_MARKER_SPECIAL_CAR);
List<V2XMarkerEntity> coordinates = message.getCoordinates();
List<V2XMarkerEntity> entityList = new ArrayList<>();
// 移除上一次的数据
//Context context = V2XServiceManager.getContext();
for (V2XMarkerEntity coordinate : coordinates) {
//故障车机
if (coordinate.getTargetId() == V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING) {
//V2XMarkerEntity.UserInfoBean userInfoBean = coordinate.getUserInfo();
//if (userInfoBean != null) {
entityList.add(coordinate);
//}
//绘制
//V2XServiceManager
// .getMoGoV2XMarkerManager()
// .drawableSpecialCarPOI(context, coordinate, V2XMarkerClickListener.getInstance());
}
}
if (!entityList.isEmpty()) {
//V2XUtils.runOnUiThread(() -> V2XServiceManager.getMoGoV2XScenarioManager().showOtherSeekHelpWindow(entityList));
V2XUtils.runOnUiThread(() -> {
V2XMessageEntity<List<V2XMarkerEntity>> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING);
v2XMessageEntity.setContent(entityList);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
});
}
}
}

View File

@@ -0,0 +1,30 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.v2x.entity.net.V2XAlarmEventRes;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc :
* 3.2.1、前方静止or慢速车辆报警
* 3.2.2、道路危险状况告警 / 前方拥堵告警
* version: 1.0
*/
@Deprecated
public class V2XMessageListener_401006 implements IMogoOnMessageListener<V2XAlarmEventRes> {
@Override
public Class<V2XAlarmEventRes> target() {
return V2XAlarmEventRes.class;
}
@Override
public void onMsgReceived(V2XAlarmEventRes message) {
Logger.i(MODULE_NAME, "iMogoOnMessageListener_401006" + message);
}
}

View File

@@ -0,0 +1,48 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XAlarmEventRes;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import java.util.HashMap;
import java.util.Map;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc : 限行通知
* version: 1.0
*/
public class V2XMessageListener_401007 implements IMogoOnMessageListener<V2XAlarmEventRes> {
@Override
public Class<V2XAlarmEventRes> target() {
return V2XAlarmEventRes.class;
}
@Override
public void onMsgReceived(V2XAlarmEventRes message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401007" + message);
try {
if (message != null) {
// 发送广播
V2XAlarmEventRes.AlarmInfo alarmInfo = message.getResult().getAlarmInfo();
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmInfo);
// 统计代码
final Map<String, Object> properties = new HashMap<>();
properties.put("warning_id", V2XPoiTypeEnum.ALERT_TRAFFIC_CONTROL);
MarkerServiceHandler.getMogoAnalytics().track("v2x_warning", properties);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,50 @@
package com.mogo.module.v2x.listener;
import android.view.Gravity;
import android.view.LayoutInflater;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.entity.net.V2XGiveLike;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc :
* * 2.0.2
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=35786774
* * 注册点赞通信接收
* version: 1.0
*/
public class V2XMessageListener_401009 implements IMogoOnMessageListener<V2XGiveLike> {
@Override
public Class<V2XGiveLike> target() {
return V2XGiveLike.class;
}
@Override
public void onMsgReceived(V2XGiveLike message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401009" + message);
try {
V2XPushMessageEntity v2XAlarmMessage = new V2XPushMessageEntity();
v2XAlarmMessage.setTts(message.getResult());
v2XAlarmMessage.setAlarmContent(message.getResult());
v2XAlarmMessage.setExpireTime(20000);
v2XAlarmMessage.setSceneId("000000");
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), v2XAlarmMessage);
} catch (Exception e) {
e.printStackTrace();
}
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
ToastUtils.showCustomLong(LayoutInflater.from(V2XServiceManager.getContext()).inflate(R.layout.toast_view_feedback_img_text, null));
}
}

View File

@@ -0,0 +1,47 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.v2x.entity.net.V2XAlarmEventRes;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc :
* * 2.0.3
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=35788659
* * TODO 停车场、加油站推送心跳,这里是前瞻的功能,目前仅在分体机使用,
* version: 1.0
*/
@Deprecated
public class V2XMessageListener_401010 implements IMogoOnMessageListener<V2XAlarmEventRes> {
@Override
public Class<V2XAlarmEventRes> target() {
return V2XAlarmEventRes.class;
}
@Override
public void onMsgReceived(V2XAlarmEventRes message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401010" + message);
try {
if (message != null
&& message.getResult() != null) {
// 处理报警事件
handlerAlarmInfo();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 处理道路事件提醒
*/
private void handlerAlarmInfo() {
}
}

View File

@@ -0,0 +1,43 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/1 10:23 AM
* desc : 道路事件,实际就是大而全的数据进行的过滤
* version: 1.0
*/
public class V2XMessageListener_401011 implements IMogoOnMessageListener<MarkerResponse> {
@Override
public Class<MarkerResponse> target() {
return MarkerResponse.class;
}
@Override
public void onMsgReceived(MarkerResponse response) {
Logger.d(MODULE_NAME, "V2XMessageListener_401011==V2X地图气泡数据刷新\n" + GsonUtil.jsonFromObject(response));
if (!V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow()) {
V2XUtils.runOnBackgroundThread(() -> {
// 解析不同的Marker类型然后对应的进行绘制
if (response != null && response.getResult() != null) {
MarkerCardResult markerCardResult = response.getResult();
// 解析存储道路事件
//V2XServiceManager.getMoGoV2XMarkerManager().drawableV2XMarker(markerCardResult);
V2XServiceManager.getMoGoV2XMarkerManager().analysisV2XRoadEvent(markerCardResult);
}
});
}
}
}

View File

@@ -0,0 +1,14 @@
package com.mogo.module.v2x.listener;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/15 10:20 AM
* desc : V2X 窗体状态回调
* version: 1.0
*/
public interface V2XWindowStatusListener {
void onViewShow();
void onViewClose();
}

View File

@@ -0,0 +1,163 @@
package com.mogo.module.v2x.manager;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerNoveltyInfo;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 8:15 PM
* desc : V2X 涉及到的地图 POI 点的绘制
* version: 1.0
*/
public interface IMoGoV2XMarkerManager extends IProvider {
/**
* 重新绘制最后一次的POI点
*/
void drawableLastAllPOI();
/**
* 获取所有的道路事件点,探路事件,返回结果是按照距离当前车辆从近到远排列好的
*
* @return 按从近到远排列好的道路事件
*/
CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList();
/**
* 从探路数据和新鲜事儿的路况信息中解析出道路事件信息
*/
void analysisV2XRoadEvent(MarkerCardResult markerCardResult);
/**
* 绘制V2X 地图点事件
*
* @param markerCardResult 大而全中过滤出来的点事件
*/
void drawableV2XMarker(MarkerCardResult markerCardResult);
/**
* 绘制 在线车辆 POI
*
* @param markerOnlineCars
* @param clickListener
*/
void drawableOnlineCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener);
/**
* 清除 在线车辆 POI
*/
void clearOnlineCarPOI();
/**
* 绘制 特殊车辆
*
* @param context
* @param v2XMarkerEntity
* @param clickListener
*/
void drawableSpecialCarPOI(Context context, V2XMarkerEntity v2XMarkerEntity, IMogoMarkerClickListener clickListener);
/**
* 清除 特殊车辆 POI
*/
void clearSpecialCarPOI();
/**
* 绘制可以直播的在线车辆
*
* @param markerOnlineCars
* @param clickListener
*/
void drawableLiveCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener);
/**
* 清除 可以直播的在线车辆 POI
*/
void clearLiveCarPOI();
/**
* 绘制 探路
*
* @param exploreWayList
* @param clickListener
*/
void drawableExplorePOI(List<MarkerExploreWay> exploreWayList, IMogoMarkerClickListener clickListener);
/**
* 清除 探路 POI
*/
void clearExplorePOI();
/**
* 绘制 新鲜事儿
*
* @param noveltyInfoList
* @param clickListener
*/
void drawableNoveltyPOI(List<MarkerNoveltyInfo> noveltyInfoList, IMogoMarkerClickListener clickListener);
/**
* 清除 新鲜事儿 POI
*/
void clearNoveltyPOI();
/**
* 绘制Marker上面调用的都是这个方法
*
* @param context
* @param markerShowEntity
* @param clickListener
*/
void drawableMarker(Context context, MarkerShowEntity markerShowEntity, IMogoMarkerClickListener clickListener);
/**
* 展开气泡
*
* @param context
* @param currentMarker
*/
IMogoMarker openMarker(Context context, IMogoMarker currentMarker);
/**
* 关闭气泡
*
* @param context
* @param currentMarker
*/
void closeMarker(Context context, IMogoMarker currentMarker);
/**
* 绘制正在预警的道路事件的POI点
*
* @param context
* @param roadEventEntity
*/
void drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener);
/**
* 清除 道路事件 POI
*/
void clearAlarmPOI();
/**
* 清除 所有的 POI
*/
void clearALLPOI();
}

View File

@@ -0,0 +1,31 @@
package com.mogo.module.v2x.manager;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.entity.V2XRoadEventEntity;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 9:49 PM
* desc : 当前车辆与道路事件的连接线
* version: 1.0
*/
public interface IMoGoV2XPolylineManager extends IProvider {
/**
* 绘制连接线,目标车,与当前车辆间连线
*
* @param context
* @param roadEventEntity
*/
void drawablePolyline(Context context, V2XRoadEventEntity roadEventEntity);
/**
* 移除连接线
*/
void clearLine();
IMogoPolyline getMogoPolyline();
}

View File

@@ -0,0 +1,19 @@
package com.mogo.module.v2x.manager;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 7:44 PM
* desc : 状态控制器监听
* version: 1.0
*/
public interface IMoGoV2XStatusChangedListener extends IProvider {
/**
* @param descriptor 状态类型
* @param isTrue true - v2x ui show
*/
void onStatusChanged(V2XStatusDescriptor descriptor, boolean isTrue);
}

View File

@@ -0,0 +1,188 @@
package com.mogo.module.v2x.manager;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 7:20 PM
* desc : V2X 状态管理
* version: 1.0
*/
public interface IMoGoV2XStatusManager extends IProvider {
/**
* 地图区域 V2X道路预警POI 是否在展示
*/
boolean isRoadEventPOIShow();
/**
* 按钮区 V2X道路预警 是否在展示
*/
boolean isRoadEventButtonShow();
/**
* 头部 V2X道路预警 UI 是否在展示
*/
boolean isRoadEventWindowShow();
/**
* 头部 V2X的道路直播 UI 是否在展示
*/
boolean isRoadLiveCarWindowShow();
/**
* 头部 他人车辆故障求助 UI 是否在展示
*/
boolean isOtherSeekHelpWindowShow();
/**
* 地图区域 自身的道路求助按钮 是否在展示
*/
boolean isMeSeekHelpButtonShow();
/**
* 地图区域 他人车辆故障求助POI 是否在展示
*/
boolean isOtherSeekHelpPOIShow();
/**
* 前瞻需求
* 右侧2/3 V2X 场景动画 UI 是否在展示
*/
boolean isV2XAnimationShow();
/**
* 前瞻需求
* 右侧2/3 左下角 模拟直播车机 UI 是否在展示
*/
boolean isLeftLiveVideoShow();
/**
* 推送弹窗的状态
*/
boolean isPushWindowShow();
/**
* 推送的 POI 状态
*/
boolean isPushPOIShow();
/**
* 疲劳驾驶 状态
*/
boolean isFatigueDrivingWindowShow();
/**
* 设置 V2X道路预警POI 是否在展示
*
* @param tag
* @param show
*/
void setRoadEventPOIShow(String tag, boolean show);
/**
* 设置 V2X道路预警 是否在展示
*
* @param tag
* @param show
*/
void setRoadEventButtonShow(String tag, boolean show);
/**
* 设置 右侧2/3 头部 V2X道路预警 是否在展示
*
* @param tag
* @param show
*/
void setRoadEventWindowShow(String tag, boolean show);
/**
* 设置 右侧2/3 头部 V2X的道路直播 是否在展示
*
* @param tag
* @param show
*/
void setRoadLiveCarWindowShow(String tag, boolean show);
/**
* 设置 他人车辆故障求助 UI 是否在展示
*
* @param tag
* @param show
*/
void setOtherSeekHelpWindowShow(String tag, boolean show);
/**
* 地图区域 自身的道路求助按钮 是否在展示
*
* @param tag
* @param show
*/
void setMeSeekHelpButtonShow(String tag, boolean show);
/**
* 地图区域 他人车辆故障求助POI 是否在展示
*
* @param tag
* @param show
*/
void setOtherSeekHelpPOIShow(String tag, boolean show);
/**
* 设置 右侧2/3 全屏 V2X 场景动画 是否在展示
*
* @param tag
* @param show
*/
void setV2XAnimationWindowShow(String tag, boolean show);
/**
* 设置 模拟直播车机 UI 是否在展示
*
* @param tag
* @param show
*/
void setLiveCarWindowShow(String tag, boolean show);
/**
* 推送弹窗的状态
*
* @param tag
* @param show
*/
void setPushWindowShow(String tag, boolean show);
/**
* 地图区域 推送的 POI 是否在展示
*
* @param tag
* @param show
*/
void setPushPOIShow(String tag, boolean show);
/**
* 地图区域 疲劳驾驶 是否在展示
*
* @param tag
* @param show
*/
void setFatigueDrivingWindowShow(String tag, boolean show);
/**
* 注册监听
*
* @param tag 业务类型
* @param descriptor 监听类型
* @param listener 监听回调
*/
void registerStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener);
/**
* 注销
*
* @param tag 业务类型
* @param descriptor 注销类型
* @param listener 注销回调
*/
void unregisterStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener);
}

View File

@@ -0,0 +1,70 @@
package com.mogo.module.v2x.manager;
/**
* @author congtaowang
* @since 2020-01-04
* <p>
* 状态描述
*/
public enum V2XStatusDescriptor {
/**
* 地图 V2X道路预警POI
*/
RoadEventPOI_UI,
/**
* 按钮 V2X道路预警
*/
RoadEventButton_UI,
/**
* 头部 V2X道路预警 UI
*/
RoadEventWindow_UI,
/**
* 头部 V2X的道路直播 UI
*/
RoadLiveCarWindow_UI,
/**
* 地图 他人车辆故障求助POI
*/
OtherSeekHelpPOI_UI,
/**
* 头部 他人车辆故障求助 UI 是否在展示
*/
OtherSeekHelpWindow_UI,
/**
* 头部 自身的道路求助按钮 UI 是否在展示
*/
MeSeekHelpButton_UI,
/**
* 右侧2/3 V2X 场景动画 UI 是否在展示
*/
V2XAnimationWindow_UI,
/**
* 右侧2/3 左下角 模拟直播车机 UI 是否在展示
*/
LiveCarWindow_UI,
/**
* 推送的POI
*/
PushWindowPOI_UI,
/**
* 推送的弹窗
*/
PushWindow_UI,
/**
* 疲劳驾驶弹窗
*/
FatigueDrivingWindow_UI,
}

View File

@@ -0,0 +1,572 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.graphics.Bitmap;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerNoveltyInfo;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.Utils;
import com.mogo.module.service.marker.IMarkerView;
import com.mogo.module.service.marker.MapMarkerAdapter;
import com.mogo.module.service.utils.ViewUtils;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.listener.V2XMarkerClickListener;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.marker.V2XMarkerAdapter;
import com.mogo.module.v2x.utils.EventTypeUtils;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.utils.logger.Logger;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
import static com.mogo.module.v2x.V2XConst.V2X_EVENT_ALARM_POI;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 9:57 PM
* desc : V2X 涉及到的地图 POI 点的绘制
* version: 1.0
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER)
public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
private static final String TAG = "MoGoV2XMarkerManager";
// 记录所有的:新鲜事儿的道路事件点、探路事件
private static CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
// 上次的道路事件的预警Marker
private static IMogoMarker mAlarmInfoMarker;
@Override
public void drawableLastAllPOI() {
//Logger.w(MODULE_NAME, "V2X---绘制上一次的POI回调给Launcher底层逻辑让其进行绘制");
// 清除连接线
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
clearAlarmPOI();
clearSpecialCarPOI();
// 开启主Launcher刷新
V2XServiceManager.getIMogoRefreshStrategyController().restartAutoRefreshAtTime(500);
}
@Override
public CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList() {
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
// 当前车辆数据
MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation();
if (currentLocation != null) {
// 重新计算距离
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {
// 事件位置
MarkerLocation location = v2XRoadEventEntity.getLocation();
if (location != null) {
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(location.getLat(), location.getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
v2XRoadEventEntity.setDistance(calculateDistance);
}
roadEventEntities.add(v2XRoadEventEntity);
}
// 按照与当前车辆距离排序
for (int i = 0; i < roadEventEntities.size(); i++) {
for (int j = i; j > 0; j--) {
if (roadEventEntities.get(j).getDistance() < roadEventEntities.get(j - 1).getDistance()) {
V2XRoadEventEntity v2XRoadEventEntity = roadEventEntities.get(j - 1);
roadEventEntities.set(j - 1, roadEventEntities.get(j));
roadEventEntities.set(j, v2XRoadEventEntity);
}
}
}
//输出日志查看结果
// Log.w(TAG, "V2X===============================");
// for (int i = 0; i < roadEventEntities.size(); i++) {
// Log.w(TAG, "V2X===" +
// "事件名称:" + roadEventEntities.get(i).getNoveltyInfo() +
// "\t 事件距离:" + roadEventEntities.get(i).getDistance());
// }
}
return roadEventEntities;
}
@Override
public void analysisV2XRoadEvent(MarkerCardResult markerCardResult) {
// 预警Window状态
boolean isShowEventWindow = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow();
// 预警按钮状态
boolean isShowEventButton = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventButtonShow();
// 道路求助的window
boolean isOtherSeekHelpWindowShow = V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow();
try {
//当没有预警提示的时候重新绘制地图POI点
if (markerCardResult != null && !isShowEventWindow && !isShowEventButton && !isOtherSeekHelpWindowShow) {
// 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
mV2XRoadEventEntityArrayList.clear();
// 获取探路以及新鲜事儿
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
if (exploreWayList != null) {
for (MarkerExploreWay markerExploreWay : exploreWayList) {
// 因为目前探路卡片不支持直播,所以这里做了过滤 @李小鹏
if (!markerExploreWay.getCanLive()) {
if (EventTypeUtils.isRoadEvent(markerExploreWay.getPoiType())) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
// 记录道路事件
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setLocation(markerLocation);
// 探路目前只有上报拥堵
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
v2XRoadEventEntity.setExpireTime(20000);
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void drawableV2XMarker(MarkerCardResult markerCardResult) {
// 预警Window状态
boolean isShowEventWindow = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventWindowShow();
// 预警按钮状态
boolean isShowEventButton = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventButtonShow();
// 道路求助的window
boolean isOtherSeekHelpWindowShow = V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow();
try {
//当没有预警提示的时候重新绘制地图POI点
if (!isShowEventWindow && !isShowEventButton && !isOtherSeekHelpWindowShow) {
// 清除上次的道路事件TODO 这里注意,道路事件的触发和这里是异步操作会触发异常
//mV2XRoadEventEntityArrayList.clear();
// 清除原来的大而全的新鲜事儿
try {
clearALLPOI();
} catch (Exception e) {
e.printStackTrace();
}
// 清除连接线
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
if (markerCardResult != null) {
// 绘制新的地图气泡
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
drawableOnlineCarPOI(onlineCarList, V2XMarkerClickListener.getInstance());
drawableExplorePOI(exploreWayList, V2XMarkerClickListener.getInstance());
drawableNoveltyPOI(noveltyInfoList, V2XMarkerClickListener.getInstance());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void drawableOnlineCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener) {
try {
if (markerOnlineCars != null) {
for (MarkerOnlineCar markerOnlineCar : markerOnlineCars) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerOnlineCar);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(markerOnlineCar.getType());
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getSafeLabel());
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
drawableMarker(V2XServiceManager.getContext(), markerShowEntity, clickListener);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearOnlineCarPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_CARD_TYPE_USER_DATA);
}
@Override
public void drawableSpecialCarPOI(Context context, V2XMarkerEntity v2XMarkerEntity, IMogoMarkerClickListener clickListener) {
try {
MarkerUtils.resetMapZoom(15);
V2XServiceManager.getMapUIController().changeMapMode(EnumMapUI.NorthUP_2D);
V2XServiceManager.getMoGoV2XStatusManager().setOtherSeekHelpPOIShow(TAG, true);
// 绘制特殊车辆
if (v2XMarkerEntity == null) {
return;
}
MarkerLocation markerLocation = new MarkerLocation();
markerLocation.setLon(v2XMarkerEntity.getLon());
markerLocation.setLat(v2XMarkerEntity.getLat());
// 进行数据转换用于Marker展示
V2XRoadEventEntity roadEventEntity = new V2XRoadEventEntity();
roadEventEntity.setPoiType(v2XMarkerEntity.getTargetId() + "");
roadEventEntity.setLocation(markerLocation);
roadEventEntity.setBindObj(v2XMarkerEntity);
// 重置告警信息
V2XServiceManager.getV2XStatusManager().setAlarmInfo(roadEventEntity);
// 清除原来的大而全的新鲜事儿
clearALLPOI();
if (roadEventEntity.getLocation() != null) {
// 道路事件,或者水波纹扩散效果
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.object(roadEventEntity)
.latitude(roadEventEntity.getLocation().getLat())
.longitude(roadEventEntity.getLocation().getLon());
optionsRipple.anchor(0.5f, 0.5f);
// 由于性能问题D车机不使用事件扩散动画
optionsRipple.icon(V2XMarkerAdapter.getV2XRoadEventViewPng(context, roadEventEntity));
mAlarmInfoMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
// 当前Marker设置为最上面
mAlarmInfoMarker.setToTop();
// if (clickListener != null) {
// mAlarmInfoMarker.setOnMarkerClickListener(clickListener);
// }
// 绘制连接线
V2XServiceManager.getMoGoV2XPolylineManager().drawablePolyline(context, roadEventEntity);
} else {
Logger.e(MODULE_NAME, "Location 必须进行初始化!!!!!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearSpecialCarPOI() {
boolean isOtherSeekHelpPOIShow = V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow();
if (isOtherSeekHelpPOIShow) {
V2XServiceManager.getMoGoV2XStatusManager().setOtherSeekHelpPOIShow(TAG, false);
// 重置告警信息
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
if (mAlarmInfoMarker != null) {
mAlarmInfoMarker.remove();
}
}
}
@Override
public void drawableLiveCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener) {
try {
Logger.w(MODULE_NAME, "V2X===事件周边的直播车机:" + markerOnlineCars);
if (markerOnlineCars != null) {
for (MarkerOnlineCar markerOnlineCar : markerOnlineCars) {
// 设置车类型
markerOnlineCar.getUserInfo().setSafeLabelType(4);
markerOnlineCar.getCarInfo().setVehicleType(0);
MarkerLocation markerLocation = markerOnlineCar.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerOnlineCar);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(V2XConst.V2X_MARKER_LIVE_CAR);
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getSafeLabel());
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
drawableMarker(
V2XServiceManager.getContext(),
markerShowEntity,
clickListener);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearLiveCarPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_MARKER_LIVE_CAR);
}
@Override
public void drawableExplorePOI(List<MarkerExploreWay> exploreWayList, IMogoMarkerClickListener clickListener) {
try {
if (exploreWayList != null) {
for (MarkerExploreWay markerExploreWay : exploreWayList) {
// 因为目前探路卡片不支持直播,所以这里做了过滤 @李小鹏
if (!markerExploreWay.getCanLive()) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerExploreWay);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(markerExploreWay.getType());
markerShowEntity.setTextContent(markerExploreWay.getAddr());
drawableMarker(
V2XServiceManager.getContext(),
markerShowEntity,
clickListener);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearExplorePOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_CARD_TYPE_ROAD_CONDITION);
}
@Override
public void drawableNoveltyPOI(List<MarkerNoveltyInfo> noveltyInfoList, IMogoMarkerClickListener clickListener) {
try {
if (noveltyInfoList != null) {
for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
MarkerLocation markerLocation = noveltyInfo.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(noveltyInfo);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(noveltyInfo.getType());
markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
// 这里只绘制道路事件相关
switch (noveltyInfo.getPoiType()) {
case V2XPoiTypeEnum.TRAFFIC_CHECK:
case V2XPoiTypeEnum.ROAD_CLOSED:
case V2XPoiTypeEnum.FOURS_ROAD_WORK:
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
case V2XPoiTypeEnum.FOURS_PONDING:
case V2XPoiTypeEnum.FOURS_PARKING:
case V2XPoiTypeEnum.FOURS_ICE:
case V2XPoiTypeEnum.FOURS_FOG:
case V2XPoiTypeEnum.FOURS_ACCIDENT:
drawableMarker(
V2XServiceManager.getContext(),
markerShowEntity,
clickListener);
break;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearNoveltyPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_CARD_TYPE_NOVELTY);
}
@Override
public void drawableMarker(Context context, MarkerShowEntity markerShowEntity, IMogoMarkerClickListener clickListener) {
// Logger.i(MODULE_NAME, "绘制Marker====drawMapMarker" + markerShowEntity);
try {
if (markerShowEntity.getMarkerLocation() != null) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
// 这里对Marker做下持有者转换与大而全的区分开由于绘制的时候用到了低层能力所以不去修改markerShowEntity中的type
switch (markerShowEntity.getMarkerType()) {
case ServiceConst.CARD_TYPE_USER_DATA:
options.owner(V2XConst.V2X_CARD_TYPE_USER_DATA);
break;
case ServiceConst.CARD_TYPE_NOVELTY:
options.owner(V2XConst.V2X_CARD_TYPE_NOVELTY);
break;
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
options.owner(V2XConst.V2X_CARD_TYPE_ROAD_CONDITION);
break;
case V2XConst.V2X_MARKER_SPECIAL_CAR:
options.owner(V2XConst.V2X_MARKER_SPECIAL_CAR);
break;
case V2XConst.V2X_MARKER_LIVE_CAR:
options.owner(V2XConst.V2X_MARKER_LIVE_CAR);
break;
default:
options.owner(markerShowEntity.getMarkerType());
break;
}
IMogoMarker marker;
Bitmap bitmap;
if (markerShowEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_USER_DATA)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_SPECIAL_CAR)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_LIVE_CAR)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_EXPRESS)
) {
bitmap = V2XMarkerAdapter.getV2XCarMarkerView(context, markerShowEntity);
options.icon(bitmap);
marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
} else {
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(context, markerShowEntity, options);
bitmap = ViewUtils.fromView(iMarkerView.getView());
options.icon(bitmap);
marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
}
//marker.setOnMarkerClickListener(clickListener);
} else {
Logger.e(MODULE_NAME, "Location 必须进行初始化!!!!!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public IMogoMarker openMarker(Context context, IMogoMarker currentMarker) {
try {
if (currentMarker != null) {
Object object = currentMarker.getObject();
if (object != null) {
// 修改数据
MarkerShowEntity showEntity = (MarkerShowEntity) object;
showEntity.setChecked(true);
// 获取数据对应的View
IMarkerView markerView = MapMarkerAdapter.getMarkerView(context,
showEntity,
currentMarker.getMogoMarkerOptions());
Bitmap bitmap;
if (showEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_USER_DATA)
|| showEntity.getMarkerType().equals(V2XConst.V2X_MARKER_SPECIAL_CAR)) {
bitmap = V2XMarkerAdapter.getV2XCarMarkerView(context, showEntity);
} else {
bitmap = ViewUtils.fromView(markerView.getView());
}
currentMarker.setIcon(bitmap);
currentMarker.setToTop();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return currentMarker;
}
@Override
public void closeMarker(Context context, IMogoMarker currentMarker) {
try {
if (currentMarker != null) {
Object object = currentMarker.getObject();
if (object != null) {
MarkerShowEntity showEntity = (MarkerShowEntity) object;
showEntity.setChecked(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(context,
showEntity,
currentMarker.getMogoMarkerOptions());
Bitmap bitmap;
if (showEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_USER_DATA)
|| showEntity.getMarkerType().equals(V2XConst.V2X_MARKER_SPECIAL_CAR)) {
bitmap = V2XMarkerAdapter.getV2XCarMarkerView(context, showEntity);
} else {
bitmap = ViewUtils.fromView(markerView.getView());
}
currentMarker.setIcon(bitmap);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener) {
try {
MarkerUtils.resetMapZoom(15);
V2XServiceManager.getMapUIController().changeMapMode(EnumMapUI.NorthUP_2D);
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventPOIShow(TAG, true);
//Logger.i(MODULE_NAME, "绘制道路事件====drawableAlarmPOI");
// 清除原来的大而全的新鲜事儿
clearALLPOI();
if (roadEventEntity.getLocation() != null) {
// 道路事件,或者水波纹扩散效果
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.object(roadEventEntity)
.latitude(roadEventEntity.getLocation().getLat())
.longitude(roadEventEntity.getLocation().getLon());
optionsRipple.anchor(0.5f, 0.5f);
// 由于性能问题D车机不使用事件扩散动画
optionsRipple.icon(V2XMarkerAdapter.getV2XRoadEventViewPng(context, roadEventEntity));
mAlarmInfoMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
// 当前Marker设置为最上面
mAlarmInfoMarker.setToTop();
// if (clickListener != null) {
// mAlarmInfoMarker.setOnMarkerClickListener(clickListener);
// }
// 绘制连接线
V2XServiceManager.getMoGoV2XPolylineManager().drawablePolyline(context, roadEventEntity);
} else {
Logger.e(MODULE_NAME, "Location 必须进行初始化!!!!!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearAlarmPOI() {
boolean isRoadEventPOIShow = V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow();
if (isRoadEventPOIShow) {
V2XServiceManager.getMoGoV2XStatusManager().setRoadEventPOIShow(TAG, false);
if (mAlarmInfoMarker != null) {
mAlarmInfoMarker.remove();
}
}
}
@Override
public void clearALLPOI() {
try {
V2XServiceManager.getMarkerManager().removeMarkers();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void init(Context context) {
}
}

View File

@@ -0,0 +1,104 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 10:00 PM
* desc : 当前车辆与道路事件的连接线
* version: 1.0
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER)
public class MoGoV2XPolylineManager implements IMoGoV2XPolylineManager {
private static final String TAG = "MoGoV2XPolylineManager";
private static IMogoPolyline mMogoPolyline;
@Override
public void drawablePolyline(Context context, V2XRoadEventEntity roadEventEntity) {
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
switch (roadEventEntity.getPoiType()) {
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
colors.add(0xFFFA8C34);
colors.add(0xFFBD6D36);
colors.add(0xFFFA8C34);
break;
default:
colors.add(0xFFF95959);
colors.add(0xFF942B48);
colors.add(0xFFCB253A);
break;
}
// 线条粗细,渐变,渐变色值
options.width(10).useGradient(true).colorValues(colors);
// 当前车辆位置
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
if (carLocation != null) {
options.add(carLocation);
} else {
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
}
// 目标车辆位置
options.add(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearLine() {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
mMogoPolyline = null;
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
}
}
@Override
public void init(Context context) {
}
/**
* @return 绘制连接线的对象
*/
@Override
public IMogoPolyline getMogoPolyline() {
return mMogoPolyline;
}
}

View File

@@ -0,0 +1,256 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.manager.IMoGoV2XStatusChangedListener;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
import com.mogo.module.v2x.manager.V2XStatusDescriptor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/17 7:34 PM
* desc :
* version: 1.0
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER)
public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
private static final String TAG = "MoGoV2XStatusManager";
/**
* 状态记录
*/
private static final Map<V2XStatusDescriptor, Boolean> mStatus = new ConcurrentHashMap<>();
/**
* 回调集合
*/
private static final Map<V2XStatusDescriptor, List<IMoGoV2XStatusChangedListener>> mListeners = new ConcurrentHashMap<>();
/**
* 状态类型修改记录
*/
private static final Map<V2XStatusDescriptor, String> mModifier = new ConcurrentHashMap<>();
// 查询状态存储情况
private boolean get_bool_val(V2XStatusDescriptor descriptor) {
Boolean val = mStatus.get(descriptor);
return val == null ? false : val;
}
@Override
public boolean isRoadEventPOIShow() {
return get_bool_val(V2XStatusDescriptor.RoadEventPOI_UI);
}
@Override
public boolean isRoadEventButtonShow() {
return get_bool_val(V2XStatusDescriptor.RoadEventButton_UI);
}
@Override
public boolean isRoadEventWindowShow() {
return get_bool_val(V2XStatusDescriptor.RoadEventWindow_UI);
}
@Override
public boolean isRoadLiveCarWindowShow() {
return get_bool_val(V2XStatusDescriptor.RoadLiveCarWindow_UI);
}
@Override
public boolean isOtherSeekHelpWindowShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public boolean isMeSeekHelpButtonShow() {
return get_bool_val(V2XStatusDescriptor.MeSeekHelpButton_UI);
}
@Override
public boolean isOtherSeekHelpPOIShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpPOI_UI);
}
@Override
public boolean isV2XAnimationShow() {
return get_bool_val(V2XStatusDescriptor.V2XAnimationWindow_UI);
}
@Override
public boolean isLeftLiveVideoShow() {
return get_bool_val(V2XStatusDescriptor.LiveCarWindow_UI);
}
@Override
public boolean isPushWindowShow() {
return get_bool_val(V2XStatusDescriptor.PushWindow_UI);
}
@Override
public boolean isPushPOIShow() {
return get_bool_val(V2XStatusDescriptor.PushWindowPOI_UI);
}
@Override
public boolean isFatigueDrivingWindowShow() {
return get_bool_val(V2XStatusDescriptor.FatigueDrivingWindow_UI);
}
@Override
public void setRoadEventPOIShow(String tag, boolean show) {
V2XServiceManager.getMoGoStatusManager().setV2XUIShow(V2XConst.MODULE_NAME, show);
mStatus.put(V2XStatusDescriptor.RoadEventPOI_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadEventPOI_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventPOI_UI);
}
@Override
public void setRoadEventButtonShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadEventButton_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadEventButton_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventButton_UI);
}
@Override
public void setRoadEventWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadEventWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadEventWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventWindow_UI);
}
@Override
public void setRoadLiveCarWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadLiveCarWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadLiveCarWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadLiveCarWindow_UI);
}
@Override
public void setOtherSeekHelpWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.OtherSeekHelpWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.OtherSeekHelpWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public void setMeSeekHelpButtonShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.MeSeekHelpButton_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.MeSeekHelpButton_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.MeSeekHelpButton_UI);
}
@Override
public void setOtherSeekHelpPOIShow(String tag, boolean show) {
V2XServiceManager.getMoGoStatusManager().setV2XUIShow(V2XConst.MODULE_NAME, show);
mStatus.put(V2XStatusDescriptor.OtherSeekHelpPOI_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.OtherSeekHelpPOI_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.OtherSeekHelpPOI_UI);
}
@Override
public void setV2XAnimationWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.V2XAnimationWindow_UI);
}
@Override
public void setLiveCarWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.LiveCarWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.LiveCarWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.LiveCarWindow_UI);
}
@Override
public void setPushWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.PushWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.PushWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.PushWindow_UI);
}
@Override
public void setPushPOIShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.PushWindowPOI_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.PushWindowPOI_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.PushWindowPOI_UI);
}
@Override
public void setFatigueDrivingWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.FatigueDrivingWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.FatigueDrivingWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.FatigueDrivingWindow_UI);
}
@Override
public void registerStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener) {
if (listener == null || descriptor == null) {
return;
}
if (!mListeners.containsKey(descriptor)) {
mListeners.put(descriptor, new ArrayList<>());
}
if (mListeners.get(descriptor) == null) {
mListeners.put(descriptor, new ArrayList<>());
}
List<IMoGoV2XStatusChangedListener> listeners = mListeners.get(descriptor);
if (listeners != null) {
listeners.add(listener);
}
}
@Override
public void unregisterStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener) {
List<IMoGoV2XStatusChangedListener> listeners = mListeners.get(descriptor);
if (listeners != null) {
listeners.remove(listener);
}
}
/**
* 调用所有存储的监听
*
* @param descriptor
* @param status
*/
private void invokeStatusChangedListener(V2XStatusDescriptor descriptor, boolean status) {
if (mListeners.containsKey(descriptor)) {
List<IMoGoV2XStatusChangedListener> listeners = mListeners.get(descriptor);
if (listeners != null) {
for (IMoGoV2XStatusChangedListener listener : listeners) {
if (listener != null) {
listener.onStatusChanged(descriptor, status);
}
}
}
}
}
/**
* 记录状态
*
* @param tag
* @param descriptor
*/
private void recordStatusModifier(String tag, V2XStatusDescriptor descriptor) {
mModifier.put(descriptor, tag);
}
@Override
public void init(Context context) {
}
}

View File

@@ -0,0 +1,147 @@
package com.mogo.module.v2x.marker;
import android.content.Context;
import android.graphics.Bitmap;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import java.util.ArrayList;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-1015:55
* desc : V2X 地图气泡
* version: 1.0
*/
public class V2XMarkerAdapter {
/**
* 返回道路事件
*/
public static Bitmap getV2XRoadEventMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
return new V2XMarkerRoadEventView(context, alarmInfo).getView();
}
/**
* 返回道路事件
*/
public static Bitmap getV2XRoadEventMarkerView(Context context, V2XRoadEventEntity alarmInfo, int imageRes) {
return new V2XMarkerRoadEventView(context, alarmInfo).setBackground(imageRes).getView();
}
/**
* 返回道路事件静态的图因为D车机性能不行会卡顿
*/
public static Bitmap getV2XRoadEventViewPng(Context context, V2XRoadEventEntity alarmInfo) {
Bitmap bitmap;
switch (alarmInfo.getPoiType()) {
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
bitmap = getV2XRoadEventMarkerView(
context,
alarmInfo,
R.drawable.v_to_x_warning_circle_orange_00009);
break;
default:
bitmap = getV2XRoadEventMarkerView(
context,
alarmInfo,
R.drawable.v_to_x_warning_circle_red_00009);
break;
}
return bitmap;
}
/**
* 返回道路事件gif序列图集合
*/
public static ArrayList<Bitmap> getV2XRoadEventViewGif(Context context, V2XRoadEventEntity alarmInfo) {
ArrayList<Bitmap> bitmapArrayList;
switch (alarmInfo.getPoiType()) {
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
bitmapArrayList = getV2XRoadEventOrangeMarkerView(context, alarmInfo);
break;
default:
bitmapArrayList = getV2XRoadEventRedMarkerView(context, alarmInfo);
break;
}
return bitmapArrayList;
}
/**
* 返回红色扩散效果的序列
*/
public static ArrayList<Bitmap> getV2XRoadEventRedMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
ArrayList<Bitmap> icons = new ArrayList<>();
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00000));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00001));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00002));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00003));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00004));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00005));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00006));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00007));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00008));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00009));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00010));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00011));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00012));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00013));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00015));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00017));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00018));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00020));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00023));
return icons;
}
/**
* 返回橘色色扩散效果的序列
*/
public static ArrayList<Bitmap> getV2XRoadEventOrangeMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
ArrayList<Bitmap> icons = new ArrayList<>();
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00000));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00001));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00002));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00003));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00004));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00005));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00006));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00007));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00008));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00009));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00010));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00011));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00012));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00013));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00015));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00017));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00018));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00019));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00020));
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00023));
return icons;
}
/**
* 获取模拟点
*
* @param context 上下文
* @return MarkerView
*/
public static Bitmap getV2XCarMarkerView(Context context, MarkerShowEntity showEntity) {
if (showEntity.isChecked()) {
return new V2XMarkerCarInfoView(context, showEntity).getView();
} else {
return new V2XMarkerCarView(context, showEntity).getView();
}
}
}

View File

@@ -0,0 +1,145 @@
package com.mogo.module.v2x.marker
import android.content.Context
import android.graphics.Bitmap
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.module.common.entity.MarkerOnlineCar
import com.mogo.module.common.entity.MarkerShowEntity
import com.mogo.module.service.utils.ViewUtils
import com.mogo.module.v2x.R
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity
import com.mogo.module.common.entity.V2XPoiTypeEnum
import kotlinx.android.synthetic.main.view_marker_car.view.*
import kotlinx.android.synthetic.main.view_marker_car_info.view.*
import kotlinx.android.synthetic.main.view_marker_car_info.view.ivCar
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-0619:55
* desc : 绘制在线车辆,特殊车辆
* version: 1.0
*/
class V2XMarkerCarInfoView(context: Context, showEntity: MarkerShowEntity) :
ConstraintLayout(context) {
init {
initView(context, showEntity)
}
private fun initView(context: Context, showEntity: MarkerShowEntity) {
val bindObj: Any = showEntity.bindObj
if (bindObj is MarkerOnlineCar) {
//1 老司机 2 安全驾驶 3 危险驾驶 4 可直播车辆
when (bindObj.userInfo.safeLabelType) {
// 可直播车机
4 -> {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_car, this)
ivMarkerTip.setImageResource(R.drawable.v_to_x_marker_car_live_vedio)
}
else -> {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_car_info, this)
}
}
}
if (bindObj is V2XMarkerEntity) {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_car, this)
}
updateUI(showEntity)
}
fun updateUI(showEntity: MarkerShowEntity) {
ivCar.rotation = showEntity.markerLocation.angle.toFloat()
// ivCar.rotation = 90f
tvUserMarker.text = if (TextUtils.isEmpty(showEntity.textContent)) {
""
} else {
showEntity.textContent
}
val bindObj: Any = showEntity.bindObj
if (bindObj is MarkerOnlineCar) {
tvMarkerContent.text =
if (bindObj.userInfo == null && TextUtils.isEmpty(bindObj.userInfo.userName)) {
"蘑菇车主"
} else {
bindObj.userInfo.userName
}
//车辆类型,0-普通车辆1-警车2-救护车3-道路救援车辆',
when (bindObj.carInfo.vehicleType) {
// 普通车
0 -> {
clMarkerContent.visibility = View.VISIBLE
ivReverseTriangle.visibility = View.VISIBLE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
// 警车
1 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_police)
}
// 救护车
2 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_ambulance)
}
// 道路救援车辆
3 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
else -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
}
}
if (bindObj is V2XMarkerEntity) {
when (bindObj.targetId) {
10001 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
10002 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_ambulance)
}
10003 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_police)
}
//失控车
10004 -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
// 故障车
V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING -> {
clMarkerContent.visibility = View.GONE
ivReverseTriangle.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
}
}
}
fun getView(): Bitmap {
return ViewUtils.fromView(this)
}
}

View File

@@ -0,0 +1,115 @@
package com.mogo.module.v2x.marker
import android.content.Context
import android.graphics.Bitmap
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.module.common.entity.MarkerOnlineCar
import com.mogo.module.common.entity.MarkerShowEntity
import com.mogo.module.service.utils.ViewUtils
import com.mogo.module.v2x.R
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity
import com.mogo.module.common.entity.V2XPoiTypeEnum
import kotlinx.android.synthetic.main.view_marker_car.view.*
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-0619:55
* desc : 绘制在线车辆,特殊车辆
* version: 1.0
*/
class V2XMarkerCarView(context: Context, showEntity: MarkerShowEntity) :
ConstraintLayout(context) {
init {
initView(context, showEntity)
}
private fun initView(context: Context, showEntity: MarkerShowEntity) {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_car, this)
updateUI(showEntity)
}
fun updateUI(showEntity: MarkerShowEntity) {
ivCar.rotation = showEntity.markerLocation.angle.toFloat()
val bindObj: Any = showEntity.bindObj
if (bindObj is MarkerOnlineCar) {
//1 老司机 2 安全驾驶 3 危险驾驶 4 可直播车辆
when (bindObj.userInfo.safeLabelType) {
1 -> {
ivMarkerTip.setImageResource(R.drawable.v_to_x_marker_car_blue)
}
2 -> {
ivMarkerTip.setImageResource(R.drawable.v_to_x_marker_car_green)
}
3 -> {
ivMarkerTip.setImageResource(R.drawable.v_to_x_marker_car_red)
}
4 -> {
ivMarkerTip.setImageResource(R.drawable.v_to_x_marker_car_live_vedio)
}
}
//车辆类型,0-普通车辆1-警车2-救护车3-道路救援车辆',
when (bindObj.carInfo.vehicleType) {
// 普通车
0 -> {
ivMarkerTip.visibility = View.VISIBLE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
// 警车
1 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_police)
}
// 救护车
2 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_ambulance)
}
// 道路救援车辆
3 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
else -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
}
}
if (bindObj is V2XMarkerEntity) {
when (bindObj.targetId) {
10001 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_gray)
}
10002 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_ambulance)
}
10003 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.icon_car_police)
}
10004 -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
// 故障车
V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING -> {
ivMarkerTip.visibility = View.GONE
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
}
}
}
fun getView(): Bitmap {
return ViewUtils.fromView(this)
}
}

View File

@@ -0,0 +1,126 @@
package com.mogo.module.v2x.marker
import android.content.Context
import android.graphics.Bitmap
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.module.service.utils.ViewUtils
import com.mogo.module.v2x.R
import com.mogo.module.common.entity.V2XPoiTypeEnum
import com.mogo.module.common.entity.V2XRoadEventEntity
import kotlinx.android.synthetic.main.view_marker_event_car.view.*
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-0619:55
* desc :
* 3、道路事件
* 2.18 演示 :驾驶模式中地图展示“拥堵“、“施工”;
* ADAS模式下还包含 原有的拥堵、交通检查、封路事件)
* version: 1.0
*/
class V2XMarkerRoadEventView(context: Context, alarmInfo: V2XRoadEventEntity) :
ConstraintLayout(context) {
val TAG = "V2XMarkerRoadEventView"
init {
initView(context, alarmInfo)
}
fun initView(context: Context, alarmInfo: V2XRoadEventEntity) {
if (alarmInfo.poiType == V2XPoiTypeEnum.ALERT_FRONT_CAR ||
alarmInfo.poiType == V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING.toString()
) {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_event_car, this)
} else {
LayoutInflater.from(context)
.inflate(R.layout.view_marker_event_road, this)
}
updateIcon(alarmInfo)
}
/**
* @see V2XPoiTypeEnum
*/
private fun updateIcon(alarmInfo: V2XRoadEventEntity) {
//Logger.d(MODULE_NAME, alarmInfo.toString())
// 道路施工、积水、路面结冰、浓雾、事故、拥堵
when (alarmInfo.poiType) {
//交通检查
V2XPoiTypeEnum.TRAFFIC_CHECK -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_2)
}
//封路
V2XPoiTypeEnum.ROAD_CLOSED -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_16)
}
//施工
V2XPoiTypeEnum.FOURS_ROAD_WORK -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_11)
}
//拥堵
V2XPoiTypeEnum.FOURS_BLOCK_UP -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_5)
}
//积水
V2XPoiTypeEnum.FOURS_PONDING -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_6)
}
//浓雾
V2XPoiTypeEnum.FOURS_FOG -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_9)
}
//结冰
V2XPoiTypeEnum.FOURS_ICE -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_8)
}
//事故
V2XPoiTypeEnum.FOURS_ACCIDENT -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_7)
}
//红绿灯数据
V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_3)
}
//红绿灯数据
V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_3)
}
//前方静止or慢速车辆报警
V2XPoiTypeEnum.ALERT_FRONT_CAR -> {
ivCar.setImageResource(R.drawable.v_to_x_warning_car_red)
}
// 故障车辆
V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING.toString() -> {
ivCar.setImageResource(R.drawable.icon_car_red)
ivCarTop.visibility = View.VISIBLE
}
// 取快递
V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_express)
ivBg.visibility = View.GONE
}
// 顺风车
V2XPoiTypeEnum.ALERT_TRAFFIC_TAXI -> {
ivCar.setImageResource(R.drawable.v_to_x_marker_taxi)
ivBg.visibility = View.GONE
}
}
}
/**
* 背景
*/
fun setBackground(imageRes: Int): V2XMarkerRoadEventView {
ivBg.setImageResource(imageRes)
return this
}
fun getView(): Bitmap {
return ViewUtils.fromView(this)
}
}

View File

@@ -0,0 +1,23 @@
package com.mogo.module.v2x.network
import com.mogo.commons.debug.DebugConfig
class HttpConstant {
companion object {
const val HOST_DEV = "http://dzt-test.zhidaohulian.com"
const val HOST_TEST = "http://dzt-test.zhidaohulian.com"
const val HOST_DEMO = "http://dzt-show.zhidaohulian.com"
const val HOST_PRODUCT = "https://dzt.zhidaohulian.com"
fun getNetHost(): String {
return when (DebugConfig.getNetMode()) {
DebugConfig.NET_MODE_DEV -> HOST_DEV
DebugConfig.NET_MODE_QA -> HOST_TEST
DebugConfig.NET_MODE_DEMO -> HOST_DEMO
else -> HOST_PRODUCT
}
}
}
}

View File

@@ -0,0 +1,111 @@
package com.mogo.module.v2x.network;
import com.mogo.commons.data.BaseData;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.v2x.entity.net.V2XUserInfoRes;
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
import com.mogo.module.v2x.entity.net.V2XLiveCarRes;
import com.mogo.module.v2x.entity.net.V2XLivePushVoRes;
import com.mogo.module.v2x.entity.net.V2XSeekHelpRes;
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
/**
* @author congtaowang
* @since 2020-01-03
* <p>
* 接口描述
*/
public interface V2XApiService {
/**
* 直播心跳
*/
@FormUrlEncoded
@POST("/dataService/integratedServices/app/push/no/heartbeat/v1")
Observable<BaseData> refreshHeartBeat(@FieldMap Map<String, String> liveBroadcast);
/**
* 刷新地图气泡点
*/
@FormUrlEncoded
@POST("/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync")
Observable<BaseData> querySnapshotAsync(@FieldMap Map<String, Object> parameters);
/**
* 直播点赞
*/
@FormUrlEncoded
@POST("/yycp-geo-fence-carService/restrictedRules/car/liveBroadcastPraise")
Observable<BaseData> giveLikeLiveVideo(@FieldMap Map<String, Object> parameters);
/**
* 同过SN获取用户信息
*/
@Headers({"Content-Type:application/json", "Accept:application/json"})
@POST("/yycp-realtimeLocations/realTimeLocationServer/queryUserInfoBySn")
Observable<V2XUserInfoRes> queryUserInfoBySn(@Body RequestBody jsonStr);
/**
* 车辆故障求助查询
*
* @param param
* @return
*/
@FormUrlEncoded
@POST("/yycp-realtimeLocations/vehicleTypeManage/car/queryVehicleType/v1")
Observable<V2XSeekHelpRes> queryHelpSignal(@FieldMap Map<String, Object> param);
/**
* 车辆故障求助查询
*
* @param param
* @return
*/
@FormUrlEncoded
@POST("/yycp-realtimeLocations/vehicleTypeManage/car/updateVehicleType/v1")
Observable<BaseData> sendHelpSignal(@FieldMap Map<String, Object> param);
/**
* 根据经纬度查询附近可直播车机直播信息
*/
@FormUrlEncoded
@POST("/yycp-realtimeLocations/realTimeLocationServer/car/queryNearbyVehicleLiveByLocation/v1")
Observable<V2XLiveCarRes> queryNearbyVehicleLiveByLocation(@FieldMap Map<String, Object> parameters);
/**
* 推流与停止推流接口
*/
@FormUrlEncoded
@POST("/dataService/integratedServices/app/push/no/livePush/v1")
Observable<V2XLivePushVoRes> livePush(@FieldMap Map<String, Object> parameters);
/**
* TODO 查询演示车用户信息
*/
@GET("/yycp-launcherSnapshot/mock/getMockUserInfos")
Observable<V2XDemoUserInfoRes> getMockUserInfos();
/**
* 根据名称获取策略详情
*/
@GET("/yycp-strategyPush/push/strategy/item?name=TIRE_DRIVING")
Observable<V2XStrategyPushRes> getStrategyPush();
/**
* 违章地段查询接口
*/
@FormUrlEncoded
@POST("/yycp-launcherSnapshot/launcherSnapshot/queryIllegalPark")
Observable<MarkerResponse> queryIllegalPark(@FieldMap Map<String, Object> parameters);
}

View File

@@ -0,0 +1,14 @@
package com.mogo.module.v2x.network;
/**
* @author congtaowang
* @since 2020-01-03
* <p>
* 刷新回调
*/
public interface V2XRefreshCallback<T> {
void onSuccess(T result);
void onFail(String msg);
}

View File

@@ -0,0 +1,477 @@
package com.mogo.module.v2x.network;
import android.content.Context;
import android.text.TextUtils;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.ParamsProvider;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.map.MogoLatLng;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.network.RefreshBody;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
import com.mogo.module.v2x.entity.net.V2XLiveCarBroadcastReq;
import com.mogo.module.v2x.entity.net.V2XLiveCarRes;
import com.mogo.module.v2x.entity.net.V2XLivePushVoRes;
import com.mogo.module.v2x.entity.net.V2XSeekHelpRes;
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
import com.mogo.module.v2x.entity.net.V2XUserInfoRes;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.zhidao.utils.common.GsonUtil;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;
/**
* 数据接口API
*
* @author donghongyu
* @since 2020-01-03
*/
public class V2XRefreshModel {
private Context mContext;
private V2XApiService mV2XApiService;
private static V2XRefreshModel mV2XRefreshModel;
private V2XRefreshModel() {
}
public synchronized static V2XRefreshModel getInstance(Context context) {
if (mV2XRefreshModel == null) {
synchronized (V2XRefreshModel.class) {
if (mV2XRefreshModel == null) {
mV2XRefreshModel = new V2XRefreshModel();
mV2XRefreshModel.init(context);
}
}
}
return mV2XRefreshModel;
}
private void init(Context context) {
this.mContext = context;
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(context);
this.mV2XApiService = network.create(V2XApiService.class, HttpConstant.Companion.getNetHost());
}
/**
* 刷新地图点数据
*/
public void querySnapshotAsync(MogoLatLng latLng, int radius, int limit) {
if (mV2XApiService != null) {
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
final RefreshBody refreshBody = new RefreshBody();
refreshBody.limit = limit;
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
refreshBody.radius = radius;
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
refreshBody.viewPush = true;
query.put("data", GsonUtil.jsonFromObject(refreshBody));
mV2XApiService.querySnapshotAsync(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
});
}
}
/**
* 触发刷新直播心跳
*
* @param sn 目标车机SN
* @param videoChannel 直播的频道
* @param callback 回调
*/
public void refreshHeartBeat(String sn, String videoChannel, final V2XRefreshCallback callback) {
if (mV2XApiService != null) {
Map<String, String> liveBroadcast = new HashMap<>();
liveBroadcast.put("sn", sn);
liveBroadcast.put("data", GsonUtil.getGson().toJson(new V2XLiveCarBroadcastReq(sn, videoChannel)));
mV2XApiService.refreshHeartBeat(liveBroadcast)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 直播点赞👍
*
* @param callback 回调
*/
public void giveLikeLiveVideo(final V2XRefreshCallback callback, String snStr) {
if (mV2XApiService != null) {
Logger.d(V2XConst.MODULE_NAME, "点赞车机:" + snStr);
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
query.put("data", "{\"sn\":" + snStr + "}");
mV2XApiService.giveLikeLiveVideo(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 获取用户信息
*
* @param sn 目标车机SN
*/
public void queryUserInfoBySn(String sn, final V2XRefreshCallback<V2XUserInfoRes> callback) {
if (mV2XApiService != null) {
RequestBody body = RequestBody.create(
okhttp3.MediaType.parse("application/json; charset=utf-8"),
"{\"sn\":\"" + sn + "\"}");
mV2XApiService.queryUserInfoBySn(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XUserInfoRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XUserInfoRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 根据经纬度查询附近可直播车机直播信息
*
* @param callback 回调
*/
public void queryNearbyVehicleLiveByLocation(
V2XRefreshCallback<V2XLiveCarRes> callback, double lon, double lat) {
if (mV2XApiService != null) {
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
StringBuffer dataStr = new StringBuffer();
dataStr.append("{");
dataStr.append("\"lon\":");
dataStr.append(lon);
dataStr.append(",");
dataStr.append("\"lat\":");
dataStr.append(lat);
dataStr.append(",");
dataStr.append("\"radius\":");
dataStr.append(0.5);
dataStr.append(",");
dataStr.append("\"size\":");
dataStr.append(5);
dataStr.append("}");
query.put("data", dataStr.toString());
mV2XApiService.queryNearbyVehicleLiveByLocation(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XLiveCarRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XLiveCarRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 推流与停止推流接口
*
* @param callback 回调
*/
public void livePush(V2XRefreshCallback<V2XLivePushVoRes> callback, String sn, int playType) {
if (mV2XApiService != null) {
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
query.put("data", "{" +
"\"eventId\": \"yycp\"," +
"\"sn\": \"" + sn + "\"," +
"\"type\": \"" + playType + "\"," +
"\"videoChannel\": \"C_1\"" +
"}");
mV2XApiService.livePush(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XLivePushVoRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XLivePushVoRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 取消求助
*
* @param callback
*/
public void cancelHelpSignal(V2XRefreshCallback<BaseData> callback) {
if (mV2XApiService != null) {
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
String json = new StringBuilder()
.append("{")
.append("\"sn\":").append(Utils.getSn())
.append(",")
.append("\"vehicleType\":")
.append(0)
.append("}").toString();
map.put("data", json);
mV2XApiService.sendHelpSignal(map).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 查询当前车辆故障求助状态
*
* @param callback
*/
public void getHelpSignal(V2XRefreshCallback<V2XSeekHelpRes> callback) {
if (mV2XApiService != null) {
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
map.put("sn", Utils.getSn());
mV2XApiService.queryHelpSignal(map).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XSeekHelpRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XSeekHelpRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* TODO 演示需求
*
* @param callback
*/
public void getMockUserInfos(V2XRefreshCallback<V2XDemoUserInfoRes> callback) {
if (mV2XApiService != null) {
mV2XApiService.getMockUserInfos().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XDemoUserInfoRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XDemoUserInfoRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 根据名称获取策略详情
*/
public void getStrategyPush(V2XRefreshCallback<V2XStrategyPushRes> callback) {
if (mV2XApiService != null) {
mV2XApiService.getStrategyPush().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<V2XStrategyPushRes>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(V2XStrategyPushRes o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
/**
* 违章地段查询接口
*/
public void queryIllegalPark(V2XRefreshCallback<MarkerResponse> callback, double lon, double lat) {
if (mV2XApiService != null) {
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
String json = "{\"location\":{\"lat\":" + lat + ",\"lon\":" + lon + "},\"radius\":50}";
// String json = "{\"location\":{\"lat\":39.968139,\"lon\":116.380476},\"radius\":1000}";
map.put("data", json);
mV2XApiService.queryIllegalPark(map).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(MarkerResponse o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
if (TextUtils.isEmpty(message)) {
message = "网络错误,请稍后重试";
}
callback.onFail(message);
}
}
});
}
}
}

View File

@@ -0,0 +1,32 @@
package com.mogo.module.v2x.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
/**
* 场景广播接收,道路预警、后台下发、违章停车、故障求助、疲劳驾驶
*
* @author donghongyu
*/
public class SceneBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = V2XConst.MODULE_NAME + "_SceneBroadcastReceiver";
@Override
public void onReceive(Context context, Intent intent) {
try {
V2XMessageEntity v2XMessageEntity = (V2XMessageEntity) intent.getSerializableExtra("V2XMessageEntity");
Logger.d(TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,71 @@
package com.mogo.module.v2x.scenario;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.module.common.entity.V2XMessageEntity;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 4:13 PM
* desc : V2X安全驾驶场景接口
* version: 1.0
*/
public interface IV2XScenario {
/**
* 展示场景
*/
void show();
/**
* 关闭场景
*/
void close();
/**
* 展示Window
*/
void showWindow();
/**
* 关闭Window
*/
void closeWindow();
/**
* 展示按钮
*/
void showButton();
/**
* 关闭按钮
*/
void closeButton();
/**
* 绘制POI
*/
void drawPOI();
/**
* 清除POI
*/
void clearPOI();
/**
* 是否是相同的场景,如果是说明重复的场景,需要根据场景进行不同的处理
*
* @param v2XMessageEntity 要比较的场景
* @return true-相同的场景false-不同场景
*/
boolean isSameScenario(V2XMessageEntity v2XMessageEntity);
/**
* 调用小智语音播放TTS
*
* @param msg 消息
* @param callBack 播放回调
*/
void speakTTSVoice(String msg, IMogoVoiceCmdCallBack callBack);
}

View File

@@ -0,0 +1,14 @@
package com.mogo.module.v2x.scenario;
import com.mogo.module.common.entity.V2XMessageEntity;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 3:47 PM
* desc : V2X安全驾驶场景管理
* version: 1.0
*/
public interface IV2XScenarioManager {
void handlerMessage(V2XMessageEntity v2XMessageEntity);
}

View File

@@ -0,0 +1,89 @@
package com.mogo.module.v2x.scenario.impl;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.commons.voice.VoicePreemptType;
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.IV2XScenario;
import com.mogo.module.v2x.scenario.view.IV2XButton;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.utils.logger.Logger;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:01 PM
* desc :
* version: 1.0
*/
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;
protected AbsV2XScenario() {
this.mV2XStatusManager = V2XServiceManager.getMoGoV2XStatusManager();
}
public abstract void init(@Nullable V2XMessageEntity<T> v2XMessageEntity);
@Override
public void close() {
closeButton();
closeWindow();
clearPOI();
}
@Override
public void speakTTSVoice(@Nullable String msg, IMogoVoiceCmdCallBack callBack) {
if (!TextUtils.isEmpty(msg)) {
Logger.w(V2XConst.MODULE_NAME, "调用TTS播放语音" + msg);
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice(msg, VoicePreemptType.PREEMPT_TYPE_IMMEADIATELY, callBack);
}
}
public IV2XWindow getV2XWindow() {
return mV2XWindow;
}
public void setV2XWindow(@Nullable IV2XWindow mV2XWindow) {
this.mV2XWindow = mV2XWindow;
}
public void setV2XButton(@Nullable IV2XButton mV2XButton) {
this.mV2XButton = mV2XButton;
}
public void setV2XMarker(@Nullable IV2XMarker mV2XMarker) {
this.mV2XMarker = mV2XMarker;
}
public void setV2XMessageEntity(@Nullable V2XMessageEntity<T> mV2XMessageEntity) {
this.mV2XMessageEntity = mV2XMessageEntity;
}
public V2XMessageEntity<T> getV2XMessageEntity() {
return mV2XMessageEntity;
}
@Override
public boolean isSameScenario(@Nullable V2XMessageEntity v2XMessageEntity) {
if (mV2XMessageEntity == null) {
return false;
}
return mV2XMessageEntity.equals(v2XMessageEntity);
}
}

View File

@@ -0,0 +1,111 @@
package com.mogo.module.v2x.scenario.impl;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.scenario.IV2XScenarioManager;
import com.mogo.module.v2x.scenario.scene.animation.V2XAnimationScenario;
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
import com.mogo.module.v2x.scenario.scene.help.V2XCarForHelpScenario;
import com.mogo.module.v2x.scenario.scene.livecar.V2XPushLiveCarScenario;
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.utils.common.GsonUtil;
import java.util.HashMap;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 4:22 PM
* desc : 场景管理的分发
* version: 1.0
*/
public class V2XScenarioManager implements IV2XScenarioManager {
private static V2XScenarioManager mV2XScenarioManager;
private AbsV2XScenario mV2XScenario;
private HashMap<Integer, AbsV2XScenario> mV2XScenarioSet = new HashMap<>();
private V2XScenarioManager() {
}
public static V2XScenarioManager getInstance() {
if (mV2XScenarioManager == null) {
synchronized (V2XScenarioManager.class) {
if (mV2XScenarioManager == null) {
mV2XScenarioManager = new V2XScenarioManager();
}
}
}
return mV2XScenarioManager;
}
@Override
public void handlerMessage(V2XMessageEntity v2XMessageEntity) {
Logger.w(MODULE_NAME, "处理V2X场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
synchronized (V2XScenarioManager.class) {
// 展示
V2XUtils.runOnUiThread(() -> {
// 提取之前存储的场景
if (v2XMessageEntity != null) {
// 广播给应用内部其它模块
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
mV2XScenario = mV2XScenarioSet.get(v2XMessageEntity.getType());
// 如果没有拿到之前的,根据类型分发
if (mV2XScenario == null) {
switch (v2XMessageEntity.getType()) {
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
mV2XScenario = V2XRoadEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
mV2XScenario = V2XSeekHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
mV2XScenario = V2XFatigueDrivingScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
mV2XScenario = V2XPushEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_LIVE_CAR_WARNING:
mV2XScenario = V2XPushLiveCarScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ANIMATION_WARNING:
mV2XScenario = V2XAnimationScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP:
mV2XScenario = V2XCarForHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING:
mV2XScenario = V2XIllegalParkScenario.getInstance();
break;
default:
ToastUtils.showLong("当前V2X消息类型未定义。");
return;
}
}
// 展示最新的消息
if (mV2XScenario != null) {
mV2XScenario.init(v2XMessageEntity);
mV2XScenarioSet.put(v2XMessageEntity.getType(), mV2XScenario);
}
}
});
}
}
}

View File

@@ -0,0 +1,121 @@
package com.mogo.module.v2x.scenario.scene.animation;
import androidx.annotation.Nullable;
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.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.utils.logger.Logger;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : 场景动画的场景展示目前这里仅在演示DEMO中使用
* version: 1.0
*/
public class V2XAnimationScenario extends AbsV2XScenario<V2XPushMessageEntity> {
private static V2XAnimationScenario mV2XAnimationScenario;
private V2XAnimationScenario() {
}
public static V2XAnimationScenario getInstance() {
if (mV2XAnimationScenario == null) {
synchronized (V2XAnimationScenario.class) {
if (mV2XAnimationScenario == null) {
mV2XAnimationScenario = new V2XAnimationScenario();
mV2XAnimationScenario.setV2XWindow(new V2XAnimationWindow());
}
}
}
return mV2XAnimationScenario;
}
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
if (!isSameScenario(v2XMessageEntity)
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
boolean isV2XAnimationShow = V2XServiceManager.getMoGoV2XStatusManager().isV2XAnimationShow();
if (isV2XAnimationShow) {
close();
}
setV2XMessageEntity(v2XMessageEntity);
show();
} else {
setV2XMessageEntity(v2XMessageEntity);
Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
}
}
@Override
public void show() {
showWindow();
}
@Override
public void showWindow() {
if (mV2XWindow != null) {
mV2XWindow.setWindowStatusListener(new V2XWindowStatusListener() {
@Override
public void onViewShow() {
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), mV2XMessageEntity.getContent());
}
@Override
public void onViewClose() {
closeWindow();
clearPOI();
}
});
mV2XWindow.show(mV2XMessageEntity.getContent());
V2XServiceManager
.getIMogoWindowManager()
.addView(mV2XWindow.getView(), 0, 0, false);
V2XServiceManager.getMoGoV2XStatusManager().setV2XAnimationWindowShow(TAG, true);
}
}
@Override
public void closeWindow() {
if (mV2XWindow != null) {
mV2XWindow.close();
}
V2XServiceManager.getMoGoV2XStatusManager().setV2XAnimationWindowShow(TAG, false);
}
@Override
public void showButton() {
if (mV2XButton != null) {
mV2XButton.show();
}
}
@Override
public void closeButton() {
if (mV2XButton != null) {
mV2XButton.close();
}
}
@Override
public void drawPOI() {
if (mV2XMarker != null) {
mV2XMarker.drawPOI(mV2XMessageEntity.getContent());
}
}
@Override
public void clearPOI() {
setV2XMessageEntity(null);
if (mV2XMarker != null) {
mV2XMarker.clearPOI();
}
}
}

Some files were not shown because too many files have changed in this diff Show More