Merge branch 'dev' of gitlab.zhidaoauto.com:ecos/yycp-service/Launcher into dev

This commit is contained in:
wangcongtao
2020-08-07 11:37:49 +08:00
190 changed files with 3689 additions and 2836 deletions

3
.idea/gradle.xml generated
View File

@@ -29,8 +29,6 @@
<option value="$PROJECT_DIR$/modules/mogo-module-authorize" />
<option value="$PROJECT_DIR$/modules/mogo-module-back" />
<option value="$PROJECT_DIR$/modules/mogo-module-common" />
<option value="$PROJECT_DIR$/modules/mogo-module-event-panel" />
<option value="$PROJECT_DIR$/modules/mogo-module-event-panel-noop" />
<option value="$PROJECT_DIR$/modules/mogo-module-extensions" />
<option value="$PROJECT_DIR$/modules/mogo-module-gps-simulator" />
<option value="$PROJECT_DIR$/modules/mogo-module-gps-simulator-debug" />
@@ -40,6 +38,7 @@
<option value="$PROJECT_DIR$/modules/mogo-module-main" />
<option value="$PROJECT_DIR$/modules/mogo-module-map" />
<option value="$PROJECT_DIR$/modules/mogo-module-media" />
<option value="$PROJECT_DIR$/modules/mogo-module-monitor" />
<option value="$PROJECT_DIR$/modules/mogo-module-obu" />
<option value="$PROJECT_DIR$/modules/mogo-module-push" />
<option value="$PROJECT_DIR$/modules/mogo-module-push-base" />

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -273,6 +273,7 @@ dependencies {
implementation rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.modulesplash
implementation rootProject.ext.dependencies.moduleV2x
implementation rootProject.ext.dependencies.mogomonitor
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
@@ -284,12 +285,12 @@ dependencies {
implementation project(':modules:mogo-module-service')
implementation project(':modules:mogo-module-splash')
implementation project(':modules:mogo-module-v2x')
implementation project(':modules:mogo-module-monitor')
}
apply from: "./functions/baseservices.gradle"
apply from: "./functions/socketpush.gradle"
apply from: "./functions/gpssimulator.gradle"
apply from: "./functions/eventpanel.gradle"
apply from: "./functions/leftpanel.gradle"
}

View File

@@ -1,25 +0,0 @@
// 道路事件操作面板
project.dependencies {
if (Boolean.valueOf(RELEASE)) {
d8xxImplementation rootProject.ext.dependencies.moduleventpanelnoop
d82xImplementation rootProject.ext.dependencies.moduleventpanelnoop
em1Implementation rootProject.ext.dependencies.moduleventpanelnoop
bydautoImplementation rootProject.ext.dependencies.moduleventpanelnoop
em4Implementation rootProject.ext.dependencies.moduleventpanelnoop
e8xxImplementation rootProject.ext.dependencies.moduleventpanelnoop
f8xxImplementation rootProject.ext.dependencies.moduleventpanelnoop
em3Implementation rootProject.ext.dependencies.moduleventpanelnoop
} else {
d8xxImplementation project(':modules:mogo-module-event-panel-noop')
d82xImplementation project(':modules:mogo-module-event-panel-noop')
em1Implementation project(':modules:mogo-module-event-panel-noop')
bydautoImplementation project(':modules:mogo-module-event-panel-noop')
em4Implementation project(':modules:mogo-module-event-panel-noop')
e8xxImplementation project(':modules:mogo-module-event-panel-noop')
f8xxImplementation project(':modules:mogo-module-event-panel-noop')
em3Implementation project(':modules:mogo-module-event-panel-noop')
}
}

View File

@@ -29,7 +29,6 @@ import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.mogo.module.event.panel.EventPanelConstants;
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
/**
@@ -67,11 +66,11 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );
MogoModulePaths.addModule( new MogoModule( EventPanelConstants.PATH_NAME, EventPanelConstants.MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( LeftPanelConst.PATH_NAME, LeftPanelConst.MODULE_NAME ) );
MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.PATH_V2X_UI ) );
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) );
MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) );
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );
if ( !DebugConfig.isLauncher() ) {

View File

@@ -21,6 +21,7 @@ targetSdkVersion : 22,
androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
androidxcardview : "androidx.cardview:cardview:1.0.0",
localbroadcastmanager : "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0",
// flexbox
flexbox : 'com.google.android:flexbox:2.0.1',
// 测试
@@ -76,7 +77,7 @@ targetSdkVersion : 22,
roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1",
// material
material : 'com.google.android.material:material:1.0.0',
material : 'com.google.android.material:material:1.1.0',
// modules
@@ -174,6 +175,8 @@ targetSdkVersion : 22,
mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}",
// loglib
mogologlib : "com.mogo.module:module-loglib:${LOGLIB_VERSION}",
// monitor
mogomonitor : "com.mogo.module:module-monitor:${MOGO_MODULE_MONITOR_VERSION}",
// google
googlezxing : "com.google.zxing:core:3.3.3",

View File

@@ -37,8 +37,9 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
mRootView = inflater.inflate( getLayoutId(), container, false );
} else {
ViewGroup viewGroup = ( ViewGroup ) mRootView.getParent();
if ( viewGroup != null )
if ( viewGroup != null ) {
viewGroup.removeView( mRootView );
}
}
mRootView = inflater.inflate(getLayoutId(), container, false);
return mRootView;

View File

@@ -1,432 +0,0 @@
package com.mogo.utils.sqlite
import android.content.ContentValues
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import com.mogo.utils.logger.Logger
import com.mogo.utils.sqlite.annotation.DbField
import com.mogo.utils.sqlite.annotation.DbTable
import java.lang.reflect.Field
import java.util.*
/**
* <p>数据类操作实现</p>
*Created by donghongyu on 2019/9/6.
*/
//T必须指明上界是Any且不为null下面会用到反射获取对象实例默认是Any?
open class BaseDao<T : Any> : IBaseDao<T> {
private val TAG = "BaseDao"
//数据库操作的引用
private var sqLiteDatabase: SQLiteDatabase? = null
//要操作的数据实体的引用
private var entityClass: Class<T>? = null
//要操作的数据表名称
private var tableName: String? = null
//记录数据表是否存在
private var isInit = false
//因为反射会消耗时间,这里使用缓存,进行性能优化
//缓存空间key-字段名,标注的自定义注解 value-成员变量)
private var cacheField: HashMap<String, Field>? = null
override fun init(sqLiteDatabase: SQLiteDatabase, entityClass: Class<T>): Boolean {
this.sqLiteDatabase = sqLiteDatabase
this.entityClass = entityClass
//自动建表(只创建一次)
if (!isInit) {
//获取表名
tableName = entityClass.getAnnotation(DbTable::class.java).tableName
//如果数据库没有建立连接跳出操作防止异常信息
if (!sqLiteDatabase.isOpen) {
return false
}
//执行Sql进行自动建表
val createTableSql = getCreateTableSql()
Logger.d(TAG, "执行SQL$createTableSql")
sqLiteDatabase.execSQL(createTableSql)
//初始化缓存空间
cacheField = HashMap()
initCacheField()
//标记已经创建过数据表
isInit = true
}
return isInit
}
/**
* 初始化字段缓存
*/
private fun initCacheField() {
//1.取到所有的列名(查询一个空表获取表结构,不影响性能)
if (sqLiteDatabase != null && sqLiteDatabase!!.isOpen) {
val sqlQuery = "select * from $tableName limit 1,0"
val cursor = sqLiteDatabase!!.rawQuery(sqlQuery, null)
//获取所有的列名
val columnNames = cursor.columnNames
//关闭资源
cursor.close()
//2.取所有成员名
val columnFields = entityClass!!.declaredFields
//3.通过两层循环,进行对应关系建立
columnNames.forEach ColumnFor@{ columnName ->
columnFields.forEach FieldFor@{ columnField ->
if (columnName == columnField.getAnnotation(DbField::class.java).fieldName) {
columnField.isAccessible = true
cacheField!![columnName] = columnField
}
return@FieldFor
}
}
}
}
/**
* 拼装创建数据表的SQL语句
*/
private fun getCreateTableSql(): String? {
//create table if not exists tb_name(_id integer,name varchar2(20))
val sqlCreateTable = StringBuffer()
sqlCreateTable.append("create table if not exists ")
sqlCreateTable.append("$tableName (")
//反射获取所有的数据对象内的成员变量
val fields = entityClass!!.declaredFields
fields.forEachIndexed { index, field ->
//字段名称
val columnName = field.getAnnotation(DbField::class.java).fieldName
//获取成员变量数据类型
when (val fieldType = field.type) {
java.lang.String::class.java -> {
sqlCreateTable.append("$columnName TEXT,")
}
java.lang.Integer::class.java -> {
sqlCreateTable.append("$columnName INTEGER,")
}
java.lang.Long::class.java -> {
sqlCreateTable.append("$columnName BIGINT,")
}
java.lang.Double::class.java -> {
sqlCreateTable.append("$columnName DOUBLE,")
}
ByteArray::class.java -> {
sqlCreateTable.append("$columnName BLOB,")
}
else -> {
//未知类型
throw UnsupportedOperationException("未定义的数据类型fieldName= $columnName fieldType= $fieldType")
}
}
if (index == fields.size - 1) {
if (sqlCreateTable.endsWith(","))
sqlCreateTable.deleteCharAt(sqlCreateTable.length - 1)
}
}
sqlCreateTable.append(")")
return sqlCreateTable.toString()
}
/**
* 插入数据
*/
override fun insert(entity: T): Long {
//1、准备好ContentValues中的数据
//2、设置插入的内容
val values: ContentValues = getContentValuesForInsert(entity)
//3、执行插入
return if (sqLiteDatabase != null && sqLiteDatabase!!.isOpen) {
sqLiteDatabase!!.insert(tableName, null, values)
} else {
-1
}
}
/**
* 删除数据
*/
override fun delete(where: T): Int {
val condition = Condition(getContentValuesForQuery(where))
return if (sqLiteDatabase != null && sqLiteDatabase!!.isOpen) {
//受影响行数
sqLiteDatabase!!
.delete(
tableName,
condition.getWhereCause(),
condition.getWhereArgs()
)
} else {
-1
}
}
/**
* 更新数据
*/
override fun update(where: T, newEntity: T): Int {
val condition = Condition(getContentValuesForQuery(where))
return if (sqLiteDatabase != null && sqLiteDatabase!!.isOpen) {
//受影响行数
sqLiteDatabase!!
.update(
tableName,
getContentValuesForInsert(newEntity),
condition.getWhereCause(),
condition.getWhereArgs()
)
} else {
-1
}
}
/**
* 查询数据
* @param where 查询条件对象,同时也用来初始化对象使用
*/
override fun query(where: T): MutableList<T> {
return query(where, null, null, null)
}
/**
* 查询数据
* @param where 查询条件对象
* @param orderBy 排序规则
* @param startIndex 开始的位置
* @param limit 限制查询得到的数据个数
*/
fun query(where: T, orderBy: String?, startIndex: Int?, limit: Int?): MutableList<T> {
//拼接分页语句
var limitString: String? = null
if (startIndex != null && limit != null) {
limitString = "$startIndex,$limit"
}
val condition = Condition(getContentValuesForQuery(where))
var cursor: Cursor? = null
//定义查询结果
val result = mutableListOf<T>()
if (sqLiteDatabase != null && sqLiteDatabase!!.isOpen) {
try {
//查询数据库
cursor = sqLiteDatabase!!
.query(
tableName,
null,
condition.getWhereCause(),
condition.getWhereArgs(),
null,
null,
orderBy,
limitString
)
//将查到结果添加到返回集合中
result.addAll(getQueryResult(cursor, where))
} catch (e: Exception) {
e.printStackTrace()
} finally {
cursor?.close()
}
}
return result
}
/**
* 获取查询使用的ContentValues
*/
private fun getContentValuesForQuery(entity: T): ContentValues {
val contentValues = ContentValues()
try {
cacheField!!.forEach {
if (it.value.get(entity) == null) {
return@forEach
}
contentValues.put(it.key, it.value.get(entity).toString())
}
} catch (e: IllegalAccessError) {
e.printStackTrace()
}
return contentValues
}
/**
* 条件拼接
*/
class Condition(whereContent: ContentValues) {
/**
* 条件拼接
* _id=?&&name=?
*/
private var whereCause: String? = null
private var whereArgs: Array<String>? = null
//根据传入的contentValues转换成查询条件
init {
//记录后面填充到查询语句“?”上的数据参数
val argList = mutableListOf<String>()
//拼接查询语句
val whereCaseSb = StringBuilder()
/**
* 是为了链接下面的查询条件条件,也或者是替换没有查询条件的语句。
* 比如要把检索条件作为一个参数传递给SQL
* 那么当这个检索语句不存在的话就可以给它赋值为1=1.
* 这样就避免了SQL出错也就可以把加条件的SQL和不加条件的SQL合二为一。
*/
whereCaseSb.append(" 1=1 ")
val keys = whereContent.keySet()
val iterator = keys.iterator()
//因为使用了“1=1”所以即便是这里没有任何数据拼接也是可以正常
while (iterator.hasNext()) {
val key = iterator.next() as String
val valueObject = whereContent.get(key)
if (valueObject != null) {
val value = valueObject as String
//拼接查询条件语句
//1:1 and _id=? and name=?
whereCaseSb.append(" and $key =?")
//记录对应的value
argList.add(value)
}
}
//集合转成数组
this.whereArgs = argList.toTypedArray()
this.whereCause = whereCaseSb.toString()
}
fun getWhereCause(): String {
return this.whereCause!!
}
fun getWhereArgs(): Array<String> {
return this.whereArgs!!
}
}
/**
* 获取查询db结果
*/
private fun getQueryResult(cursor: Cursor, where: T): MutableList<T> {
//定义查询结果
val result = mutableListOf<T>()
//Cursor从头读到尾
//游标从头读到尾
cursor.moveToFirst()
//移动游标获取下一行数据
while (!cursor.isAfterLast) {
//通过反射构建一个查询结果对象
val item = where.javaClass.newInstance()
//拿到缓存的当前数据对象的成员变量与数据库的键值关系
val fieldIterator = cacheField!!.entries.iterator()
fieldIterator.forEach IteratorFor@{
//获取数据库字段名称
val columnName = it.key
//数据库字段名对应的数据对象的成员变量
val field = it.value
//获取指定列名对应的索引
val columnIndex = cursor.getColumnIndex(columnName)
//获取成员变量数据类型
val fieldType = field.type
if (columnIndex != -1) {
when (fieldType) {
java.lang.String::class.java -> {
field.set(item, cursor.getString(columnIndex))
}
java.lang.Integer::class.java -> {
field.set(item, cursor.getInt(columnIndex))
}
java.lang.Long::class.java -> {
field.set(item, cursor.getLong(columnIndex))
}
java.lang.Double::class.java -> {
field.set(item, cursor.getDouble(columnIndex))
}
ByteArray::class.java -> {
field.set(item, cursor.getBlob(columnIndex))
}
else -> {
//未知类型
throw UnsupportedOperationException("未定义的数据类型columnName= $columnName fieldType= $fieldType")
}
}
}
}
//添加到结果集
result.add(item)
//移动到下一个位置
cursor.moveToNext()
}
cursor.close()
return result
}
/**
* 获取插入使用的ContentValues
*/
private fun getContentValuesForInsert(entity: T): ContentValues {
val contentValues = ContentValues()
val fieldIterator = cacheField!!.entries.iterator()
fieldIterator.forEach IteratorFor@{
try {
//获取变量的值
val valueObject = it.value.get(entity) ?: return@IteratorFor
//获取列名
val columnName = it.key
//获取成员变量数据类型
val fieldType = it.value.type
when (fieldType) {
java.lang.String::class.java -> {
contentValues.put(columnName, valueObject as String)
}
java.lang.Integer::class.java -> {
contentValues.put(columnName, valueObject as Int)
}
java.lang.Long::class.java -> {
contentValues.put(columnName, valueObject as Long)
}
java.lang.Double::class.java -> {
contentValues.put(columnName, valueObject as Double)
}
ByteArray::class.java -> {
contentValues.put(columnName, valueObject as ByteArray)
}
else -> {
//未知类型
throw UnsupportedOperationException("未定义的数据类型columnName= $columnName fieldType= $fieldType")
}
}
} catch (e: IllegalArgumentException) {
e.printStackTrace()
}
}
Logger.d(TAG, "contentValues:$contentValues")
return contentValues
}
}

