remove non existing apps from cache

This commit is contained in:
tibbi 2022-09-18 11:57:32 +02:00
parent 9a46ceec58
commit 69ee50167b
2 changed files with 9 additions and 0 deletions

View File

@ -98,6 +98,12 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
val launchers = allApps.distinctBy { it.packageName } as ArrayList<AppLauncher> val launchers = allApps.distinctBy { it.packageName } as ArrayList<AppLauncher>
context.launchersDB.insertAll(launchers) context.launchersDB.insertAll(launchers)
gotLaunchers(launchers) gotLaunchers(launchers)
cachedLaunchers.map { it.packageName }.forEach { packageName ->
if (!launchers.map { it.packageName }.contains(packageName)) {
context.launchersDB.deleteApp(packageName)
}
}
} }
} }

View File

@ -13,4 +13,7 @@ interface AppLaunchersDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(appLaunchers: List<AppLauncher>) fun insertAll(appLaunchers: List<AppLauncher>)
@Query("DELETE FROM apps WHERE package_name = :packageName")
fun deleteApp(packageName: String)
} }