From efc140f512b0ccd501868d516ca6fbf16f2493dd Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Tue, 30 Dec 2025 16:24:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=B1=BB=E5=9E=8B=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=9C=BA=E5=88=B6=EF=BC=8C=20=E4=BB=8E=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E5=88=B6=E5=AE=9Alist=E9=9A=8F=E6=9C=BA=E9=80=89?= =?UTF-8?q?=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/newUtil/NotificationDatas.kt | 18 ++++++----- .../timing/NotificationTimingController.kt | 31 +++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) 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 8226835..988bcaa 100644 --- a/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationDatas.kt @@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap @SuppressLint("StaticFieldLeak") object NotificationDatas { - private var mCurRandomIndex = 0 + private val mLastRandomIndexMap: MutableMap = mutableMapOf() const val GAP_FOR_WITHDRAW_NOTIFY = 30 * 1000 var context: Context = BaseApp.appContext() @@ -222,16 +222,20 @@ object NotificationDatas { return mConfigMap[notifiType] } - fun getRandomConfig(): NotificationConfig { - var randomIndex = AndroidUtil.randomInt(0, mRandomConfigList.size - 1) - if (mCurRandomIndex == randomIndex) { + fun getRandomConfig(randomType:String, specifyList: List): NotificationConfig { + var randomIndex = AndroidUtil.randomInt(0, specifyList.size - 1) + val newGenIndex = specifyList[randomIndex] - 1 + val lastIndex = mLastRandomIndexMap[randomType] + + if (lastIndex == newGenIndex) { randomIndex++ - if (randomIndex >= mRandomConfigList.size) { + if (randomIndex >= specifyList.size) { randomIndex = 0 } } - mCurRandomIndex = randomIndex - return mRandomConfigList[mCurRandomIndex] + mLastRandomIndexMap.put(randomType, specifyList[randomIndex] - 1) + + return mRandomConfigList[mLastRandomIndexMap[randomType]!!] } } \ 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 6fffcbf..3149283 100644 --- a/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt +++ b/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt @@ -307,17 +307,6 @@ class NotificationTimingController private constructor() : LifecycleObserver { }*/ when (type) { - NotificationCheckController.NotificationType.UNLOCK -> { - showNotifyRandom() - } - - NotificationCheckController.NotificationType.BACKGROUND -> { - showNotifyWithdraw() - //showNotifyRandom() - //showNotifyResident() - } - - NotificationCheckController.NotificationType.KEEPALIVE -> { } @@ -331,15 +320,24 @@ class NotificationTimingController private constructor() : LifecycleObserver { } NotificationCheckController.NotificationType.FIXTIMEPOINT -> { - showNotifyRandom() + showNotifyRandom(NotificationCheckController.NotificationType.FIXTIMEPOINT.string, listOf(2,3,4,6,7,8)) } NotificationCheckController.NotificationType.APPINSTALL -> { - showNotifyRandom() + showNotifyRandom(NotificationCheckController.NotificationType.APPINSTALL.string, listOf(3,5,7,9,11)) } NotificationCheckController.NotificationType.CHARGE -> { - showNotifyRandom() + showNotifyRandom(NotificationCheckController.NotificationType.CHARGE.string, listOf(1,3,5,7,9,11)) + } + + NotificationCheckController.NotificationType.UNLOCK -> { + showNotifyRandom(NotificationCheckController.NotificationType.UNLOCK.string, listOf(2,4,6,8,10,11)) + } + + NotificationCheckController.NotificationType.BACKGROUND -> { + showNotifyWithdraw() + //showNotifyResident() } } @@ -351,7 +349,6 @@ class NotificationTimingController private constructor() : LifecycleObserver { private fun showNotifyWithdraw() { 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) @@ -360,8 +357,8 @@ class NotificationTimingController private constructor() : LifecycleObserver { } } - private fun showNotifyRandom() { - NotificationUtil.getInstance().showBasicNotification(NotificationDatas.getRandomConfig()) + private fun showNotifyRandom(randomType:String, randomList: List) { + NotificationUtil.getInstance().showBasicNotification(NotificationDatas.getRandomConfig(randomType, randomList)) }