From 5e5ba292bd8ed553d839ebc222d7f10bcae585bc Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Mon, 29 Dec 2025 18:15:02 +0800 Subject: [PATCH] =?UTF-8?q?app=E5=90=8E=E5=8F=B0=20=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=20=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ama/core/architecture/util/SpUtil.kt | 7 ++++++- .../notification/newUtil/NotificationDatas.kt | 1 + .../notification/newUtil/NotificationRecorder.kt | 16 ++++++++++++++++ .../timing/NotificationTimingController.kt | 14 ++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt diff --git a/core/architecture/src/main/java/com/ama/core/architecture/util/SpUtil.kt b/core/architecture/src/main/java/com/ama/core/architecture/util/SpUtil.kt index 5745f06..3746165 100644 --- a/core/architecture/src/main/java/com/ama/core/architecture/util/SpUtil.kt +++ b/core/architecture/src/main/java/com/ama/core/architecture/util/SpUtil.kt @@ -51,7 +51,12 @@ class SpUtil private constructor(spFileName: String) { - @Volatile + // notification 相关 + const val NOTIFI_LAST_WITHDRAW_SHOW_MS = "NOTIFI_LAST_WITHDRAW_SHOW_MS" + + + + @Volatile private var instance: SpUtil? = null fun instance(prefName: String = DEFAULT_SP_NAME): SpUtil { return instance ?: synchronized(this) { diff --git a/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt b/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt index 8f6346d..0a9aa40 100644 --- a/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt @@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap @SuppressLint("StaticFieldLeak") object NotificationDatas { + const val GAP_FOR_WITHDRAW_NOTIFY = 30 * 1000 var context: Context = BaseApp.appContext() diff --git a/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt b/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt new file mode 100644 index 0000000..40c8e32 --- /dev/null +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt @@ -0,0 +1,16 @@ +package com.remax.notification.newUtil + +import com.ama.core.architecture.util.SpUtil + +object NotificationRecorder { + + fun saveLastWithdrawShowTime(newLastShowTime: Long) { + SpUtil.instance().putLong(SpUtil.NOTIFI_LAST_WITHDRAW_SHOW_MS, newLastShowTime) + } + + fun getLastWithdrawShowTime() : Long { + return SpUtil.instance().getLong(SpUtil.NOTIFI_LAST_WITHDRAW_SHOW_MS) + } + + +} \ No newline at end of file diff --git a/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt b/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt index c2c8e6d..d8d4c88 100644 --- a/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt +++ b/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt @@ -23,12 +23,15 @@ import com.remax.notification.TaskStateNewBieFirstWithDraw2 import com.remax.notification.controller.NotificationTriggerController import com.remax.notification.check.NotificationCheckController import com.remax.notification.newUtil.NotificationDatas +import com.remax.notification.newUtil.NotificationDatas.GAP_FOR_WITHDRAW_NOTIFY import com.remax.notification.newUtil.NotificationDatas.NOTI_TYPE_BG_WITHDRAW +import com.remax.notification.newUtil.NotificationRecorder import com.remax.notification.newUtil.NotificationUtil import com.remax.notification.utils.NotiLogger import com.remax.notification.utils.FCMTopicManager import com.remax.notification.service.FCMService import com.remax.notification.service.NotificationKeepAliveServiceManager +import com.remax.notification.utils.DateUtil import com.remax.notification.utils.Topic import com.remax.notification.worker.NotificationKeepAliveWorker import kotlinx.coroutines.CoroutineScope @@ -343,10 +346,13 @@ class NotificationTimingController private constructor() : LifecycleObserver { private fun showNotifyWithdraw() { - val hasClaimedSmallCash = SpUtil.instance().getObject(SpUtil.KEY_NEWBIE_FIRST_WITHDRAW)?.hasClaimReward - NotificationDatas.getConfigForType(NOTI_TYPE_BG_WITHDRAW)?.let { - it.content = String.format(it.content, if (hasClaimedSmallCash == null || !hasClaimedSmallCash) 0.1 else 50) - NotificationUtil.getInstance().showHeadsUpNotification(it) + if (System.currentTimeMillis() - NotificationRecorder.getLastWithdrawShowTime() >= GAP_FOR_WITHDRAW_NOTIFY) { + + val hasClaimedSmallCash = SpUtil.instance().getObject(SpUtil.KEY_NEWBIE_FIRST_WITHDRAW)?.hasClaimReward + NotificationDatas.getConfigForType(NOTI_TYPE_BG_WITHDRAW)?.let { + it.content = String.format(it.content, if (hasClaimedSmallCash == null || !hasClaimedSmallCash) 0.1 else 50) + NotificationUtil.getInstance().showHeadsUpNotification(it) + } } }