Commit 6315bea1 authored by 周文华's avatar 周文华

【修复】修复通知栏中耗时操作导致的anr

parent 294472a7
......@@ -44,6 +44,10 @@ import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.RamUtils.ramPair
import com.base.pdfviewerscannerwhite.utils.TimeUtils.formatATime
import com.base.pdfviewerscannerwhite.utils.TimeUtils.isDayOrNight
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
......@@ -149,6 +153,10 @@ object NotificationUiUtil {
var hoverActionId = ""
val mainScope by lazy {
MainScope()
}
@SuppressLint("RemoteViewLayout")
fun sendNotificationIfCan(
context: Context,
......@@ -259,7 +267,8 @@ object NotificationUiUtil {
}
NOTIFICATION_ACTION_CLEAN_JUNK -> {
var size = fastGetJunkSize(context)
mainScope.launch {
var size = withContext(Dispatchers.IO){ fastGetJunkSize(context)}
if (size == 0L) {
size = Random.nextLong(1024 * 5, 1024 * 10)
}
......@@ -273,6 +282,7 @@ object NotificationUiUtil {
sendCustomNotification(context, intent, bigRemoteViewsVar, smallRemoteViewsVar)
}
}
NOTIFICATION_ACTION_WEATHER -> {
val weatherBean: WeatherBean = WeatherUtils.getWeatherEntity() ?: return
......
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