View File

@@ -1,35 +0,0 @@
package com.mogo.utils.sqlite
import android.database.sqlite.SQLiteDatabase
/**
* <p>操作SQLite数据库的顶层接口</p>
* Created by donghongyu on 2019/9/6.
*/
interface IBaseDao<T> {
/**
* 初始化数据库连接
*/
fun init(sqLiteDatabase: SQLiteDatabase, entityClass: Class<T>): Boolean
/**
* 将 [entity] 进行数据插入
*/
fun insert(entity: T): Long
/**
* 根据条件 [where] 进行数据删除
*/
fun delete(where: T): Int
/**
* 根据条件 [where] 进行数据更新,如果[where]==null 则代表删除所有数据
*/
fun update(where: T, newEntity: T): Int
/**
* 根据条件 [where] 进行数据查询,如果[where]==null 则代表查询所有数据
*/
fun query(where: T): MutableList<T>
}

View File

@@ -0,0 +1,462 @@
package com.mogo.utils.sqlite;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.sqlite.annotation.DbField;
import com.mogo.utils.sqlite.annotation.DbTable;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 数据库操作
*
* @param <T>
* @author donghongyu
*/
public class SQLBaseDao<T> implements SQLIDao<T> {
private String TAG = "SQLBaseDao";
//数据库操作的引用
private SQLiteDatabase sqLiteDatabase;
//要操作的数据实体的引用
private Class<T> entityClass;
//要操作的数据表名称
private String tableName;
//记录数据表是否存在
private boolean isInit = false;
//因为反射会消耗时间,这里使用缓存,进行性能优化
//缓存空间key-字段名,标注的自定义注解 value-成员变量)
private HashMap<String, Field> cacheField;
@Override
public boolean init(@NotNull SQLiteDatabase sqLiteDatabase, @NotNull Class<T> entityClass) {
this.sqLiteDatabase = sqLiteDatabase;
this.entityClass = entityClass;
//自动建表(只创建一次)
if (!isInit) {
//获取表名
tableName = entityClass.getAnnotation(DbTable.class).tableName();
//如果数据库没有建立连接跳出操作防止异常信息
if (!sqLiteDatabase.isOpen()) {
return false;
}
//执行Sql进行自动建表
String createTableSql = getCreateTableSql();
Logger.d(TAG, "执行SQL" + createTableSql);
sqLiteDatabase.execSQL(createTableSql);
//初始化缓存空间
cacheField = new HashMap();
initCacheField();
//标记已经创建过数据表
isInit = true;
}
return isInit;
}
/**
* 插入数据
*
* @param entity 要插入数据的数据对象爱你那个
* @return 插入结果ID如果发生错误则为-1
*/
@Override
public long insert(T entity) {
//1、准备好ContentValues中的数据
//2、设置插入的内容
ContentValues values = getContentValuesForInsert(entity);
//3、执行插入
long result;
if (sqLiteDatabase != null && sqLiteDatabase.isOpen()) {
result = sqLiteDatabase.insert(tableName, null, values);
} else {
result = -1;
}
return result;
}
/**
* 删除数据
*
* @param where 要删除的对象,对象的字段如果赋值,则代表查询条件
* @return 受影响行数
*/
@Override
public int delete(T where) {
// 拼接查询条件
Condition condition = new Condition(getContentValuesForQuery(where));
int result;
if (sqLiteDatabase != null && sqLiteDatabase.isOpen()) {
//受影响行数
result = sqLiteDatabase.delete(
tableName,
condition.getWhereCause(),
condition.getWhereArgs()
);
} else {
result = -1;
}
return result;
}
/**
* 更新数据
*
* @param where 要更新的对象,对象的字段如果赋值,则代表查询条件
* @param newEntity 新的数据内容
* @return 受影响行数
*/
@Override
public int update(T where, T newEntity) {
Condition condition = new Condition(getContentValuesForQuery(where));
int result;
if (sqLiteDatabase != null && sqLiteDatabase.isOpen()) {
//受影响行数
result = sqLiteDatabase.update(
tableName,
getContentValuesForInsert(newEntity),
condition.getWhereCause(),
condition.getWhereArgs()
);
} else {
result = -1;
}
return result;
}
/**
* 查询数据
*
* @param where 查询条件对象,同时也用来初始化对象使用
*/
@NotNull
@Override
public List<T> query(T where) {
return query(where, null, null, null);
}
/**
* 查询数据
*
* @param where 查询条件对象,同时也用来初始化对象使用
*/
@NotNull
@Override
public List<T> query(T where, String orderBy) {
return query(where, orderBy, null, null);
}
/**
* @param where 根据条件 [where] 进行数据查询,如果[where]==只初始化不赋值 则代表查询所有数据
* @param orderBy 排序字段
* @param isOrderDESC 是否倒序 true-倒序false-正序
* @return 结果集合
*/
@Override
public List<T> query(T where, String orderBy, boolean isOrderDESC) {
if (isOrderDESC) {
orderBy = orderBy + " DESC";
}
return query(where, orderBy, null, null);
}
/**
* 查询数据
*
* @param where 查询条件对象
* @param orderBy 排序规则
* @param startIndex 开始的位置
* @param limit 限制查询得到的数据个数
*/
public ArrayList<T> query(T where, String orderBy, Integer startIndex, Integer limit) {
//拼接分页语句
String limitString = null;
if (startIndex != null && limit != null) {
limitString = startIndex + "," + limit;
}
Condition condition = new Condition(getContentValuesForQuery(where));
Cursor cursor = null;
//定义查询结果
ArrayList<T> result = new ArrayList<>();
if (sqLiteDatabase != null && sqLiteDatabase.isOpen()) {
try {
//查询数据库
cursor = sqLiteDatabase.query(
tableName,
null,
condition.getWhereCause(),
condition.getWhereArgs(),
null,
null,
orderBy,
limitString
);
//将查到结果添加到返回集合中
result.addAll(getQueryResult(cursor, where));
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
}
return result;
}
/**
* 获取查询db结果
*/
private ArrayList<T> getQueryResult(Cursor cursor, T where) {
//定义查询结果
ArrayList<T> result = new ArrayList<>();
//Cursor从头读到尾
//游标从头读到尾
cursor.moveToFirst();
try {
if (where != null) {
//移动游标获取下一行数据
while (!cursor.isAfterLast()) {
//通过反射构建一个查询结果对象
T item = (T) where.getClass().newInstance();
Set<Map.Entry<String, Field>> fieldIterator = cacheField.entrySet();
for (Map.Entry<String, Field> stringFieldEntry : fieldIterator) {
//获取数据库字段名称
String columnName = stringFieldEntry.getKey();
//数据库字段名对应的数据对象的成员变量
Field field = stringFieldEntry.getValue();
//获取指定列名对应的索引
int columnIndex = cursor.getColumnIndex(columnName);
//获取成员变量数据类型
Class fieldType = field.getType();
if (columnIndex != -1) {
if (fieldType == (String.class)) {
field.set(item, cursor.getString(columnIndex));
} else if (fieldType == (Integer.class)) {
field.set(item, cursor.getInt(columnIndex));
} else if (fieldType == (Long.class)) {
field.set(item, cursor.getLong(columnIndex));
} else if (fieldType == (Double.class)) {
field.set(item, cursor.getDouble(columnIndex));
} else if (fieldType == (byte[].class)) {
field.set(item, cursor.getBlob(columnIndex));
} else {
//未知类型
throw new UnsupportedOperationException("未定义的数据类型fieldName= " + columnName + " fieldType= " + fieldType);
}
}
}
//添加到结果集
result.add(item);
//移动到下一个位置
cursor.moveToNext();
}
}
} catch (IllegalAccessException | InstantiationException e) {
e.printStackTrace();
}
cursor.close();
return result;
}
/**
* 初始化字段缓存
*/
private void initCacheField() {
//1.取到所有的列名(查询一个空表获取表结构,不影响性能)
if (sqLiteDatabase != null && sqLiteDatabase.isOpen()) {
String sqlQuery = "select * from " + tableName + " limit 1,0";
Cursor cursor = sqLiteDatabase.rawQuery(sqlQuery, null);
//获取所有的列名
String[] columnNames = cursor.getColumnNames();
//关闭资源
cursor.close();
//2.取所有成员名
Field[] columnFields = entityClass.getDeclaredFields();
//3.通过两层循环,进行对应关系建立
for (String columnName : columnNames) {
for (Field columnField : columnFields) {
if (columnName.equals(columnField.getAnnotation(DbField.class).fieldName())) {
columnField.setAccessible(true);
cacheField.put(columnName, columnField);
}
}
}
}
}
/**
* 拼装创建数据表的SQL语句
*/
private String getCreateTableSql() {
//create table if not exists tb_name(_id integer,name varchar2(20))
StringBuffer sqlCreateTable = new StringBuffer();
sqlCreateTable.append("create table if not exists ");
sqlCreateTable.append(tableName + " (");
//反射获取所有的数据对象内的成员变量
Field[] fields = entityClass.getDeclaredFields();
for (int index = 0; index < fields.length; index++) {
//字段名称
String columnName = fields[index].getAnnotation(DbField.class).fieldName();
//获取成员变量数据类型
Class fieldType = fields[index].getType();
if (fieldType == (String.class)) {
sqlCreateTable.append(columnName).append(" TEXT,");
} else if (fieldType == (Integer.class)) {
sqlCreateTable.append(columnName).append(" INTEGER,");
} else if (fieldType == (Long.class)) {
sqlCreateTable.append(columnName).append(" BIGINT,");
} else if (fieldType == (Double.class)) {
sqlCreateTable.append(columnName).append(" DOUBLE,");
} else if (fieldType == (byte[].class)) {
sqlCreateTable.append(columnName).append(" BLOB,");
} else {
//未知类型
throw new UnsupportedOperationException("未定义的数据类型fieldName= " + columnName + " fieldType= " + fieldType);
}
if (index == fields.length - 1) {
if (sqlCreateTable.toString().endsWith(",")) {
sqlCreateTable.deleteCharAt(sqlCreateTable.length() - 1);
}
}
}
sqlCreateTable.append(")");
return sqlCreateTable.toString();
}
/**
* 获取插入使用的ContentValues
*/
private ContentValues getContentValuesForInsert(T entity) {
ContentValues contentValues = new ContentValues();
Set<Map.Entry<String, Field>> fieldIterator = cacheField.entrySet();
for (Map.Entry<String, Field> stringFieldEntry : fieldIterator) {
try {
//获取变量的值
Object valueObject = stringFieldEntry.getValue().get(entity);
//获取列名
String columnName = stringFieldEntry.getKey();
//获取成员变量数据类型
Class fieldType = stringFieldEntry.getValue().getType();
if (fieldType == (String.class)) {
contentValues.put(columnName, (String) valueObject);
} else if (fieldType == (Integer.class)) {
contentValues.put(columnName, (Integer) valueObject);
} else if (fieldType == (Long.class)) {
contentValues.put(columnName, (Long) valueObject);
} else if (fieldType == (Double.class)) {
contentValues.put(columnName, (Double) valueObject);
} else if (fieldType == (byte[].class)) {
contentValues.put(columnName, (byte[]) valueObject);
} else {
//未知类型
throw new UnsupportedOperationException("未定义的数据类型fieldName= " + columnName + " fieldType= " + fieldType);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Logger.d(TAG, "contentValues:" + contentValues);
return contentValues;
}
/**
* 获取查询使用的 条件值对象
*/
private ContentValues getContentValuesForQuery(T entity) {
ContentValues contentValues = new ContentValues();
try {
if (entity != null) {
Set<Map.Entry<String, Field>> fieldIterator = cacheField.entrySet();
for (Map.Entry<String, Field> stringFieldEntry : fieldIterator) {
if (stringFieldEntry.getValue().get(entity) != null) {
contentValues.put(stringFieldEntry.getKey(),
stringFieldEntry.getValue().get(entity).toString());
}
}
}
} catch (IllegalAccessError | IllegalAccessException e) {
e.printStackTrace();
}
return contentValues;
}
/**
* 条件拼接对象
*/
static class Condition {
/**
* 条件key拼接
* _id=?&&name=?
*/
private String whereCause;
/**
* 条件值,与 whereCause 顺序一致
*/
private String[] whereArgs;
//根据传入的contentValues转换成查询条件
public Condition(ContentValues whereContent) {
//记录后面填充到查询语句“?”上的数据参数
ArrayList<String> argList = new ArrayList<>();
//拼接查询语句
StringBuilder whereCaseSb = new StringBuilder();
/*
* 是为了链接下面的查询条件条件,也或者是替换没有查询条件的语句。
* 比如要把检索条件作为一个参数传递给SQL
* 那么当这个检索语句不存在的话就可以给它赋值为1=1.
* 这样就避免了SQL出错也就可以把加条件的SQL和不加条件的SQL合二为一。
*/
whereCaseSb.append(" 1=1 ");
Set<String> keys = whereContent.keySet();
//因为使用了“1=1”所以即便是这里没有任何数据拼接也是可以正常
for (String key : keys) {
Object valueObject = whereContent.get(key);
if (valueObject != null) {
String value = (String) valueObject;
//拼接查询条件语句
//1:1 and _id=? and name=?
whereCaseSb.append(" and " + key + " =?");
//记录对应的value
argList.add(value);
}
}
//集合转成数组
this.whereArgs = argList.toArray(new String[argList.size()]);
this.whereCause = whereCaseSb.toString();
}
public String getWhereCause() {
return this.whereCause;
}
public String[] getWhereArgs() {
return this.whereArgs;
}
}
}

View File

@@ -10,14 +10,14 @@ import com.mogo.utils.sqlite.proxy.BaseDaoProxyLog
* <p>数据库处理工厂</p>
* Created by donghongyu on 2019/9/6.
*/
open class BaseDaoFactory {
open class SQLDaoFactory {
//默认数据库名称
private var dbName = "MoGoSQLite.db"
companion object {
//单利工厂
private var baseDaoFactory: BaseDaoFactory? = null
private var sqlDaoFactory: SQLDaoFactory? = null
//数据库存储路径
private lateinit var sqLiteDatabasePath: String
@@ -25,21 +25,21 @@ open class BaseDaoFactory {
//数据库操作类
private var sqLiteDatabase: SQLiteDatabase? = null
fun getInstance(): BaseDaoFactory {
if (baseDaoFactory == null) {
synchronized(BaseDaoFactory::class.java) {
if (baseDaoFactory == null) {
baseDaoFactory = BaseDaoFactory()
fun getInstance(): SQLDaoFactory {
if (sqlDaoFactory == null) {
synchronized(SQLDaoFactory::class.java) {
if (sqlDaoFactory == null) {
sqlDaoFactory = SQLDaoFactory()
}
}
}
return baseDaoFactory!!
return sqlDaoFactory!!
}
}
//获取数据库操作对象
fun <T : Any> getBaseDao(context: Context, entityClass: Class<T>): IBaseDao<T>? {
var baseDao: IBaseDao<T>? = null
fun <T : Any> getBaseDao(context: Context, entityClass: Class<T>): SQLIDao<T>? {
var baseDao: SQLIDao<T>? = null
try {
//获取数据库名称,如果没有设置则使用默认名称
@@ -49,12 +49,14 @@ open class BaseDaoFactory {
}
//openOrCreateDatabase 如果不存在则先创建再打开数据库,如果存在则直接打开。
sqLiteDatabasePath =
"${context.getDir("database", Context.MODE_APPEND).path}/$dbName"
"${context.getDir("database", Context.MODE_APPEND).path}/$dbName"
sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(sqLiteDatabasePath, null)
// 这里为了演示,添加了日志工具的叠加使用,根据需要可以自己修改
// baseDao = BaseDaoProxyShow().bind(BaseDaoProxyLog().bind(BaseDao<T>())) as IBaseDao<T>
baseDao = BaseDaoProxyLog().bind(BaseDao<T>()) as IBaseDao<T>
// baseDao = BaseDaoProxyLog().bind(SQLBaseDao<T>()) as IBaseDao<T>
// baseDao = BaseDao<T>()
baseDao = BaseDaoProxyLog().bind(SQLBaseDao<T>()) as SQLIDao<T>
baseDao.init(sqLiteDatabase!!, entityClass)
} catch (e: Exception) {

View File

@@ -0,0 +1,53 @@
package com.mogo.utils.sqlite;
import android.database.sqlite.SQLiteDatabase;
import java.util.List;
/**
* 数据库操作接口
*
* @author donghongyu
*/
public interface SQLIDao<T> {
/**
* 初始化数据库连接
*/
boolean init(SQLiteDatabase sqLiteDatabase, Class<T> entityClass);
/**
* 将 [entity] 进行数据插入
*/
long insert(T entity);
/**
* 根据条件 [where] 进行数据删除,如果[where]==只初始化不赋值 则代表删除所有数据
*/
int delete(T where);
/**
* 根据条件 [where] 进行数据更新,如果[where]==只初始化不赋值 则代表删除所有数据
*/
int update(T where, T newEntity);
/**
* @param where 根据条件 [where] 进行数据查询,如果[where]==只初始化不赋值 则代表查询所有数据
* @return 结果集合
*/
List<T> query(T where);
/**
* @param where 根据条件 [where] 进行数据查询,如果[where]==只初始化不赋值 则代表查询所有数据
* @param orderBy 排序字段
* @return 结果集合
*/
List<T> query(T where, String orderBy);
/**
* @param where 根据条件 [where] 进行数据查询,如果[where]==只初始化不赋值 则代表查询所有数据
* @param orderBy 排序字段
* @param isOrderDESC 是否倒序
* @return 结果集合
*/
List<T> query(T where, String orderBy, boolean isOrderDESC);
}

View File

@@ -1,51 +0,0 @@
package com.mogo.utils.sqlite.proxy
import android.database.sqlite.SQLiteDatabase
import android.util.Log
import com.mogo.utils.sqlite.IBaseDao
/**
* <p>静态代理数据库操作类,用来记录日志</P>
* Created by donghongyu on 2019/9/6.
*/
class BaseDaoProxy<T>(var iBaseDao: IBaseDao<T>) : IBaseDao<T> by iBaseDao {
override fun init(sqLiteDatabase: SQLiteDatabase, entityClass: Class<T>): Boolean {
Log.i("数据库代理", "初始化数据库连接……")
val isInitSuccess = iBaseDao.init(sqLiteDatabase, entityClass)
if (isInitSuccess) {
Log.i("数据库代理", "数据库连接成功……")
} else {
Log.e("数据库代理", "数据库连接失败……")
}
return isInitSuccess
}
override fun insert(entity: T): Long {
Log.i("数据库代理", "开始插入数据……")
val result = iBaseDao.insert(entity)
Log.i("数据库代理", "插入数据索引位置> $result <……")
return result
}
override fun delete(where: T): Int {
Log.i("数据库代理", "开始删除数据……")
val result = iBaseDao.delete(where)
Log.i("数据库代理", "删除了> $result <条数据……")
return result
}
override fun update(where: T, newEntity: T): Int {
Log.i("数据库代理", "开始更新数据……")
val result = iBaseDao.update(where, newEntity)
Log.i("数据库代理", "更新了> $result <条数据……")
return result
}
override fun query(where: T): MutableList<T> {
Log.i("数据库代理", "开始查询数据……")
val result = iBaseDao.query(where)
Log.i("数据库代理", "查询到> ${result.size} <条数据……")
return result
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.utils.sqlite.proxy
import android.util.Log
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.utils.GsonUtil
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy
@@ -24,8 +25,8 @@ class BaseDaoProxyLog : InvocationHandler {
this.target = target
//取得代理对象
return Proxy.newProxyInstance(
target.javaClass.classLoader,
target.javaClass.interfaces, this
target.javaClass.classLoader,
target.javaClass.interfaces, this
)
}
@@ -40,11 +41,11 @@ class BaseDaoProxyLog : InvocationHandler {
override fun invoke(proxy: Any, method: Method, args: Array<Any>): Any? {
var result: Any? = null
//反射方法前调用
Log.i("数据库", "当前执行>>${method.name}")
Logger.i("SQL数据库", "当前执行>>${method.name}>>")
//反射执行方法 相当于调用target.sayHelllo;
result = method.invoke(target, *args)
//反射方法后调用.
Log.i("数据库", "执行结果>>$result")
Logger.i("SQL数据库", "执行结果>>$result")
return result
}
}

View File

@@ -1,49 +0,0 @@
package com.mogo.utils.sqlite.proxy
import android.util.Log
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy
/**
* 使用java实现动态代理数据库操作类,加入更多额外的功能,来测试代理类的叠加功能
* Created by donghongyu on 2019/9/6.
*/
class BaseDaoProxyShow : InvocationHandler {
private var target: Any? = null
/**
* 绑定委托对象并返回一个【代理占位】
*
* @param target 真实对象
* @return 代理对象【占位】
*/
fun bind(target: Any): Any {
this.target = target
//取得代理对象
return Proxy.newProxyInstance(
target.javaClass.classLoader,
target.javaClass.interfaces, this
)
}
/**
* 同过代理对象调用方法首先进入这个方法.
*
* @param proxy --代理对象
* @param method -- 方法,被调用方法.
* @param args -- 方法的参数
*/
@Throws(Throwable::class)
override fun invoke(proxy: Any, method: Method, args: Array<Any>): Any? {
var result: Any? = null
//反射方法前调用
Log.i("数据库代理", "显示执行>>${method.name}")
//反射执行方法 相当于调用target.sayHelllo;
result = method.invoke(target, *args)
//反射方法后调用.
Log.i("数据库代理", "执行结果>>$result")
return result
}
}

View File

@@ -81,7 +81,7 @@ MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.6
# 广告资源位
MOGO_MODULE_AD_CARD_VERSION=1.0.1
# 探路上报和分享模块
TANLULIB_VERSION=1.3.1.16
TANLULIB_VERSION=1.3.1.24
MOGO_MODULE_EVENT_PANEL_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_EVENT_PANEL_NOOP_VERSION = 1.0.0-SNAPSHOT
#左侧面板模块
@@ -101,7 +101,9 @@ MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT
# loglib
LOGLIB_VERSION = 1.0.0-SNAPSHOT
LOGLIB_VERSION = 1.0.1-SNAPSHOT
# monitor
MOGO_MODULE_MONITOR_VERSION = 1.0.0-SNAPSHOT
## 产品库必备配置产品库自动对versionCode和versionName版本进行升级
applicationId=com.mogo.launcer

View File

@@ -16,6 +16,7 @@ public class MarkerCardResult extends BaseData {
private List<MarkerOnlineCar> onlineCar;
private List<MarkerExploreWay> exploreWay;
private long messageTime;
public List<MarkerCarChat> getCarChat() {
return carChat;
@@ -65,15 +66,11 @@ public class MarkerCardResult extends BaseData {
this.dataType = dataType;
}
@Override
public String toString() {
return "MarkerCardResult{" +
"dataType=" + dataType +
", carChat=" + carChat +
", exploreWay=" + exploreWay +
", onlineCar=" + onlineCar +
", shareMusic=" + shareMusic +
", noveltyInfo=" + noveltyInfo +
'}';
public long getMessageTime() {
return messageTime;
}
public void setMessageTime(long messageTime) {
this.messageTime = messageTime;
}
}

View File

@@ -109,14 +109,16 @@ public class V2XEventShowEntity implements Serializable {
@IntDef(value = {
V2XWindowTypeEnum.DEFAULT_WINDOW,
V2XWindowTypeEnum.LIVE_CAR_WINDOW,
V2XWindowTypeEnum.ROAD_EVENT_WINDOW,
V2XWindowTypeEnum.PUSH_EVENT_WINDOW,
V2XWindowTypeEnum.ANIMATION_WINDOW,
V2XWindowTypeEnum.FATIGUE_DRIVING_WINDOW,
V2XWindowTypeEnum.SEEK_HELP_WINDOW,
V2XWindowTypeEnum.ILLEGAL_PARK_WINDOW,
V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING,
V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_TOAST_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_LIVE_CAR_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_ANIMATION_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_LIVE_CAR_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING,
V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP,
})
@Target({
ElementType.PARAMETER,

View File

@@ -4,6 +4,8 @@ import com.mogo.utils.sqlite.annotation.DbDatabase;
import com.mogo.utils.sqlite.annotation.DbField;
import com.mogo.utils.sqlite.annotation.DbTable;
import java.util.Objects;
/**
* V2X 道路历史事件
*

View File

@@ -80,6 +80,8 @@ public class V2XMessageEntity<T> implements Serializable {
* V2X 场景类型
*/
public interface V2XTypeEnum {
// 默认展示详情
int DEFAULT_WINDOW = 0;
// 道路事件预警
int ALERT_ROAD_WARNING = 1_000;
// 他车求助预警

View File

@@ -1,27 +0,0 @@
package com.mogo.module.common.entity;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/3/31 4:53 PM
* desc : V2X 道路提醒类型
* version: 1.0
*/
public interface V2XWindowTypeEnum {
// 默认展示详情
int DEFAULT_WINDOW = 0;
// 直播
int LIVE_CAR_WINDOW = 1;
// 道路事件详情
int ROAD_EVENT_WINDOW = 2;
// 推送事件详情
int PUSH_EVENT_WINDOW = 3;
// 演示动画场景
int ANIMATION_WINDOW = 4;
// 疲劳驾驶
int FATIGUE_DRIVING_WINDOW = 5;
// 他人故障求助
int SEEK_HELP_WINDOW = 6;
// 违章停车
int ILLEGAL_PARK_WINDOW = 7;
}

View File

@@ -1 +0,0 @@
-keep class com.zhidao.mogo.module.event.panel.EventPanelConstants

View File

@@ -1,3 +0,0 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-event-panel-noop
VERSION_CODE=1

View File

@@ -1,24 +0,0 @@
package com.zhidao.mogo.module.event.panel
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.zhidao.mogo.module.event.panel.test", appContext.packageName)
}
}

View File

@@ -1,11 +0,0 @@
package com.zhidao.mogo.module.event.panel
/**
* 事件面板相关常量
*
* @author tongchenfei
*/
object EventPanelConstants {
const val MODULE_NAME = "MODULE_EVENT_PANEL"
const val PATH_NAME = "/event/panel"
}

View File

@@ -1,94 +0,0 @@
package com.zhidao.mogo.module.event.panel
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
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.IMogoMarkerClickListener
import com.mogo.map.navi.IMogoNaviListener
import com.mogo.service.MogoServicePaths
import com.mogo.service.eventpanel.IEventPanelProvider
import com.mogo.service.module.IMogoModuleLifecycle
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
/**
* 事件面板provider的空方法实现
*
* @author tongchenfei
*/
const val TAG = "EventPanelNoopModule"
@Route(path = MogoServicePaths.PATH_EVENT_PANEL)
class EventPanelModuleProvider : IEventPanelProvider {
override fun init(context: Context) {
Logger.d(TAG, "模块初始化====")
}
override fun createFragment(context: Context, data: Bundle?): Fragment? {
return null
}
/**
* 显示面板
*/
override fun showPanel() {
}
/**
* 隐藏面板
*/
override fun hidePanel() {
}
override fun createView(context: Context): View? {
return null
}
override fun getModuleName(): String {
return MODULE_NAME
}
override fun getCardLifecycle(): IMogoModuleLifecycle? {
return null
}
override fun getMapListener(): IMogoMapListener? {
return null
}
override fun getType(): Int {
return 0
}
override fun getNaviListener(): IMogoNaviListener? {
return null
}
override fun getLocationListener(): IMogoLocationListener? {
return null
}
override fun getMarkerClickListener(): IMogoMarkerClickListener? {
return null
}
override fun getAppPackage(): String? {
return null
}
override fun getAppName(): String? {
return null
}
override fun isPanelShow(): Boolean {
return false
}
}

View File

@@ -1,17 +0,0 @@
package com.zhidao.mogo.module.event.panel
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View File

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

View File

@@ -1,63 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.androidxviewpager2
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.room
kapt rootProject.ext.dependencies.roomAnnotationProcessor
implementation rootProject.ext.dependencies.roomRxjava
if (Boolean.valueOf(RELEASE)) {
compileOnly rootProject.ext.dependencies.modulecommon
} else {
compileOnly project(':modules:mogo-module-common')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,5 +0,0 @@
#-----EventPanel------
-keep class com.zhidao.mogo.module.event.panel.bean.** {*;}
-keep class com.zhidao.mogo.module.event.panel.dao.** {*;}
-keep class com.zhidao.mogo.module.event.panel.listener.** {*;}
-keep class com.zhidao.mogo.module.event.panel.EventPanelConstants

View File

@@ -1,27 +0,0 @@
# 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
#-----EventPanel------
-keep class com.zhidao.mogo.module.event.panel.bean.** {*;}
-keep class com.zhidao.mogo.module.event.panel.dao.** {*;}
-keep class com.zhidao.mogo.module.event.panel.listener.** {*;}
-keep class com.zhidao.mogo.module.event.panel.EventPanelConstants

View File

@@ -1,5 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhidao.mogo.module.event.panel">
/
</manifest>

View File

@@ -1,15 +0,0 @@
package com.zhidao.mogo.module.event.panel
/**
* 事件面板相关常量
*
* @author tongchenfei
*/
object EventPanelConstants {
const val MODULE_NAME = "MODULE_EVENT_PANEL"
const val PATH_NAME = "/event/panel"
const val ROAD_EVENT_USEFUL = "2"
const val ROAD_EVENT_UNUSEFUL = "1"
const val ROAD_EVENT_USEFUL_STATUS_UNSET = "0"
}

View File

@@ -1,103 +0,0 @@
package com.zhidao.mogo.module.event.panel
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
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.IMogoMarkerClickListener
import com.mogo.map.navi.IMogoNaviListener
import com.mogo.service.eventpanel.IEventPanelProvider
import com.mogo.service.module.IMogoModuleLifecycle
import com.mogo.service.module.IMogoModuleProvider
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
import com.zhidao.mogo.module.event.panel.EventPanelConstants.PATH_NAME
import com.zhidao.mogo.module.event.panel.fragment.EventPanelFragment
import com.zhidao.mogo.module.event.panel.util.MogoApiManager
import com.zhidao.mogo.module.event.panel.util.TripRecordDataManager
/**
* 事件面板provider
*
* @author tongchenfei
*/
@Route(path = PATH_NAME)
class EventPanelModuleProvider : IEventPanelProvider {
/**
* Do your init work in this method, it well be call when processor has been load.
*
* @param context ctx
*/
override fun init(context: Context) {
Logger.d(MODULE_NAME, "模块初始化====")
MogoApiManager.init(context)
TripRecordDataManager.init(context)
}
override fun createFragment(context: Context, data: Bundle?): Fragment? {
return EventPanelFragment.getInstance()
}
/**
* 显示面板
*/
override fun showPanel() {
EventPanelFragment.getInstance().showPanel()
}
override fun isPanelShow(): Boolean {
return EventPanelFragment.getInstance().isPanelShow()
}
/**
* 隐藏面板
*/
override fun hidePanel() {
EventPanelFragment.getInstance().hidePanel()
}
override fun createView(context: Context): View? {
return null
}
override fun getModuleName(): String {
return MODULE_NAME
}
override fun getCardLifecycle(): IMogoModuleLifecycle? {
return null
}
override fun getMapListener(): IMogoMapListener? {
return null
}
override fun getType(): Int {
return 0
}
override fun getNaviListener(): IMogoNaviListener? {
return null
}
override fun getLocationListener(): IMogoLocationListener? {
return null
}
override fun getMarkerClickListener(): IMogoMarkerClickListener? {
return null
}
override fun getAppPackage(): String? {
return null
}
override fun getAppName(): String? {
return null
}
}

View File

@@ -1,24 +0,0 @@
package com.zhidao.mogo.module.event.panel.adapter
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.zhidao.mogo.module.event.panel.fragment.MyShareFragment
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment
import com.zhidao.mogo.module.event.panel.fragment.SurroundingEventFragment
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
/**
* 事件面板viewpager2的adapter
*
* @author tongchenfei
*/
class EventPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
private val fragments:Array<Fragment> = arrayOf(TripRecordFragment(), SurroundingEventFragment(), ShareEventsFragment())
/**
* 目前一共就三个fragment
*/
override fun getItemCount(): Int = fragments.size
override fun createFragment(position: Int): Fragment = fragments[position]
}

View File

@@ -1,25 +0,0 @@
package com.zhidao.mogo.module.event.panel.bean
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.zhidao.mogo.module.event.panel.EventPanelConstants.ROAD_EVENT_USEFUL_STATUS_UNSET
/**
* 出行记录本地存储封装类,此类标识了数据库表名以及字段名
*
* @author tongchenfei
*/
@Entity
data class TripRecord(@PrimaryKey(autoGenerate = false)
var id: Int,
var eventId: String = "",
var eventType: Int,
/**
* 是否有用
* 1 - 没用
* 2 - 有用
* 0 - 未设置
*/
var usefulStatus: String = ROAD_EVENT_USEFUL_STATUS_UNSET,
var entity: String = "",
var recordTime: Long = System.currentTimeMillis())

View File

@@ -1,48 +0,0 @@
package com.zhidao.mogo.module.event.panel.dao
import androidx.room.*
import com.zhidao.mogo.module.event.panel.bean.TripRecord
/**
* 出行动态dao,全部使用同步方法,在线程中执行
*
* @author tongchenfei
*/
@Dao
interface TripRecordDao {
/**
* 查询当日数据
* @param limitTime 当日0点的时间戳
*/
@Query(value = "SELECT * FROM TripRecord WHERE recordTime > :limitTime ORDER BY recordTime DESC")
fun queryAllTripRecord(limitTime: Long): List<TripRecord>
/**
* 根据事件id获取出行动态
*
* @param eventId 事件id [com.mogo.module.common.entity.V2XRoadEventEntity.noveltyInfo.infoId]
*/
@Query(value = "SELECT * FROM TripRecord WHERE eventId = :eventId")
fun queryTripRecordByEventId(eventId: String): TripRecord?
@Query(value = "SELECT * FROM TripRecord WHERE id = :id")
fun queryTripRecordById(id: Int): TripRecord?
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg tripRecord: TripRecord)
@Update
fun update(vararg tripRecord: TripRecord)
@Delete
fun delete(vararg tripRecord: TripRecord)
/**
* 删除超时的数据即当天0时以前的数据
* 虽然注解是Query但是目的是执行后面的sql语句所以就不要在意这些细节了
*
* @param limitTime 当日0点的时间戳
*/
@Query(value = "DELETE FROM TripRecord WHERE recordTime < :limitTime")
fun deleteOvertimeTripRecord(limitTime: Long)
}

View File

@@ -1,25 +0,0 @@
package com.zhidao.mogo.module.event.panel.dao
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.zhidao.mogo.module.event.panel.bean.TripRecord
@Database(entities = [TripRecord::class], version = 1, exportSchema = false)
abstract class TripRecordDatabase : RoomDatabase() {
companion object{
private var instance:TripRecordDatabase? = null
fun getInstance(context: Context):TripRecordDatabase{
if (instance == null) {
synchronized(TripRecordDatabase::class.java) {
if (instance == null) {
instance = Room.databaseBuilder(context, TripRecordDatabase::class.java, "TripRecordDatabase.db").build()
}
}
}
return instance!!
}
}
abstract fun getTripRecordDao():TripRecordDao
}

View File

@@ -1,61 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment
import android.view.View
import androidx.fragment.app.Fragment
import com.mogo.commons.mvp.MvpFragment
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
import com.zhidao.mogo.module.event.panel.R
import com.zhidao.mogo.module.event.panel.adapter.EventPagerAdapter
import com.zhidao.mogo.module.event.panel.presenter.EventPanelPresenter
import kotlinx.android.synthetic.main.module_event_panel_fragment_event_panel.*
/**
* 事件面板主fragment
*
* @author tongchenfei
*/
class EventPanelFragment : MvpFragment<EventPanelFragment, EventPanelPresenter>() {
companion object{
private val fragment = EventPanelFragment()
fun getInstance():EventPanelFragment{
return fragment
}
}
override fun getLayoutId(): Int {
return R.layout.module_event_panel_fragment_event_panel
}
override fun initViews() {
Logger.d(MODULE_NAME, "EventPanelFragment init view===")
vpEventPanel.adapter = EventPagerAdapter(this)
btnShowOrHidePanels.setOnClickListener {
if (vpEventPanel.visibility == View.GONE) {
showPanel()
}else{
hidePanel()
}
}
}
override fun createPresenter(): EventPanelPresenter {
return EventPanelPresenter(this)
}
fun showPanel(){
Logger.d(MODULE_NAME,"in fragment show panel")
vpEventPanel.visibility = View.VISIBLE
btnShowOrHidePanels.text = "隐藏面板"
}
fun hidePanel(){
Logger.d(MODULE_NAME,"in fragment hide panel")
vpEventPanel.visibility = View.GONE
btnShowOrHidePanels.text = "显示面板"
}
fun isPanelShow():Boolean{
return vpEventPanel.visibility == View.VISIBLE
}
}

View File

@@ -1,28 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment
import com.mogo.commons.mvp.MvpFragment
import com.zhidao.mogo.module.event.panel.R
import com.zhidao.mogo.module.event.panel.presenter.MySharePresenter
class MyShareFragment : MvpFragment<MyShareFragment, MySharePresenter>() {
/**
* 布局资源
*
* @return
*/
override fun getLayoutId(): Int = R.layout.module_event_panel_share_item
/**
* 初始化控件必须在初始化完成之后才可以实例化presenter避免
* presenter 生命周期错乱
*/
override fun initViews() {
}
/**
* 创建 presenter 实例
*
* @return
*/
override fun createPresenter(): MySharePresenter = MySharePresenter(this)
}

View File

@@ -1,156 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.mogo.module.event.panel.R;
import com.zhidao.mogo.module.event.panel.adapter.ShareEventAdapter;
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
import com.zhidao.mogo.module.event.panel.network.HostConstant;
import com.zhidao.mogo.module.event.panel.network.ShareEventApiService;
import com.zhidao.mogo.module.event.panel.network.ShareEventParameter;
import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareEventsPresenter> {
private static final String TAG = "ShareEventsFragment";
private RecyclerView recyclerView;
private View view;
private ShareEventAdapter adapter;
private ArrayList dataArrayList = new ArrayList();
private ShareEventApiService shareEventApiService;
private int pageNum = 1;
private View emptyView;
private Button shareBtn;
@Override
protected int getLayoutId() {
return R.layout.module_event_panel_share_recylerview;
}
@Override
protected void initViews() {
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.module_event_panel_share_recylerview, container, false);
emptyView = inflater.inflate(R.layout.module_event_panel_share_empty,container,false);
initRecyclerView();
initData();
return view;
}
private void initRecyclerView() {
recyclerView = view.findViewById(R.id.road_case_share_list);
adapter = new ShareEventAdapter(getActivity(), dataArrayList);
recyclerView.setAdapter(adapter);
LinearLayoutManager linearLayoutManager =
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
}
private void initData() {
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
this.shareEventApiService = network.create(ShareEventApiService.class, HostConstant.getNetHost());
getShareEventDescription();
getShareEventList(pageNum, 10);
}
/*
* 热心指数等
* */
private void getShareEventDescription() {
//ZD802B1932L00622 测试数据sn
ShareEventParameter parameter = new ShareEventParameter(Utils.getSn());
Map<String, Object> parameters = new HashMap<>();
parameters.put("data", GsonUtil.jsonFromObject(parameter));
shareEventApiService.getEnthusiasmIndex(parameters)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<ShareEventDescription>(RequestOptions.create(getContext())) {
@Override
public void onSuccess(ShareEventDescription resultData) {
if (resultData != null && resultData.getResult() != null
&& resultData.getResult().getEnthusiasmIndex() != null) {
dataArrayList.add(resultData.getResult().getEnthusiasmIndex());
adapter.notifyDataSetChanged();
Log.d(TAG, "热心指数---:" + resultData.getResult().getEnthusiasmIndex());
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
});
}
/*
* 分享列表
* */
private void getShareEventList(int page, int size) {
ShareEventParameter parameter = new ShareEventParameter(Utils.getSn(), pageNum, 10);
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("data", GsonUtil.jsonFromObject(parameter));
shareEventApiService.getShareEventList(parameters)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<ShareEventItem>(RequestOptions.create(getContext())) {
@Override
public void onSuccess(ShareEventItem resultData) {
if (resultData != null && resultData.getResult() != null
&& resultData.getResult().getPage().getContent().size() > 0) {
adapter.setEmptylist(false);
dataArrayList.addAll(resultData.getResult().getPage().getContent());
Log.d(TAG, "分享列表---:" + dataArrayList.get(0));
} else {
adapter.setEmptylist(true);
}
adapter.notifyDataSetChanged();
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
});
}
@NonNull
@Override
protected ShareEventsPresenter createPresenter() {
return new ShareEventsPresenter(this);
}
}

View File

@@ -1,32 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment
import com.mogo.commons.mvp.MvpFragment
import com.zhidao.mogo.module.event.panel.R
import com.zhidao.mogo.module.event.panel.presenter.SurroundingEventPresenter
import kotlinx.android.synthetic.main.module_event_panel_fragment_surrounding_event.*
class SurroundingEventFragment:MvpFragment<SurroundingEventFragment,SurroundingEventPresenter>(){
/**
* 布局资源
*
* @return
*/
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_surrounding_event
/**
* 初始化控件必须在初始化完成之后才可以实例化presenter避免
* presenter 生命周期错乱
*/
override fun initViews() {
tvTitle.setOnClickListener {
EventPanelFragment.getInstance().hidePanel()
}
}
/**
* 创建 presenter 实例
*
* @return
*/
override fun createPresenter(): SurroundingEventPresenter = SurroundingEventPresenter(this)
}

View File

@@ -1,49 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment
import android.util.Log
import com.mogo.commons.mvp.MvpFragment
import com.mogo.module.common.entity.V2XMessageEntity
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
import com.zhidao.mogo.module.event.panel.R
import com.zhidao.mogo.module.event.panel.bean.TripRecord
import com.zhidao.mogo.module.event.panel.presenter.TripRecordPresenter
import com.zhidao.mogo.module.event.panel.util.TripRecordDataManager
import kotlinx.android.synthetic.main.module_event_panel_fragment_trip_record.*
import kotlin.random.Random
/**
* 出行动态fragment
*/
class TripRecordFragment : MvpFragment<TripRecordFragment, TripRecordPresenter>() {
private val tripRecordList = ArrayList<TripRecord>()
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_trip_record
override fun initViews() {
btnInsert.setOnClickListener {
TripRecordDataManager.insertTripRecord(TripRecord(id = 456, eventType = 456,eventId = "456"))
}
btnUpdate.setOnClickListener {
TripRecordDataManager.syncRoadEventModifyState(eventId = "456", modifyType = "2")
}
btnQuery.setOnClickListener {
Log.d(MODULE_NAME, "local list: $tripRecordList")
mPresenter.queryAllTripRecord()
}
}
override fun createPresenter(): TripRecordPresenter = TripRecordPresenter(this)
fun refreshTripRecordList(tripRecords: List<TripRecord>) {
Logger.d(MODULE_NAME, "刷新出行动态列表:$tripRecords")
tripRecordList.clear()
tripRecordList.addAll(tripRecords)
}
/**
* 刷新单个出行动态,如果无此动态,新增动态
*/
fun refreshTripRecord(tripRecord: TripRecord) {
Logger.d(MODULE_NAME, "刷新单个出行动态: $tripRecord")
}
}

View File

@@ -1,18 +0,0 @@
package com.zhidao.mogo.module.event.panel.listener
import com.zhidao.mogo.module.event.panel.bean.TripRecord
/**
* 数据库异步操作数据回调
*/
interface ITripRecordCallback {
/**
* 查询全部出行动态成功
*/
fun queryTripRecordListSuccess(tripRecordList:List<TripRecord>)
/**
* 有出行动态新增或更新后,回调此接口
*/
fun insertOrUpdateTripRecordSuccess(tripRecord:TripRecord)
}

View File

@@ -1,23 +0,0 @@
package com.zhidao.mogo.module.event.panel.network;
import com.mogo.commons.debug.DebugConfig;
public class HostConstant {
public static final String HOST_DEV = "http://dzt-test.zhidaohulian.com";
public static final String HOST_TEST = "http://dzt-test.zhidaohulian.com";
public static final String HOST_DEMO = "http://dzt-show.zhidaohulian.com";
public static final String HOST_PRODUCT = "https://dzt.zhidaohulian.com";
public static String getNetHost() {
switch ( DebugConfig.getNetMode() ) {
case DebugConfig.NET_MODE_DEV:
return HOST_DEV;
case DebugConfig.NET_MODE_QA:
return HOST_TEST;
case DebugConfig.NET_MODE_DEMO:
return HOST_DEMO;
default:
return HOST_PRODUCT;
}
}
}

View File

@@ -1,26 +0,0 @@
package com.zhidao.mogo.module.event.panel.network;
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
import java.util.Map;
import io.reactivex.Observable;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
public interface ShareEventApiService {
//我的分享-热心指数等
@FormUrlEncoded
@POST("/deva/poiInfoFabulous/car/poi/no/queryEnthusiasmIndex/v1")
Observable<ShareEventDescription> getEnthusiasmIndex(@FieldMap Map<String, Object> parames);
//我的分享-列表
@FormUrlEncoded
@POST("/deva/car/pathAndPoi/no/queryInfo")
Observable<ShareEventItem> getShareEventList(@FieldMap Map<String, Object> parames);
}

View File

@@ -1,18 +0,0 @@
package com.zhidao.mogo.module.event.panel.network;
public class ShareEventParameter {
private String sn;
private int pageNum;
private int pageSize;
public ShareEventParameter(String sn) {
this.sn = sn;
}
public ShareEventParameter(String sn, int pageNum, int pageSize) {
this.sn = sn;
this.pageNum = pageNum;
this.pageSize = pageSize;
}
}

View File

@@ -1,11 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter
import com.mogo.commons.mvp.Presenter
import com.zhidao.mogo.module.event.panel.fragment.EventPanelFragment
/**
* 事件面板presenter
*
* @author tongchenfei
*/
class EventPanelPresenter(view: EventPanelFragment) : Presenter<EventPanelFragment>(view)

View File

@@ -1,7 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter
import com.mogo.commons.mvp.Presenter
import com.zhidao.mogo.module.event.panel.fragment.MyShareFragment
class MySharePresenter(view: MyShareFragment) : Presenter<MyShareFragment>(view) {
}

View File

@@ -1,11 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.Presenter;
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment;
public class ShareEventsPresenter extends Presenter <ShareEventsFragment>{
public ShareEventsPresenter(IView view) {
super((ShareEventsFragment) view);
}
}

View File

@@ -1,7 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter
import com.mogo.commons.mvp.Presenter
import com.zhidao.mogo.module.event.panel.fragment.SurroundingEventFragment
class SurroundingEventPresenter(view: SurroundingEventFragment) : Presenter<SurroundingEventFragment>(view) {
}

View File

@@ -1,33 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter
import androidx.lifecycle.LifecycleOwner
import com.mogo.commons.mvp.Presenter
import com.zhidao.mogo.module.event.panel.bean.TripRecord
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
import com.zhidao.mogo.module.event.panel.listener.ITripRecordCallback
import com.zhidao.mogo.module.event.panel.util.TripRecordDataManager
class TripRecordPresenter(view: TripRecordFragment) : Presenter<TripRecordFragment>(view),ITripRecordCallback {
init {
TripRecordDataManager.addTripRecordCallback(this)
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
TripRecordDataManager.removeTripRecordCallback(this)
}
fun queryAllTripRecord(){
TripRecordDataManager.queryAllTripRecord()
}
override fun queryTripRecordListSuccess(tripRecordList: List<TripRecord>) {
mView.refreshTripRecordList(tripRecordList)
}
override fun insertOrUpdateTripRecordSuccess(tripRecord: TripRecord) {
mView.refreshTripRecord(tripRecord)
}
}

View File

@@ -1,14 +0,0 @@
package com.zhidao.mogo.module.event.panel.util
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
object MogoApiManager {
lateinit var serviceApis:IMogoServiceApis
fun init(context: Context) {
serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
}
}

View File

@@ -1,171 +0,0 @@
package com.zhidao.mogo.module.event.panel.util
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Handler
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.mogo.module.common.entity.V2XMessageEntity
import com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.*
import com.mogo.module.common.entity.V2XRoadEventEntity
import com.mogo.utils.ThreadPoolService
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.utils.GsonUtil
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
import com.zhidao.mogo.module.event.panel.bean.TripRecord
import com.zhidao.mogo.module.event.panel.dao.TripRecordDao
import com.zhidao.mogo.module.event.panel.dao.TripRecordDatabase
import com.zhidao.mogo.module.event.panel.listener.ITripRecordCallback
import java.util.*
import kotlin.collections.ArrayList
private const val BROADCAST_SCENE_EVENT_ACTION = "com.v2x.scene_local_broadcast"
private const val BROADCAST_SCENE_MODIFY_ACTION = "com.zhidao.tanlu.dataerror"
private const val BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity"
private const val BORADCAST_SCENE_MODIFY_EVENT_ID_KEY = "id"
private const val BROADCAST_SCENE_MODIFY_EVENT_UPDATE_TYPE_KEY = "updateType"
/**
* 出行动态的数据管理类由于TripRecordFragment初始化时机较晚所以封装一个单例类提早初始化
*/
object TripRecordDataManager {
private lateinit var context: Context
private val sceneEventReceiver = SceneEventReceiver()
private lateinit var tripRecordDao: TripRecordDao
private val tripRecordCallbackList = ArrayList<ITripRecordCallback>()
fun init(context: Context) {
this.context = context
LocalBroadcastManager.getInstance(context).registerReceiver(sceneEventReceiver, IntentFilter(BROADCAST_SCENE_EVENT_ACTION))
context.registerReceiver(sceneEventReceiver, IntentFilter(BROADCAST_SCENE_MODIFY_ACTION))
tripRecordDao = TripRecordDatabase.getInstance(TripRecordDataManager.context).getTripRecordDao()
}
fun addTripRecordCallback(callback: ITripRecordCallback) {
tripRecordCallbackList.add(callback)
}
fun removeTripRecordCallback(callback: ITripRecordCallback) {
tripRecordCallbackList.remove(callback)
}
private val handler = Handler()
fun queryAllTripRecord() {
ThreadPoolService.singleExecute {
val limitTime = countLimitTime()
// 查询所有的出行动态
val tripRecordList = tripRecordDao.queryAllTripRecord(limitTime)
Logger.d(MODULE_NAME, "查询所有出行动态,limitTime: $limitTime, list: $tripRecordList")
// 删除超时的出行动态
tripRecordDao.deleteOvertimeTripRecord(limitTime)
// 切换线程回调
handler.post {
tripRecordCallbackList.forEach { callback ->
callback.queryTripRecordListSuccess(tripRecordList)
}
}
}
}
fun insertTripRecord(record: TripRecord) {
ThreadPoolService.singleExecute {
// 先查一下此数据是否存在
Logger.d(MODULE_NAME, "出行动态入库===$record")
var check = tripRecordDao.queryTripRecordById(record.id)
if (check == null) {
Logger.d(MODULE_NAME, "数据库中不存在此数据,直接插入")
check = record
tripRecordDao.insert(record)
} else {
Logger.d(MODULE_NAME, "数据库中存在此数据更新recordTime即可其他参数不变")
check.recordTime = System.currentTimeMillis()
tripRecordDao.update(check)
}
// 为了防止只进不出,所以在插入新数据时,进行过期数据删除操作
tripRecordDao.deleteOvertimeTripRecord(countLimitTime())
// 切换线程回调
handler.post {
tripRecordCallbackList.forEach { callback ->
callback.insertOrUpdateTripRecordSuccess(check)
}
}
}
}
/**
* 计算约束时间即当日0时
*/
private fun countLimitTime(): Long {
val calendar = Calendar.getInstance()
calendar.time = Date()
calendar.set(Calendar.HOUR_OF_DAY, 0)
calendar.set(Calendar.MINUTE, 0)
calendar.set(Calendar.SECOND, 0)
return calendar.timeInMillis
}
/**
* 处理道路事件推送,保存到本地数据库
* 目前只处理道路事件,违章提醒,他车求助,其他事件暂不处理
*/
private fun dealSceneMessage(type: Int, content: Any) {
if (type in arrayOf(ALERT_ROAD_WARNING, ALERT_ILLEGAL_PARK_WARNING, ALERT_SEEK_WARNING)) {
val eventId = if (type == ALERT_ROAD_WARNING) {
val event = content as V2XRoadEventEntity
event.noveltyInfo.infoId
} else {
""
}
Logger.d(MODULE_NAME, "处理场景事件,准备插入数据库===eventId: $eventId")
insertTripRecord(TripRecord(id = content.hashCode(), eventId = eventId, eventType = type, entity = GsonUtil.jsonFromObject(content)))
}
}
/**
* 本地数据库同步v2x传过来的纠错信息
*/
fun syncRoadEventModifyState(eventId: String, modifyType: String) {
Logger.d(MODULE_NAME, "准备同步纠错信息: $eventId, $modifyType")
ThreadPoolService.singleExecute {
// 找出需要纠错的数据
val willModify = tripRecordDao.queryTripRecordByEventId(eventId)
if (willModify != null) {
// 查到数据进行修改,如果查不到数据,就不做操作了
Logger.d(MODULE_NAME, "准备修改纠错状态:$willModify")
willModify.usefulStatus = modifyType
tripRecordDao.update(willModify)
// 切线程回调
handler.post {
tripRecordCallbackList.forEach { callback ->
callback.insertOrUpdateTripRecordSuccess(willModify)
}
}
}
}
}
class SceneEventReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Logger.d(MODULE_NAME, "收到V2X事件推送===")
when (intent.action) {
BROADCAST_SCENE_EVENT_ACTION -> {
// 道路事件推送
val message = intent.getSerializableExtra(BROADCAST_SCENE_EXTRA_KEY) as V2XMessageEntity<*>
Logger.d(MODULE_NAME, "道路事件推送 type: ${message.type}, content: ${message.content}")
dealSceneMessage(message.type, message.content)
}
BROADCAST_SCENE_MODIFY_ACTION -> {
// 纠错推送
syncRoadEventModifyState(intent.getStringExtra(BORADCAST_SCENE_MODIFY_EVENT_ID_KEY), intent.getStringExtra(BROADCAST_SCENE_MODIFY_EVENT_UPDATE_TYPE_KEY))
}
}
}
}
}

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clPanelContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vpEventPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<Button
android:id="@+id/btnShowOrHidePanels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:layout_marginEnd="10dp"
android:text="显示面板"
android:textColor="#000"
android:textSize="20sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clPanelContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Surrounding Event"
android:textColor="#fff"
android:textSize="40sp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clPanelContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Trip Record"
android:textColor="#000"
android:textSize="40sp" />
<Button
android:id="@+id/btnInsert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Insert"
android:textColor="#000"
android:textSize="30sp"
android:layout_marginTop="100dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/btnUpdate"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Update"
android:textColor="#000"
android:textSize="30sp"
android:layout_marginTop="100dp"
app:layout_constraintLeft_toRightOf="@+id/btnInsert"
app:layout_constraintRight_toLeftOf="@+id/btnDelete"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:textColor="#000"
android:textSize="30sp"
android:layout_marginTop="100dp"
app:layout_constraintLeft_toRightOf="@+id/btnUpdate"
app:layout_constraintRight_toLeftOf="@+id/btnQuery"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnQuery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Query"
android:textColor="#000"
android:textSize="30sp"
android:layout_marginTop="100dp"
app:layout_constraintLeft_toRightOf="@+id/btnDelete"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnGenerate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="GenerateLimitTime"
android:textColor="#000"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnInsert" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/road_case_share_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:overScrollMode="never"
android:background="#000000"
tools:itemCount="1"
tools:listitem="@layout/module_event_panel_share_description"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>

View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View File

@@ -204,6 +204,11 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mApis.getSearchManagerApi().goSettings();
return true;
});
mUploadRoadCondition.setOnLongClickListener(view->{
mApis.getMogoMonitorApi().showLogDebugDialog();
return true;
});
}
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);

View File

@@ -31,6 +31,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.monitor.IMogoMonitorProvider;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.utils.logger.Logger;
import com.zhidao.autopilot.support.api.AutopilotServiceManage;
@@ -170,6 +171,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
hideLayout();
}
} );
// 初始化MonitorModule
IMogoMonitorProvider monitorProvider = (IMogoMonitorProvider) ARouter.getInstance().build(MogoServicePaths.PATH_MOGO_MONITOR).navigation(this);
monitorProvider.resetActivityContext(this);
}
private void startBaseService() {

View File

@@ -1,7 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.alibaba.arouter'
android {
@@ -13,14 +10,13 @@ android {
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()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
@@ -31,20 +27,17 @@ android {
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.mogologlib
implementation rootProject.ext.dependencies.arouter
kapt rootProject.ext.dependencies.aroutercompiler
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
compileOnly rootProject.ext.dependencies.modulecommon
} else {

View File

@@ -1,3 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-event-panel
POM_ARTIFACT_ID=module-monitor
VERSION_CODE=1

View File

@@ -18,6 +18,4 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.zhidao.mogo.module.event.panel.EventPanelConstants
#-renamesourcefileattribute SourceFile

View File

@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhidao.mogo.module.event.panel">
package="com.zhidao.mogo.module.monitor">
/
</manifest>

View File

@@ -0,0 +1,11 @@
package com.zhidao.mogo.module.monitor;
class MogoMonitorConst {
public static final String MODULE_NAME = "MogoMonitor";
public static final String MODULE_PATH = "/monitor/api";
public static final int LOG_PUSH_TYPE = 500000;
public static final int START_CATCH_LOG = 1;
public static final int STOP_CATCH_LOG = 2;
}

View File

@@ -0,0 +1,118 @@
package com.zhidao.mogo.module.monitor;
import android.content.Context;
import android.util.ArrayMap;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.monitor.IMogoMonitorProvider;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.zhidao.loglib.LogInfoManager;
import com.zhidao.loglib.bean.RemoteLogPushContent;
import com.zhidao.loglib.dialog.ILogDialogListener;
import com.zhidao.loglib.upload.UploadManager;
import com.zhidao.loglib.util.LogInfoManagerFactory;
import com.zhidao.loglib.util.LoggingNotice;
import java.util.Map;
/**
* 应用监控模块provider
* @author tongchenfei
*/
@Route(path = MogoMonitorConst.MODULE_PATH)
public class MogoMonitorProvider implements IMogoMonitorProvider, IMogoOnMessageListener<RemoteLogPushContent>, ILogDialogListener {
private static final String TAG = MogoMonitorConst.MODULE_NAME;
private LogInfoManager manualCatchLog = null;
private Map<String, LogInfoManager> managerCache = new ArrayMap<>();
private Context context;
@Override
public void showLogDebugDialog() {
if (manualCatchLog == null) {
manualCatchLog = LogInfoManagerFactory.createManualLogInfoManager(context);
}
manualCatchLog.showDebugWindow().setDialogListener(this);
}
@Override
public void init(Context context) {
IMogoServiceApis apis =
(IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
apis.getSocketManagerApi(context).registerOnMessageListener(MogoMonitorConst.LOG_PUSH_TYPE,this);
}
@Override
public void resetActivityContext(Context context) {
this.context = context;
UploadManager.getInstance().init(context);
LoggingNotice.getInstance().init(context);
}
@Override
public Class<RemoteLogPushContent> target() {
return RemoteLogPushContent.class;
}
@Override
public void onMsgReceived(RemoteLogPushContent obj) {
Logger.d(TAG, "收到push消息: " + obj);
switch (obj.getType()){
case MogoMonitorConst.START_CATCH_LOG:
if (managerCache.containsKey(obj.getPkgName())) {
Logger.d(TAG, "这个包名的日志正在抓了: " + obj);
return;
}
openLoggerLevel();
LogInfoManager infoManager =
LogInfoManagerFactory.createPushLogInfoManager(context, obj);
infoManager.start();
managerCache.put(obj.getPkgName(), infoManager);
break;
case MogoMonitorConst.STOP_CATCH_LOG:
LogInfoManager stopManager = managerCache.remove(obj.getPkgName());
if (stopManager != null) {
stopManager.stop();
}
closeLoggerLevel();
break;
default:
break;
}
}
@Override
public void onLogStart() {
// 这个是通过对话框点击开始的回调
isInManualCatchLog = true;
openLoggerLevel();
}
@Override
public void onLogStop() {
// 这个是通过对话框点击结束的回调
isInManualCatchLog = false;
closeLoggerLevel();
}
private boolean isInManualCatchLog = false;
/**
* 放开Logger的限制
*/
private void openLoggerLevel(){
Logger.init(LogLevel.DEBUG);
}
/**
* 根据状态收紧Logger的限制
*/
private void closeLoggerLevel(){
if (!isInManualCatchLog && managerCache.size() == 0) {
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
}
}
}

View File

@@ -1 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

View File

@@ -1 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

View File

@@ -1 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

View File

@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'android-aspectjx'
@@ -53,6 +54,16 @@ dependencies {
implementation rootProject.ext.dependencies.carcallprovider
implementation rootProject.ext.dependencies.carcall
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.material
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.androidxviewpager2
implementation rootProject.ext.dependencies.localbroadcastmanager
kapt rootProject.ext.dependencies.roomAnnotationProcessor
kapt rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogomap
implementation rootProject.ext.dependencies.mogoutils

View File

@@ -9,14 +9,22 @@ package com.mogo.module.v2x;
*/
public class V2XConst {
/**
* 类型
* V2X面板名称
*/
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";
/**
* 事件面板名称
*/
public static final String MODULE_NAME_EVENT_PANEL = "MODULE_EVENT_PANEL";
/**
* 事件面板路径
*/
public static final String PATH_EVENT_PANEL = "/event/panel";
/**
* V2X 场景广播 Action
@@ -25,7 +33,7 @@ public class V2XConst {
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 SEEK_HELP_TIME = "seek_help_time";
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";

View File

@@ -0,0 +1,95 @@
package com.mogo.module.v2x;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
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.IMogoMarkerClickListener;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.module.v2x.fragment.V2XEventPanelFragment;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
import com.mogo.utils.logger.Logger;
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_EVENT_PANEL)
public class V2XEventPanelModuleProvider implements
IMogoModuleProvider {
private final String TAG = "EventPanelModuleProvider";
@Override
public Fragment createFragment(Context context, Bundle data) {
return V2XEventPanelFragment.Companion.getInstance();
}
@Override
public View createView(Context context) {
return null;
}
@NonNull
@Override
public String getModuleName() {
return V2XConst.MODULE_NAME_EVENT_PANEL;
}
@Override
public IMogoModuleLifecycle getCardLifecycle() {
return null;
}
@Override
public IMogoMapListener getMapListener() {
return null;
}
@Override
public int getType() {
return ModuleType.TYPE_CARD_FRAGMENT;
}
@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, "事件模版 模块初始化。。。。");
}
}

View File

@@ -15,7 +15,6 @@ import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
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.model.MogoPoi;
import com.mogo.map.navi.IMogoNaviListener;
@@ -23,7 +22,6 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XMessageEntity;
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.v2x.network.V2XRefreshCallback;
@@ -34,6 +32,7 @@ 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.V2XSQLiteUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.service.module.IMogoModuleLifecycle;
@@ -76,7 +75,7 @@ public class V2XModuleProvider implements
@NonNull
@Override
public String getModuleName() {
return ServiceConst.TYPE;
return MODULE_NAME;
}
@Override
@@ -121,18 +120,15 @@ public class V2XModuleProvider implements
@Override
public void init(Context context) {
Logger.e(MODULE_NAME, "V2X模块初始化。。。。");
Logger.e(MODULE_NAME, "V2X 模块初始化。。。。");
mContext = context;
V2XUtils.init(context);
V2XServiceManager.init(context);
initVoice(context);
handleAdas();
V2XVoiceManager.INSTANCE.init(context);
registerListener();
initData();
V2XServiceManager.getMogoRegisterCenter().registerMogoMapListener(V2XConst.MODULE_NAME, this);
// 注册广播接收场景弹窗使用的
SceneBroadcastReceiver localReceiver = new SceneBroadcastReceiver();
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
@@ -148,10 +144,6 @@ public class V2XModuleProvider implements
}
}
private void initVoice(Context context) {
V2XVoiceManager.INSTANCE.init(context);
}
private void initData() {
try {
// 查询ACC状态
@@ -171,33 +163,14 @@ public class V2XModuleProvider implements
}
// 刷新配置文件
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;
}
});
// 清除V2X事件数据库中过期的数据数据有效期为24小时
V2XSQLiteUtils.clearYesterdayScenarioHistoryData();
}
/**
* 获取疲劳驾驶的配置
*/
private void refreshStrategyConfig() {
// 获取疲劳驾驶的配置
V2XServiceManager
.getV2XRefreshModel()
.getStrategyPush(new V2XRefreshCallback<V2XStrategyPushRes>() {
@@ -219,21 +192,53 @@ public class V2XModuleProvider implements
});
}
private void handleAdas() {
/**
* 注册各种监听
*/
private void registerListener() {
// 初始化监听
V2XServiceManager.getMogoRegisterCenter()
.registerMogoMapListener(V2XConst.MODULE_NAME, this);
V2XServiceManager.getMoGoStatusManager()
.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.ACC_STATUS, this);
V2XServiceManager.getMoGoStatusManager()
.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.SEEK_HELPING, this);
// 响应违章停车的POI点击
V2XServiceManager
.getMogoRegisterCenter()
.registerMogoMarkerClickListener(V2XConst.MODULE_NAME,
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;
});
// 注册V2X场景Socket
V2XServiceManager.getV2XSocketManager().registerSocketMessage();
// 开启自动刷新
// 开启自动刷新,暂时关闭间隔查询来降低流量消耗
V2XServiceManager.getV2XMarkerService().startAutoRefresh();
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
V2XServiceManager.getMapUIController().recoverLockMode();
}
private void handleSeekHelp(boolean isTrue) {
/**
* 刷新自车求助状态
*
* @param isTrue
*/
private void refreshMeSeekHelp(boolean isTrue) {
V2XMessageEntity<Boolean> entity = new V2XMessageEntity<>();
entity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP);
entity.setContent(isTrue);
@@ -256,16 +261,24 @@ public class V2XModuleProvider implements
.putString(V2XConst.V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString());
}
} else if (descriptor == StatusDescriptor.SEEK_HELPING) {
handleSeekHelp(isTrue);
refreshMeSeekHelp(isTrue);
}
}
/**
* 是否是ACC ON操作
*
* @return true-ACC ON false - ACC OFF
*/
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>() {
@@ -278,12 +291,12 @@ public class V2XModuleProvider implements
//故障车
if (vehicleType == 4) {
if (!V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
handleSeekHelp(true);
refreshMeSeekHelp(true);
V2XServiceManager.getMoGoStatusManager().setSeekHelping(MODULE_NAME, true);
}
} else {
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
handleSeekHelp(false);
refreshMeSeekHelp(false);
V2XServiceManager.getMoGoStatusManager().setSeekHelping(MODULE_NAME, false);
}
}

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.utils.logger.Logger;
/**
* author : donghongyu
@@ -53,6 +54,7 @@ public class V2XStatusManager {
if (mLocation == null) {
mLocation = new MogoLocation();
}
Logger.d(V2XConst.MODULE_NAME, "当前车辆位置:" + mLocation.toString());
return mLocation;
}

View File

@@ -0,0 +1,62 @@
package com.mogo.module.v2x.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.amap.api.maps.model.Text;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.panel.SurroundingResponse;
import java.util.List;
/**
* @author lixiaopeng
* @description 周边
* @since 2020/7/29
*/
public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEventViewHolder>{
private List<SurroundingResponse.ResultBean.PoiInfosBean> mPoiInfosList;
private Context mContext;
private TextView mAddressTv;
public SurroundingEventAdapter(Context context, List<SurroundingResponse.ResultBean.PoiInfosBean> poiInfosList) {
mContext = context;
mPoiInfosList = poiInfosList;
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
@NonNull
@Override
public SurroundingEventViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View inflate = LayoutInflater.from(parent.getContext())
.inflate(R.layout.module_fragment_surrounding_event_item, parent, false);
return new SurroundingEventViewHolder(inflate);
}
@Override
public void onBindViewHolder(@NonNull SurroundingEventViewHolder holder, int position) {
final SurroundingResponse.ResultBean.PoiInfosBean poiInfosBean = mPoiInfosList.get(position);
if (poiInfosBean == null) {
return;
}
// mAddressTv = holder.itemView.findViewById(R.id.tv_information);
}
@Override
public int getItemCount() {
return mPoiInfosList == null ? 0 : mPoiInfosList.size();
}
}

View File

@@ -0,0 +1,19 @@
package com.mogo.module.v2x.adapter;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingEventViewHolder extends RecyclerView.ViewHolder{
public SurroundingEventViewHolder(@NonNull View itemView) {
super(itemView);
}
}

View File

@@ -0,0 +1,21 @@
package com.mogo.module.v2x.adapter
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
/**
* 事件面板viewpager2的adapter
*
* @author tongchenfei
*/
class V2XEventPagerAdapter(fragment: Fragment,
private val fragments: Array<Fragment>) :
FragmentStateAdapter(fragment) {
/**
* 目前一共就三个fragment
*/
override fun getItemCount(): Int = fragments.size
override fun createFragment(position: Int): Fragment = fragments[position]
}

View File

@@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.common.entity.V2XWindowTypeEnum;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.v2x.adapter.holder.V2XFatigueDrivingVH;
import com.mogo.module.v2x.adapter.holder.V2XIllegalParkVH;
import com.mogo.module.v2x.adapter.holder.V2XLiveVideoVH;
@@ -37,27 +37,27 @@ public class V2XRoadEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
RecyclerView.ViewHolder holder;
switch (viewType) {
// 直播
case V2XWindowTypeEnum.LIVE_CAR_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_LIVE_CAR_WARNING:
holder = new V2XLiveVideoVH(parent);
break;
//道路事件详情
case V2XWindowTypeEnum.ROAD_EVENT_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
holder = new V2XRoadEventVH(parent);
break;
//违章停车
case V2XWindowTypeEnum.ILLEGAL_PARK_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING:
holder = new V2XIllegalParkVH(parent);
break;
//推送展示
case V2XWindowTypeEnum.PUSH_EVENT_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
holder = new V2XPushEventVH(parent);
break;
//疲劳驾驶
case V2XWindowTypeEnum.FATIGUE_DRIVING_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
holder = new V2XFatigueDrivingVH(parent);
break;
//他人故障求助
case V2XWindowTypeEnum.SEEK_HELP_WINDOW:
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
holder = new V2XOtherSeekHelpVH(parent);
break;
default:

View File

@@ -0,0 +1,93 @@
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.V2XHistoryScenarioData;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.v2x.adapter.holder.V2XScenarioHistoryFatigueDrivingVH;
import com.mogo.module.v2x.adapter.holder.V2XScenarioHistoryIllegalParkVH;
import com.mogo.module.v2x.adapter.holder.V2XScenarioHistoryOtherSeekHelpVH;
import com.mogo.module.v2x.adapter.holder.V2XScenarioHistoryPushEventVH;
import com.mogo.module.v2x.adapter.holder.V2XScenarioHistoryRoadEventVH;
import java.util.ArrayList;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<V2XHistoryScenarioData> mV2XHistoryScenarioData;
public V2XScenarioHistoryAdapter(ArrayList<V2XHistoryScenarioData> v2XHistoryScenarioData) {
if (v2XHistoryScenarioData != null) {
this.mV2XHistoryScenarioData = v2XHistoryScenarioData;
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder;
switch (viewType) {
//道路事件详情
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
holder = new V2XScenarioHistoryRoadEventVH(parent);
break;
//违章停车
case V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING:
holder = new V2XScenarioHistoryIllegalParkVH(parent);
break;
//推送展示
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
holder = new V2XScenarioHistoryPushEventVH(parent);
break;
//疲劳驾驶
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
holder = new V2XScenarioHistoryFatigueDrivingVH(parent);
break;
//他人故障求助
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
holder = new V2XScenarioHistoryOtherSeekHelpVH(parent);
break;
default:
holder = new V2XScenarioHistoryRoadEventVH(parent);
}
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof V2XScenarioHistoryRoadEventVH) {
((V2XScenarioHistoryRoadEventVH) holder).initView(mV2XHistoryScenarioData.get(position));
}
if (holder instanceof V2XScenarioHistoryIllegalParkVH) {
((V2XScenarioHistoryIllegalParkVH) holder).initView(mV2XHistoryScenarioData.get(position));
}
if (holder instanceof V2XScenarioHistoryPushEventVH) {
((V2XScenarioHistoryPushEventVH) holder).initView(mV2XHistoryScenarioData.get(position));
}
if (holder instanceof V2XScenarioHistoryFatigueDrivingVH) {
((V2XScenarioHistoryFatigueDrivingVH) holder).initView(mV2XHistoryScenarioData.get(position));
}
if (holder instanceof V2XScenarioHistoryOtherSeekHelpVH) {
((V2XScenarioHistoryOtherSeekHelpVH) holder).initView(mV2XHistoryScenarioData.get(position));
}
}
@Override
public int getItemViewType(int position) {
return mV2XHistoryScenarioData.get(position).getScenarioType();
}
@Override
public int getItemCount() {
return mV2XHistoryScenarioData == null ? 0 : mV2XHistoryScenarioData.size();
}
}

View File

@@ -1,224 +0,0 @@
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.SpanUtils;
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", 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);
SpanUtils.with(tvDistance)
.append("" + distance)
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_80))
.append("M")
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_30))
.create();
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

@@ -1,41 +1,41 @@
package com.zhidao.mogo.module.event.panel.adapter;
package com.mogo.module.v2x.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.panel.ShareEventDescription;
import com.mogo.module.v2x.entity.panel.ShareEventItem;
import com.mogo.module.v2x.entity.panel.ShareEventItemEnum;
import com.mogo.module.v2x.entity.panel.ShareEventLoadMoreItem;
import com.mogo.module.v2x.fragment.V2XEventPanelFragment;
import com.mogo.module.v2x.listener.AdapterCallback;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.DateTimeUtils;
import com.zhidao.mogo.module.event.panel.R;
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
import com.zhidao.mogo.module.event.panel.bean.ShareEventItemEnum;
import com.zhidao.mogo.module.event.panel.fragment.EventPanelFragment;
import java.util.ArrayList;
public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public class V2XShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private ArrayList dataArrayList;
private final LayoutInflater shareLayoutInflater;
private boolean emptylist;//分享空白页
private IMogoServiceApis mApis;
private AdapterCallback callback;
public void setEmptylist(boolean emptylist) {
this.emptylist = emptylist;
}
public ShareEventAdapter(Context context, ArrayList dataArrayList) {
public V2XShareEventAdapter(Context context, ArrayList dataArrayList, AdapterCallback callback) {
this.context = context;
this.dataArrayList = dataArrayList;
this.callback = callback;
shareLayoutInflater = LayoutInflater.from(context);
mApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
}
@@ -45,46 +45,75 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//根据viewType创建自定义布局
if (viewType == ShareEventItemEnum.ITEM_TYPE_NUM_DES) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_description, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_description, parent,
false);
shareDescriptionViewHolder holder = new shareDescriptionViewHolder(v);
return holder;
} else if (viewType == ShareEventItemEnum.ITEM_TYPE_SHARE_LIST) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_item, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_item, parent,
false);
shareItemViewHolder holder = new shareItemViewHolder(v);
return holder;
} else if (viewType == ShareEventItemEnum.ITEM_TYPE_SHARE_EMPTY) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_empty, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_empty, parent,
false);
shareEmptyViewHolder holder = new shareEmptyViewHolder(v);
return holder;
} else {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_load_status, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_load_status, parent,
false);
shareLoadStatusViewHolder holder = new shareLoadStatusViewHolder(v);
return holder;
}
}
private float getEnthusuasmIndex(double score) {
if (score <= 0) {
return 0;
} else if (0 < score && score <= 5) {
return (float) 0.5;
} else if (5 < score && score <= 10) {
return 1;
} else if (10 < score && score <= 15) {
return (float) 1.5;
} else if (15 < score && score <= 20) {
return 2;
} else if (20 < score && score <= 25) {
return (float) 2.5;
} else if (25 < score && score <= 30) {
return 3;
} else if (30 < score && score <= 35) {
return (float) 3.5;
} else if (35 < score && score <= 40) {
return 4;
} else if (40 < score && score <= 45) {
return (float) 4.5;
}
return 5;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof shareDescriptionViewHolder) {
//分享次数,车友认同次数,热心指数
if (dataArrayList.size() > position) {
ShareEventDescription.ResultBean.EnthusiasmIndexBean data = (ShareEventDescription.ResultBean.EnthusiasmIndexBean) dataArrayList.get(position);
if (data != null) {
String shareNum = String.valueOf(data.getShareNum());
String likeNum = String.valueOf(data.getLikeNum());
double enthusiasmIndex = data.getEnthusiasmIndex();
if (shareNum != null) {
((shareDescriptionViewHolder) holder).shareNumTextView.setText(shareNum);
}
if (likeNum != null) {
((shareDescriptionViewHolder) holder).approveNumTextView.setText(likeNum);
}
((shareDescriptionViewHolder) holder).ratingBar.setRating(getEnthusuasmIndex(enthusiasmIndex));
}
}
} else if (holder instanceof shareItemViewHolder) {
//分享列表
if (dataArrayList.size() > position) {
ShareEventItem.ResultBean.PageBean.ContentBean data = (ShareEventItem.ResultBean.PageBean.ContentBean) dataArrayList.get(position);
if (data != null) {
@@ -112,23 +141,27 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
} else if (holder instanceof shareLoadStatusViewHolder) {
((shareLoadStatusViewHolder) holder).statusButton.setText("加载更多");
ShareEventLoadMoreItem item = (ShareEventLoadMoreItem) dataArrayList.get(dataArrayList.size() - 1);
((shareLoadStatusViewHolder) holder).statusButton.setText(item.getStatusText());
}
}
@Override
public int getItemCount() {
return dataArrayList.size() + ((this.emptylist == true) ? 1 : 0);
int size = dataArrayList.size();
return dataArrayList.size();
}
@Override
public int getItemViewType(int position) {
if (position == 0) {
Object item = dataArrayList.get(position);
if (item instanceof ShareEventDescription.ResultBean.EnthusiasmIndexBean) {
return ShareEventItemEnum.ITEM_TYPE_NUM_DES;
}
if (emptylist == true) {
return ShareEventItemEnum.ITEM_TYPE_SHARE_EMPTY;
} else if (item instanceof ShareEventItem.ResultBean.PageBean.ContentBean) {
return ShareEventItemEnum.ITEM_TYPE_SHARE_LIST;
} else if (item instanceof ShareEventLoadMoreItem) {
return ((ShareEventLoadMoreItem) dataArrayList.get(position)).getViewType();
}
return ShareEventItemEnum.ITEM_TYPE_SHARE_LIST;
}
@@ -159,11 +192,13 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
class shareDescriptionViewHolder extends RecyclerView.ViewHolder {
private TextView shareNumTextView;
private TextView approveNumTextView;
private RatingBar ratingBar;
public shareDescriptionViewHolder(@NonNull View itemView) {
super(itemView);
shareNumTextView = itemView.findViewById(R.id.share_num);
approveNumTextView = itemView.findViewById(R.id.share_approve);
ratingBar = itemView.findViewById(R.id.rating_bar);
}
}
@@ -173,9 +208,10 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
class shareEmptyViewHolder extends RecyclerView.ViewHolder {
public shareEmptyViewHolder(@NonNull View itemView) {
super(itemView);
Button shareBtn = itemView.findViewById(R.id.share_event_button);
shareBtn.setOnClickListener(view -> {
EventPanelFragment.Companion.getInstance().hidePanel();
V2XEventPanelFragment.Companion.getInstance().hidePanel();
mApis.getShareManager().showShareDialog();
});
}
@@ -190,6 +226,13 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public shareLoadStatusViewHolder(@NonNull View itemView) {
super(itemView);
statusButton = itemView.findViewById(R.id.event_share_load_status);
statusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
callback.loadMoreShareEventList();
}
});
}
}
}

