From c78509d484cf0e9c325aff492d11385f235716f7 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 7 Dec 2022 15:22:12 +0800 Subject: [PATCH] =?UTF-8?q?[2.13.0][Fix]=E8=A7=A3=E5=86=B3=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9B=92=E5=AD=90=E8=BF=87=E6=9C=9F=E7=9A=84=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=B6=88=E6=81=AF=E6=9C=AA=E8=A2=AB=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/main/MainMoGoApplication.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index 7e5c962fbd..889febb1a4 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -43,6 +43,7 @@ import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo; import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo; import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb; +import java.io.File; import java.lang.reflect.Field; import java.text.SimpleDateFormat; import java.util.Date; @@ -101,15 +102,25 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { new Thread(() -> { String lastLaunchTimeStr = SPUtils.getInstance().getString("last_launch", ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Date currDate = new Date(System.currentTimeMillis()); + String currTimeStr = format.format(currDate); if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) { - Date currDate = new Date(System.currentTimeMillis()); - String currTimeStr = format.format(currDate); boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr); // 超过一天需要清除消息盒子中的数据,并把时间戳存入SP if (!isSameDay) { - this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); + File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); + if (file != null && file.exists()) { + this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); + } SPUtils.getInstance().put("last_launch", currTimeStr); } + } else { + // 首次使用App或中途仅删除sp文件 + File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); + if (file != null && file.exists()) { + this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); + } + SPUtils.getInstance().put("last_launch", currTimeStr); } }).start(); }