mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-05-31 19:09:21 +02:00
remove the deleted launchers from the list
This commit is contained in:
parent
b6d0f5c317
commit
1d78da67a3
@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.activity_main.*
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareBy
|
||||
|
||||
class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
||||
class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, RecyclerAdapter.EditLaunchersInterface {
|
||||
lateinit var dbHelper: DbHelper
|
||||
lateinit var launchers: ArrayList<AppLauncher>
|
||||
lateinit var remainingLaunchers: ArrayList<AppLauncher>
|
||||
@ -91,6 +91,14 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
||||
setupLaunchers()
|
||||
}
|
||||
|
||||
override fun launchersDeleted(indexes: List<Int>) {
|
||||
val reversed = indexes.reversed()
|
||||
for (index in reversed) {
|
||||
launchers.removeAt(index)
|
||||
launchers_holder.adapter.notifyItemRemoved(index)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
preferences.isFirstRun = false
|
||||
|
@ -35,6 +35,8 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
deleteIds.add(launchers[i].id.toString())
|
||||
}
|
||||
DbHelper(act).deleteLaunchers(deleteIds)
|
||||
actMode?.finish()
|
||||
(act as EditLaunchersInterface).launchersDeleted(positions)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -113,4 +115,8 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface EditLaunchersInterface {
|
||||
fun launchersDeleted(indexes: List<Int>)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user