mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-01 01:46:44 +01:00
automatically remove launchers of uninstalled apps
This commit is contained in:
parent
1d78da67a3
commit
cbb077de35
@ -54,6 +54,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
||||
|
||||
private fun setupLaunchers() {
|
||||
launchers = dbHelper.getLaunchers()
|
||||
checkInvalidApps()
|
||||
launchers_holder.adapter = RecyclerAdapter(this, launchers) {
|
||||
val launchIntent = packageManager.getLaunchIntentForPackage(it.pkgName)
|
||||
if (launchIntent != null) {
|
||||
@ -84,6 +85,18 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
||||
return filtered as ArrayList<AppLauncher>
|
||||
}
|
||||
|
||||
private fun checkInvalidApps() {
|
||||
val invalidIds = ArrayList<String>()
|
||||
for ((id, name, pkgName) in launchers) {
|
||||
val launchIntent = packageManager.getLaunchIntentForPackage(pkgName)
|
||||
if (launchIntent == null && !pkgName.startsWith("com.simplemobiletools")) {
|
||||
invalidIds.add(id.toString())
|
||||
}
|
||||
}
|
||||
dbHelper.deleteLaunchers(invalidIds)
|
||||
launchers = launchers.filter { !invalidIds.contains(it.id.toString()) } as ArrayList<AppLauncher>
|
||||
}
|
||||
|
||||
override fun selectedLaunchers(launchers: ArrayList<AppLauncher>) {
|
||||
for ((id, name, pkgName) in launchers) {
|
||||
dbHelper.addLauncher(name, pkgName)
|
||||
|
Loading…
x
Reference in New Issue
Block a user