View File

@@ -28,7 +28,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
*
* @author donghongyu
*/
public abstract class V2XBaseViewHolder
public abstract class V2XBaseViewHolder<T>
extends RecyclerView.ViewHolder
implements IMogoNaviListener {
@@ -36,6 +36,14 @@ public abstract class V2XBaseViewHolder
super(itemView);
}
/**
* 填充View视图
*
* @param viewData 与视图绑定的数据
*/
public abstract void initView(T viewData);
/**
* 延迟关闭窗体视图
*/
@@ -91,10 +99,10 @@ public abstract class V2XBaseViewHolder
*/
public void triggerReportErr(MarkerExploreWay noveltyInfo) {
try {
RoadConditionUtils.sendDataErrorReceiverInfo(
RoadConditionUtils.sendShareReceiverInfo(
noveltyInfo.getPoiType(),
noveltyInfo.getInfoId(),
"1");
3);
TrackUtils.trackV2xRoadEvent(
noveltyInfo.getInfoId(),
@@ -112,10 +120,10 @@ public abstract class V2XBaseViewHolder
*/
public void triggerReportTrue(MarkerExploreWay noveltyInfo) {
try {
RoadConditionUtils.sendDataErrorReceiverInfo(
RoadConditionUtils.sendShareReceiverInfo(
noveltyInfo.getPoiType(),
noveltyInfo.getInfoId(),
"2");
2);
TrackUtils.trackV2xRoadEvent(
noveltyInfo.getInfoId(),

View File

@@ -29,7 +29,7 @@ import com.mogo.module.v2x.voice.V2XVoiceManager;
*
* @author donghongyu
*/
public class V2XFatigueDrivingVH extends V2XBaseViewHolder {
public class V2XFatigueDrivingVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private TextView mTvAddress, mTvAddressDistance;
private ImageView mIvToNav;
@@ -41,7 +41,7 @@ public class V2XFatigueDrivingVH extends V2XBaseViewHolder {
public V2XFatigueDrivingVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.window_fatigue_driving, viewGroup, false));
.inflate(R.layout.item_v2x_fatigue_driving, viewGroup, false));
mTvAddress = itemView.findViewById(R.id.tvAddress);
mTvAddressDistance = itemView.findViewById(R.id.tvAddressDistance);
mIvToNav = itemView.findViewById(R.id.ivToNav);
@@ -71,6 +71,7 @@ public class V2XFatigueDrivingVH extends V2XBaseViewHolder {
});
}
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
mV2XPushMessageEntity = v2XEventShowEntity.getV2XPushMessageEntity();
try {
@@ -97,9 +98,9 @@ public class V2XFatigueDrivingVH extends V2XBaseViewHolder {
SpanUtils.with(mTvAddressDistance)
.append("" + (int) mV2XPushMessageEntity.getDistance())
.setFontSize((int) itemView.getResources().getDimension(R.dimen.dp_80))
.append("M")
.setFontSize((int) itemView.getResources().getDimension(R.dimen.dp_30))
.setFontSize((int) itemView.getResources().getDimension(R.dimen.module_v2x_event_distance_text))
.append("m")
.setFontSize((int) itemView.getResources().getDimension(R.dimen.module_v2x_event_distance_title))
.create();
}

View File

@@ -29,7 +29,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
*
* @author donghongyu
*/
public class V2XIllegalParkVH extends V2XBaseViewHolder {
public class V2XIllegalParkVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private TextView mAddressTv;
private TextView mIllegalNumTv;
private HeartLikeView mIlIllegalParkingLike;
@@ -43,7 +43,7 @@ public class V2XIllegalParkVH extends V2XBaseViewHolder {
public V2XIllegalParkVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.window_illegal_parking, viewGroup, false));
.inflate(R.layout.item_v2x_illegal_parking, viewGroup, false));
mAddressTv = itemView.findViewById(R.id.tvAddress);
mIllegalNumTv = itemView.findViewById(R.id.tvIllegalNum);
@@ -75,6 +75,7 @@ public class V2XIllegalParkVH extends V2XBaseViewHolder {
});
}
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
mExploreWay = v2XEventShowEntity.getV2XIllegalPark();
mAddressTv.setText(mExploreWay.getAddr());
@@ -108,10 +109,10 @@ public class V2XIllegalParkVH extends V2XBaseViewHolder {
*/
private void roadReportTrue() {
if (mExploreWay != null) {
RoadConditionUtils.sendDataErrorReceiverInfo(
RoadConditionUtils.sendShareReceiverInfo(
mExploreWay.getPoiType(),
mExploreWay.getInfoId(),
"2");
2);
}
delayedCloseWindow();
}
@@ -121,10 +122,10 @@ public class V2XIllegalParkVH extends V2XBaseViewHolder {
*/
private void roadReportErr() {
if (mExploreWay != null) {
RoadConditionUtils.sendDataErrorReceiverInfo(
RoadConditionUtils.sendShareReceiverInfo(
mExploreWay.getPoiType(),
mExploreWay.getInfoId(),
"1");
3);
}
delayedCloseWindow();
}

View File

@@ -21,8 +21,9 @@ import com.mogo.service.imageloader.MogoImageView;
* date : 2020/3/11 4:35 PM
* desc : 直播类型的卡片
* version: 1.0
* @author donghongyu
*/
public class V2XLiveVideoVH extends V2XBaseViewHolder {
public class V2XLiveVideoVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private V2XLiveGSYVideoView videoPlayer;
private MogoImageView ivReportHead;
@@ -40,6 +41,7 @@ public class V2XLiveVideoVH extends V2XBaseViewHolder {
ivReportHead = itemView.findViewById(R.id.ivReportHead);
}
@Override
public void initView(V2XEventShowEntity v2XLiveCarEntity) {
mV2XRoadEventEntity = v2XLiveCarEntity.getV2XRoadEventEntity();
mV2XLiveCarEntity = v2XLiveCarEntity.getV2XLiveCarInfoRes();

View File

@@ -16,7 +16,6 @@ import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
import com.mogo.module.v2x.utils.ChartingUtil;
import com.mogo.module.v2x.utils.SpanUtils;
@@ -41,7 +40,7 @@ import static android.view.View.VISIBLE;
*
* @author donghongyu
*/
public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
public class V2XOtherSeekHelpVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private MogoImageView ivHead;
private TextView tvName;
@@ -116,6 +115,7 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
});
}
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
mV2XPushMessageEntity = v2XEventShowEntity.getV2XPushMessageEntity();
// 只有自研车机才会 有车聊聊通话
@@ -170,9 +170,9 @@ public class V2XOtherSeekHelpVH extends V2XBaseViewHolder {
tvName.setText(mV2XPushMessageEntity.getDisplayName());
SpanUtils.with(tvDistance)
.append("" + (int) mV2XPushMessageEntity.getDistance())
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_80))
.append("M")
.setFontSize((int) tvDistance.getResources().getDimension(R.dimen.dp_30))
.setFontSize((int) itemView.getResources().getDimension(R.dimen.module_v2x_event_distance_text))
.append("m")
.setFontSize((int) itemView.getResources().getDimension(R.dimen.module_v2x_event_distance_title))
.create();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.CHINA);
String eventTime = String.format("%s发布求助信息",

View File

@@ -27,8 +27,9 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* date : 2020/3/11 4:35 PM
* desc : TODO 这里是前瞻演示需求,推送的消息,
* version: 1.0
* @author donghongyu
*/
public class V2XPushEventVH extends V2XBaseViewHolder {
public class V2XPushEventVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private MogoImageView ivImg;
private MogoImageView ivReportHead;
@@ -136,6 +137,7 @@ public class V2XPushEventVH extends V2XBaseViewHolder {
});
}
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
mV2XRoadEventEntity = v2XEventShowEntity.getV2XPushMessageEntity();
mNoveltyInfo = new MarkerExploreWay();

