diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index ed2ef1d..a4b5b93 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -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 } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/HomeScreenGridItemsDao.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/HomeScreenGridItemsDao.kt index 6f78fb8..b2c1520 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/HomeScreenGridItemsDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/HomeScreenGridItemsDao.kt @@ -13,4 +13,7 @@ interface HomeScreenGridItemsDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertAll(items: List) + + @Query("DELETE FROM home_screen_grid_items WHERE package_name = :packageName") + fun deleteItem(packageName: String) } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index 13bbf6e..7d91001 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -43,6 +43,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie fun fetchAppIcons() { ensureBackgroundThread { + appIconDrawables.clear() appIcons = context.homeScreenGridItemsDB.getAllItems() as ArrayList appIcons.forEach { item -> val drawable = context.getDrawableForPackageName(item.packageName)