Commit dfa3e5fe authored by wanglei's avatar wanglei

...

parent 13990c6a
...@@ -3,11 +3,14 @@ package com.base.pdfviewerscannerwhite.fcm ...@@ -3,11 +3,14 @@ package com.base.pdfviewerscannerwhite.fcm
import android.content.Context import android.content.Context
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
object NotificationHoverUtils { object NotificationHoverUtils {
private val TAG = "NotificationHoverUtils"
private var handlerThread: HandlerThread? = null private var handlerThread: HandlerThread? = null
private var handler: Handler? = null private var handler: Handler? = null
...@@ -22,8 +25,14 @@ object NotificationHoverUtils { ...@@ -22,8 +25,14 @@ object NotificationHoverUtils {
handlerThread?.start() handlerThread?.start()
} }
val hoverCount = AppPreferences.getInstance().getString("popup_hover_count", "0").toInt() var hoverCount = AppPreferences.getInstance().getString("popup_hover_count", "0").toInt()
val hoverDelay = AppPreferences.getInstance().getString("popup_hover_delay", "0").toLong() var hoverDelay = AppPreferences.getInstance().getString("popup_hover_delay", "0").toLong()
if (BuildConfig.DEBUG) {
hoverCount = 5
hoverDelay = 1000L
}
// 创建 Handler // 创建 Handler
if (handler == null) { if (handler == null) {
...@@ -35,11 +44,13 @@ object NotificationHoverUtils { ...@@ -35,11 +44,13 @@ object NotificationHoverUtils {
for (i in 1..hoverCount) { for (i in 1..hoverCount) {
val time = i * hoverDelay val time = i * hoverDelay
handler?.postDelayed(Runnable { handler?.postDelayed(Runnable {
if (MyApplication.PAUSED_VALUE === 1) { LogEx.logDebug(TAG, "handler ${MyApplication.PAUSED_VALUE}")
if (MyApplication.PAUSED_VALUE == 1) {
handler?.removeCallbacksAndMessages(null) handler?.removeCallbacksAndMessages(null)
return@Runnable return@Runnable
} }
if (MyApplication.PAUSED_VALUE !== 1) { if (MyApplication.PAUSED_VALUE != 1) {
LogEx.logDebug(TAG, "handler send notification")
NotificationUiUtil.setActionNotification(context, NotificationUiUtil.hoverActionId) NotificationUiUtil.setActionNotification(context, NotificationUiUtil.hoverActionId)
} }
}, time) }, time)
......
...@@ -113,7 +113,7 @@ object NotificationUiUtil { ...@@ -113,7 +113,7 @@ object NotificationUiUtil {
} }
if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) { if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) {
EventUtils.event("Notification_Error", "where=$where actionId=$actionId interval=$interval") EventUtils.event("Notification_Error", "where=$where actionId=$actionId interval=$interval")
LogEx.logDebug("canSendNotification", "interval") LogEx.logDebug("canSendNotification", "interval where=$where")
return false return false
} }
...@@ -140,7 +140,6 @@ object NotificationUiUtil { ...@@ -140,7 +140,6 @@ object NotificationUiUtil {
//悬停通知 //悬停通知
hoverActionId = actionId hoverActionId = actionId
NotificationHoverUtils.sendHoverNotification(context) NotificationHoverUtils.sendHoverNotification(context)
} }
fun setActionNotification(context: Context, actionId: String) { 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