View File

@@ -15,7 +15,6 @@ 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.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XUserInfoRes;
@@ -49,8 +48,9 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* date : 2020/3/11 4:35 PM
* desc : 道路事件详情
* version: 1.0
* @author donghongyu
*/
public class V2XRoadEventVH extends V2XBaseViewHolder {
public class V2XRoadEventVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private MogoImageView ivEventImg;
private MogoImageView ivReportHead;
private ImageView ivEventPlay;
@@ -156,6 +156,7 @@ public class V2XRoadEventVH extends V2XBaseViewHolder {
});
}
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
try {
if (v2XEventShowEntity == null) {
@@ -255,7 +256,7 @@ public class V2XRoadEventVH extends V2XBaseViewHolder {
List<V2XEventShowEntity> eventShowEntityArrayList = new ArrayList<>();
for (V2XLiveCarInfoEntity v2XLiveCarInfoRes : v2XEventShowEntity.getV2XLiveCarList()) {
V2XEventShowEntity showEntity = new V2XEventShowEntity();
showEntity.setViewType(V2XWindowTypeEnum.LIVE_CAR_WINDOW);
showEntity.setViewType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_LIVE_CAR_WARNING);
showEntity.setV2XLiveCarInfoRes(v2XLiveCarInfoRes);
showEntity.setV2XRoadEventEntity(mV2XRoadEventEntity);
eventShowEntityArrayList.add(showEntity);

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.mogo.module.common.entity.V2XHistoryScenarioData;
import com.mogo.module.v2x.R;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryFatigueDrivingVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public V2XScenarioHistoryFatigueDrivingVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_fatigue_driving, viewGroup, false));
}
@Override
public void initView(V2XHistoryScenarioData viewData) {
}
@Override
public void delayedCloseWindow() {
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.mogo.module.common.entity.V2XHistoryScenarioData;
import com.mogo.module.v2x.R;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryIllegalParkVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public V2XScenarioHistoryIllegalParkVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_illegal_parking, viewGroup, false));
}
@Override
public void initView(V2XHistoryScenarioData viewData) {
}
@Override
public void delayedCloseWindow() {
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.mogo.module.common.entity.V2XHistoryScenarioData;
import com.mogo.module.v2x.R;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryOtherSeekHelpVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public V2XScenarioHistoryOtherSeekHelpVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_fault_help, viewGroup, false));
}
@Override
public void initView(V2XHistoryScenarioData viewData) {
}
@Override
public void delayedCloseWindow() {
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.mogo.module.common.entity.V2XHistoryScenarioData;
import com.mogo.module.v2x.R;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryPushEventVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public V2XScenarioHistoryPushEventVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_push_event_detail, viewGroup, false));
}
@Override
public void initView(V2XHistoryScenarioData viewData) {
}
@Override
public void delayedCloseWindow() {
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.mogo.module.common.entity.V2XHistoryScenarioData;
import com.mogo.module.v2x.R;
/**
* @author donghongyu
*/
public class V2XScenarioHistoryRoadEventVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public V2XScenarioHistoryRoadEventVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_event_detail, viewGroup, false));
}
@Override
public void initView(V2XHistoryScenarioData viewData) {
}
@Override
public void delayedCloseWindow() {
}
}

