remove home screen icons after uninstalling an app
This commit is contained in:
parent
9c1458d89b
commit
4bcda4ba95
|
@ -160,12 +160,19 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
|
||||
(widgets_fragment as WidgetsFragment).getAppWidgets()
|
||||
|
||||
var hasDeletedAnything = false
|
||||
mCachedLaunchers.map { it.packageName }.forEach { packageName ->
|
||||
if (!launchers.map { it.packageName }.contains(packageName)) {
|
||||
hasDeletedAnything = true
|
||||
launchersDB.deleteApp(packageName)
|
||||
homeScreenGridItemsDB.deleteItem(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDeletedAnything) {
|
||||
home_screen_grid.fetchAppIcons()
|
||||
}
|
||||
|
||||
mCachedLaunchers = launchers
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,7 @@ interface HomeScreenGridItemsDao {
|
|||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertAll(items: List<HomeScreenGridItem>)
|
||||
|
||||
@Query("DELETE FROM home_screen_grid_items WHERE package_name = :packageName")
|
||||
fun deleteItem(packageName: String)
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
|
||||
fun fetchAppIcons() {
|
||||
ensureBackgroundThread {
|
||||
appIconDrawables.clear()
|
||||
appIcons = context.homeScreenGridItemsDB.getAllItems() as ArrayList<HomeScreenGridItem>
|
||||
appIcons.forEach { item ->
|
||||
val drawable = context.getDrawableForPackageName(item.packageName)
|
||||
|
|
Loading…
Reference in New Issue