完成了事件面板的视图更新
This commit is contained in:
@@ -79,13 +79,7 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
}
|
||||
}
|
||||
|
||||
val historyMessage = V2XSQLiteUtils.getScenarioHistoryUnDisposeData()
|
||||
if (historyMessage != null && historyMessage.size > 0) {
|
||||
tvEventCount.visibility = View.VISIBLE
|
||||
tvEventCount.text = "${historyMessage.size}"
|
||||
} else {
|
||||
tvEventCount.visibility = View.GONE
|
||||
}
|
||||
changeEventCount()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -112,4 +106,15 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
fun isPanelShow(): Boolean {
|
||||
return clPanelContainer.visibility == View.VISIBLE
|
||||
}
|
||||
|
||||
// 修改未处理消息
|
||||
fun changeEventCount() {
|
||||
val historyMessage = V2XSQLiteUtils.getScenarioHistoryUnDisposeData()
|
||||
if (historyMessage != null && historyMessage.size > 0) {
|
||||
tvEventCount.visibility = View.VISIBLE
|
||||
tvEventCount.text = "${historyMessage.size}"
|
||||
} else {
|
||||
tvEventCount.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,13 +106,7 @@ public abstract class AbsV2XScenario<T> implements IV2XScenario {
|
||||
*/
|
||||
public void saveLocalStory(int scenarioType, Object markerExploreWay) {
|
||||
try {
|
||||
// 进行数据库存储
|
||||
V2XHistoryScenarioData v2XHistoryScenarioData = new V2XHistoryScenarioData();
|
||||
v2XHistoryScenarioData.setScenarioType(scenarioType);
|
||||
v2XHistoryScenarioData.setTriggerTime(TimeUtils.getNowMills());
|
||||
v2XHistoryScenarioData.setEventJsonData(GsonUtil.jsonFromObject(markerExploreWay));
|
||||
v2XHistoryScenarioData.setDispose(false);
|
||||
V2XSQLiteUtils.getScenarioHistoryDao().insert(v2XHistoryScenarioData);
|
||||
V2XSQLiteUtils.saveLocalStory(scenarioType,markerExploreWay);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.mogo.module.v2x.utils;
|
||||
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.fragment.V2XEventPanelFragment;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.sqlite.SQLDaoFactory;
|
||||
import com.mogo.utils.sqlite.SQLIDao;
|
||||
|
||||
@@ -61,6 +63,7 @@ public class V2XSQLiteUtils {
|
||||
try {
|
||||
int result = getScenarioHistoryDao().delete(new V2XHistoryScenarioData());
|
||||
Logger.d(V2XConst.MODULE_NAME, "删除数据成功:" + result);
|
||||
V2XEventPanelFragment.Companion.getInstance().changeEventCount();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -89,6 +92,27 @@ public class V2XSQLiteUtils {
|
||||
try {
|
||||
int result = getScenarioHistoryDao().update(oldScenarioData, newScenarioData);
|
||||
Logger.d(V2XConst.MODULE_NAME, "修改数据成功:" + result);
|
||||
V2XEventPanelFragment.Companion.getInstance().changeEventCount();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储本地数据
|
||||
*
|
||||
* @param markerExploreWay 要存储的场景
|
||||
*/
|
||||
public static void saveLocalStory(int scenarioType, Object markerExploreWay) {
|
||||
try {
|
||||
// 进行数据库存储
|
||||
V2XHistoryScenarioData v2XHistoryScenarioData = new V2XHistoryScenarioData();
|
||||
v2XHistoryScenarioData.setScenarioType(scenarioType);
|
||||
v2XHistoryScenarioData.setTriggerTime(TimeUtils.getNowMills());
|
||||
v2XHistoryScenarioData.setEventJsonData(GsonUtil.jsonFromObject(markerExploreWay));
|
||||
v2XHistoryScenarioData.setDispose(false);
|
||||
V2XSQLiteUtils.getScenarioHistoryDao().insert(v2XHistoryScenarioData);
|
||||
V2XEventPanelFragment.Companion.getInstance().changeEventCount();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user