package com.remax.notification.newUtil

import com.ama.core.architecture.util.DateUtil
import com.ama.core.architecture.util.SpUtil
import com.remax.notification.NotifyConst

object NotificationRecorder {
    private val mLastShowTimeMap = mutableMapOf<String, Long>()
    private var mLastSystemAlertTimeMs = DateUtil.getCurTimeMs() - NotifyConst.MIN_INTERVAL_SHOW_SYSTEM_ALERT + 20 * 1000

    init {
        mLastShowTimeMap.putAll( SpUtil.instance().getMap<String, Long>(SpUtil.NOTIFI_LAST_NOTIFY_SHOW_MS))
    }

    fun saveLastNotifyShowTime(notifyType: String, newLastShowTime: Long) {
        mLastShowTimeMap.put(notifyType, newLastShowTime)
        SpUtil.instance().putMap(SpUtil.NOTIFI_LAST_NOTIFY_SHOW_MS, mLastShowTimeMap)
    }

    fun getLastNotifyShowTime(notifyType: String) : Long {
        return mLastShowTimeMap[notifyType]?: 0L
    }

    fun getLastSystemAlertShowTime(): Long {
        return mLastSystemAlertTimeMs
    }

    fun setLastSystemAlertShowTime() {
        mLastSystemAlertTimeMs = DateUtil.getCurTimeMs()
    }


}