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)) }