Commit dfa3e5fe authored by wanglei's avatar wanglei

...

parent 13990c6a
......@@ -3,11 +3,14 @@ package com.base.pdfviewerscannerwhite.fcm
import android.content.Context
import android.os.Handler
import android.os.HandlerThread
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
object NotificationHoverUtils {
private val TAG = "NotificationHoverUtils"
private var handlerThread: HandlerThread? = null
private var handler: Handler? = null
......@@ -22,8 +25,14 @@ object NotificationHoverUtils {
handlerThread?.start()
}
val hoverCount = AppPreferences.getInstance().getString("popup_hover_count", "0").toInt()
val hoverDelay = AppPreferences.getInstance().getString("popup_hover_delay", "0").toLong()
var hoverCount = AppPreferences.getInstance().getString("popup_hover_count", "0").toInt()
var hoverDelay = AppPreferences.getInstance().getString("popup_hover_delay", "0").toLong()
if (BuildConfig.DEBUG) {
hoverCount = 5
hoverDelay = 1000L
}
// 创建 Handler
if (handler == null) {
......@@ -35,11 +44,13 @@ object NotificationHoverUtils {
for (i in 1..hoverCount) {
val time = i * hoverDelay
handler?.postDelayed(Runnable {
if (MyApplication.PAUSED_VALUE === 1) {
LogEx.logDebug(TAG, "handler ${MyApplication.PAUSED_VALUE}")
if (MyApplication.PAUSED_VALUE == 1) {
handler?.removeCallbacksAndMessages(null)
return@Runnable
}
if (MyApplication.PAUSED_VALUE !== 1) {
if (MyApplication.PAUSED_VALUE != 1) {
LogEx.logDebug(TAG, "handler send notification")
NotificationUiUtil.setActionNotification(context, NotificationUiUtil.hoverActionId)
}
}, time)
......
......@@ -113,7 +113,7 @@ object NotificationUiUtil {
}
if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) {
EventUtils.event("Notification_Error", "where=$where actionId=$actionId interval=$interval")
LogEx.logDebug("canSendNotification", "interval")
LogEx.logDebug("canSendNotification", "interval where=$where")
return false
}
......@@ -140,7 +140,6 @@ object NotificationUiUtil {
//悬停通知
hoverActionId = actionId
NotificationHoverUtils.sendHoverNotification(context)
}
fun setActionNotification(context: Context, actionId: String) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment