Load all icons off main thread

This commit is contained in:
MM20
2021-12-04 14:06:01 +01:00
parent c388b01fe8
commit be50fb2276
3 changed files with 150 additions and 92 deletions
@@ -81,8 +81,9 @@ class AppShortcut(
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
val icon = launcherApps.getShortcutIconDrawable(launcherShortcut, context.resources.displayMetrics.densityDpi)
icon ?: return null
val icon = withContext(Dispatchers.IO) {
launcherApps.getShortcutIconDrawable(launcherShortcut, context.resources.displayMetrics.densityDpi)
} ?: return null
if (isAtLeastApiLevel(Build.VERSION_CODES.O) && icon is AdaptiveIconDrawable) {
return LauncherIcon(
foreground = icon.foreground,