Rename loadIconAsync to loadIcon as it's no longer guaranteed to be called off the main thread
This commit is contained in:
parent
2273a0912a
commit
c388b01fe8
@ -38,7 +38,7 @@ class AppInstallation(
|
||||
foregroundScale = 0.5f)
|
||||
}
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
val icon = session.appIcon ?: return getPlaceholderIcon(context)
|
||||
val foreground = BitmapDrawable(context.resources, icon)
|
||||
foreground.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
||||
|
||||
@ -79,7 +79,7 @@ class AppShortcut(
|
||||
foregroundScale = 0.5f)
|
||||
}
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
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
|
||||
|
||||
@ -68,7 +68,7 @@ class LauncherApp(
|
||||
return launcherActivityInfo.user
|
||||
}
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
try {
|
||||
val icon =
|
||||
withContext(Dispatchers.IO) {
|
||||
|
||||
@ -48,7 +48,7 @@ class Contact(
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
val contentResolver = context.contentResolver
|
||||
val uri = ContactsContract.Contacts.getLookupUri(id, lookupKey) ?: return null
|
||||
val bmp = ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, false)
|
||||
|
||||
@ -51,7 +51,7 @@ open class File(
|
||||
|
||||
open val isStoredInCloud = false
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
if (!JavaIOFile(path).exists()) return null
|
||||
when {
|
||||
mimeType.startsWith("image/") -> {
|
||||
|
||||
@ -36,7 +36,7 @@ class GDriveFile(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class OneDriveFile(
|
||||
|
||||
override val isStoredInCloud = true
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ abstract class Searchable : Comparable<Searchable> {
|
||||
}
|
||||
}
|
||||
|
||||
open suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? = null
|
||||
open suspend fun loadIcon(context: Context, size: Int): LauncherIcon? = null
|
||||
abstract fun getPlaceholderIcon(context: Context): LauncherIcon
|
||||
|
||||
override fun compareTo(other: Searchable): Int {
|
||||
|
||||
@ -48,7 +48,7 @@ fun ShapedLauncherIcon(
|
||||
|
||||
LaunchedEffect(item) {
|
||||
icon = withContext(Dispatchers.IO) {
|
||||
item.loadIconAsync(context, iconSize)
|
||||
item.loadIcon(context, iconSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ class Website(
|
||||
) : Searchable() {
|
||||
|
||||
override val key = "web://$url"
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
if (favicon.isEmpty()) return null
|
||||
try {
|
||||
return withContext(Dispatchers.IO) {
|
||||
|
||||
@ -29,7 +29,7 @@ class Wikipedia(
|
||||
) : Searchable() {
|
||||
override val key = "wikipedia://$id"
|
||||
|
||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
||||
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user