ANR fixes
This commit is contained in:
parent
fd3082dbc1
commit
4e98c04bf0
3 changed files with 18 additions and 4 deletions
|
@ -30,10 +30,16 @@ import io.flutter.embedding.engine.FlutterEngine
|
|||
import io.flutter.plugin.common.EventChannel
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
open class MainActivity : FlutterFragmentActivity() {
|
||||
private val defaultScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
private lateinit var mediaStoreChangeStreamHandler: MediaStoreChangeStreamHandler
|
||||
private lateinit var settingsChangeStreamHandler: SettingsChangeStreamHandler
|
||||
private lateinit var intentStreamHandler: IntentStreamHandler
|
||||
|
@ -149,7 +155,7 @@ open class MainActivity : FlutterFragmentActivity() {
|
|||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
setupShortcuts()
|
||||
defaultScope.launch { setupShortcuts() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,7 +438,9 @@ open class MainActivity : FlutterFragmentActivity() {
|
|||
)
|
||||
.build()
|
||||
|
||||
ShortcutManagerCompat.setDynamicShortcuts(this, listOf(videos, search, safeMode))
|
||||
val shortcutInfoList = listOf(videos, search, safeMode)
|
||||
ShortcutManagerCompat.setDynamicShortcuts(this, shortcutInfoList)
|
||||
Log.i(LOG_TAG, "set shortcuts: ${shortcutInfoList.joinToString(", ") { v -> v.id }}")
|
||||
}
|
||||
|
||||
private fun onAnalysisCompleted() {
|
||||
|
|
|
@ -14,13 +14,19 @@ import deckers.thibault.aves.model.FieldMap
|
|||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
|
||||
class DeviceHandler(private val context: Context) : MethodCallHandler {
|
||||
private val defaultScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||
when (call.method) {
|
||||
"canManageMedia" -> safe(call, result, ::canManageMedia)
|
||||
"getCapabilities" -> safe(call, result, ::getCapabilities)
|
||||
"getCapabilities" -> defaultScope.launch { safe(call, result, ::getCapabilities) }
|
||||
"getDefaultTimeZoneRawOffsetMillis" -> safe(call, result, ::getDefaultTimeZoneRawOffsetMillis)
|
||||
"getLocales" -> safe(call, result, ::getLocales)
|
||||
"getPerformanceClass" -> safe(call, result, ::getPerformanceClass)
|
||||
|
|
|
@ -57,7 +57,7 @@ internal class ContentImageProvider : ImageProvider() {
|
|||
cursor.close()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
callback.onFailure(e)
|
||||
callback.onFailure(Exception("Failed to query content, error=${e.message}"))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue