Loading iconloaderlib/src/com/android/launcher3/icons/cache/CachedObject.java +3 −7 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3.icons.cache; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.os.UserHandle; Loading @@ -29,10 +28,8 @@ import com.android.launcher3.icons.IconProvider; /** * A simple interface to represent an object which can be added to icon cache * * @param <T> Any subclass of the icon cache with which this object is associated */ public interface CachedObject<T extends BaseIconCache> { public interface CachedObject { /** * Returns the component name for the underlying object Loading @@ -47,13 +44,13 @@ public interface CachedObject<T extends BaseIconCache> { /** * Loads the user visible label for the provided object */ @Nullable CharSequence getLabel(PackageManager pm); @Nullable CharSequence getLabel(); /** * Loads the user visible icon for the provided object */ @Nullable default Drawable getFullResIcon(@NonNull T cache) { default Drawable getFullResIcon(@NonNull BaseIconCache cache) { return null; } Loading @@ -63,7 +60,6 @@ public interface CachedObject<T extends BaseIconCache> { @Nullable ApplicationInfo getApplicationInfo(); /** * Returns a persistable string that can be used to indicate indicate the correctness of the * cache for the provided item Loading iconloaderlib/src/com/android/launcher3/icons/cache/CachedObjectCachingLogic.kt +8 −15 Original line number Diff line number Diff line Loading @@ -24,30 +24,23 @@ import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.IconProvider /** Caching logic for ComponentWithLabelAndIcon */ class CachedObjectCachingLogic<T : BaseIconCache>(context: Context) : CachingLogic<CachedObject<T>> { object CachedObjectCachingLogic : CachingLogic<CachedObject> { private val pm = context.packageManager override fun getComponent(info: CachedObject): ComponentName = info.component override fun getComponent(info: CachedObject<T>): ComponentName = info.component override fun getUser(info: CachedObject): UserHandle = info.user override fun getUser(info: CachedObject<T>): UserHandle = info.user override fun getLabel(info: CachedObject): CharSequence? = info.label override fun getLabel(info: CachedObject<T>): CharSequence? = info.getLabel(pm) override fun loadIcon( context: Context, cache: BaseIconCache, info: CachedObject<T>, ): BitmapInfo { val d = info.getFullResIcon(cache as T) ?: return BitmapInfo.LOW_RES_INFO override fun loadIcon(context: Context, cache: BaseIconCache, info: CachedObject): BitmapInfo { val d = info.getFullResIcon(cache) ?: return BitmapInfo.LOW_RES_INFO cache.iconFactory.use { li -> return li.createBadgedIconBitmap(d, IconOptions().setUser(info.user)) } } override fun getApplicationInfo(info: CachedObject<T>) = info.applicationInfo override fun getApplicationInfo(info: CachedObject) = info.applicationInfo override fun getFreshnessIdentifier(item: CachedObject<T>, provider: IconProvider): String? = override fun getFreshnessIdentifier(item: CachedObject, provider: IconProvider): String? = item.getFreshnessIdentifier(provider) } Loading
iconloaderlib/src/com/android/launcher3/icons/cache/CachedObject.java +3 −7 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3.icons.cache; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.os.UserHandle; Loading @@ -29,10 +28,8 @@ import com.android.launcher3.icons.IconProvider; /** * A simple interface to represent an object which can be added to icon cache * * @param <T> Any subclass of the icon cache with which this object is associated */ public interface CachedObject<T extends BaseIconCache> { public interface CachedObject { /** * Returns the component name for the underlying object Loading @@ -47,13 +44,13 @@ public interface CachedObject<T extends BaseIconCache> { /** * Loads the user visible label for the provided object */ @Nullable CharSequence getLabel(PackageManager pm); @Nullable CharSequence getLabel(); /** * Loads the user visible icon for the provided object */ @Nullable default Drawable getFullResIcon(@NonNull T cache) { default Drawable getFullResIcon(@NonNull BaseIconCache cache) { return null; } Loading @@ -63,7 +60,6 @@ public interface CachedObject<T extends BaseIconCache> { @Nullable ApplicationInfo getApplicationInfo(); /** * Returns a persistable string that can be used to indicate indicate the correctness of the * cache for the provided item Loading
iconloaderlib/src/com/android/launcher3/icons/cache/CachedObjectCachingLogic.kt +8 −15 Original line number Diff line number Diff line Loading @@ -24,30 +24,23 @@ import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.IconProvider /** Caching logic for ComponentWithLabelAndIcon */ class CachedObjectCachingLogic<T : BaseIconCache>(context: Context) : CachingLogic<CachedObject<T>> { object CachedObjectCachingLogic : CachingLogic<CachedObject> { private val pm = context.packageManager override fun getComponent(info: CachedObject): ComponentName = info.component override fun getComponent(info: CachedObject<T>): ComponentName = info.component override fun getUser(info: CachedObject): UserHandle = info.user override fun getUser(info: CachedObject<T>): UserHandle = info.user override fun getLabel(info: CachedObject): CharSequence? = info.label override fun getLabel(info: CachedObject<T>): CharSequence? = info.getLabel(pm) override fun loadIcon( context: Context, cache: BaseIconCache, info: CachedObject<T>, ): BitmapInfo { val d = info.getFullResIcon(cache as T) ?: return BitmapInfo.LOW_RES_INFO override fun loadIcon(context: Context, cache: BaseIconCache, info: CachedObject): BitmapInfo { val d = info.getFullResIcon(cache) ?: return BitmapInfo.LOW_RES_INFO cache.iconFactory.use { li -> return li.createBadgedIconBitmap(d, IconOptions().setUser(info.user)) } } override fun getApplicationInfo(info: CachedObject<T>) = info.applicationInfo override fun getApplicationInfo(info: CachedObject) = info.applicationInfo override fun getFreshnessIdentifier(item: CachedObject<T>, provider: IconProvider): String? = override fun getFreshnessIdentifier(item: CachedObject, provider: IconProvider): String? = item.getFreshnessIdentifier(provider) }