View File

@@ -29,8 +29,8 @@ 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.mogo.utils.network.utils.GsonUtil;
import com.mogo.utils.storage.SharedPrefsMgr;
import java.util.ArrayList;
import java.util.HashMap;
@@ -41,7 +41,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* @author donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/13 11:02 AM
* desc :
@@ -96,7 +96,6 @@ public class V2XAlarmServer {
eventLocation.getLat(),
(int) currentLocation.getBearing()
);
// Logger.w(MODULE_NAME, "V2X预警--事件位置===" + eventLocation);
if (0 <= eventAngle && eventAngle <= 20) {
// 判断是否已经提示过道路事件
boolean isAlreadyAlert = false;
@@ -112,12 +111,12 @@ public class V2XAlarmServer {
isAlreadyAlert = true;
}
}
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n是否已经提醒" + isAlreadyAlert +
// "\n事件ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n事件详情" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo())
// );
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());
@@ -125,22 +124,23 @@ public class V2XAlarmServer {
}
return null;
} else {
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n角度" + eventAngle + " 度" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
Logger.w(MODULE_NAME, "V2X预警--事件与车头角度夹角过大:" +
"\n角度" + eventAngle + "" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
);
}
} else {
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了" +
"\n距离" + v2XRoadEventEntity.getDistance() + "" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
);
}
} else {
// Logger.w(MODULE_NAME,
// "车头方向: " + currentLocation.getAngle() +
// "\n事件方向" + v2XRoadEventEntity.getLocation().getAngle()
// );
Logger.w(MODULE_NAME,
"V2X预警--车头方向与事件方向角度不一致:" +
"\n车头方向 " + currentLocation.getBearing() +
"\n事件方向" + v2XRoadEventEntity.getLocation().getAngle()
);
}
}
}

View File

@@ -0,0 +1,12 @@
package com.mogo.module.v2x.entity.panel
/**
* @description
*
* @author lixiaopeng
* @since 2019-10-24
*/
data class Center (
val lat: Double,
val lon: Double
)

View File

@@ -1,4 +1,4 @@
package com.zhidao.mogo.module.event.panel.bean;
package com.mogo.module.v2x.entity.panel;
import com.mogo.commons.data.BaseData;
@@ -45,11 +45,11 @@ public class ShareEventDescription extends BaseData implements Serializable {
this.enthusiasmIndex = enthusiasmIndex;
}
public static class EnthusiasmIndexBean {
public static class EnthusiasmIndexBean{
@Override
public String toString() {
return "EnthusiasmIndexBean{" +
"id=" + id +
", id=" + id +
", sn='" + sn + '\'' +
", score=" + score +
", shareNum=" + shareNum +
@@ -72,7 +72,6 @@ public class ShareEventDescription extends BaseData implements Serializable {
* createTime : 2020-07-28T06:21:11.523+0000
* updateTime : 2020-07-28T06:21:11.523+0000
*/
private int id;
private String sn;
private int score;

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