mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-07 23:38:54 +01:00
uncheck launchers at pressing Back
This commit is contained in:
parent
0f71fd3f3b
commit
86d1d3211c
@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.activity_main.*
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareBy
|
||||
|
||||
class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, RecyclerAdapter.EditLaunchersInterface {
|
||||
class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, RecyclerAdapter.RecyclerInterface {
|
||||
lateinit var dbHelper: DbHelper
|
||||
lateinit var launchers: ArrayList<AppLauncher>
|
||||
lateinit var remainingLaunchers: ArrayList<AppLauncher>
|
||||
@ -101,7 +101,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
||||
for ((id, name, pkgName) in launchers) {
|
||||
dbHelper.addLauncher(name, pkgName)
|
||||
}
|
||||
refreshLaunchers()
|
||||
refreshLauncherIcons()
|
||||
}
|
||||
|
||||
override fun launchersDeleted(indexes: List<Int>, deletedLaunchers: List<AppLauncher>) {
|
||||
@ -128,6 +128,10 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
||||
setupLaunchers()
|
||||
}
|
||||
|
||||
override fun refreshLauncherIcons() {
|
||||
setupLaunchers()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
preferences.isFirstRun = false
|
||||
|
@ -56,6 +56,11 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
menuItem?.isVisible = multiSelector.selectedPositions.size == 1
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDestroyActionMode(actionMode: ActionMode?) {
|
||||
super.onDestroyActionMode(actionMode)
|
||||
(act as RecyclerInterface).refreshLauncherIcons()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
@ -90,7 +95,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
val newName = editView.edit_launcher_edittext.text.toString().trim()
|
||||
if (!newName.isEmpty()) {
|
||||
if (DbHelper(act).updateLauncherName(selectedLauncher.id, newName) > 0) {
|
||||
(act as EditLaunchersInterface).launcherRenamed()
|
||||
(act as RecyclerInterface).launcherRenamed()
|
||||
finishActionMode()
|
||||
alertDialog.dismiss()
|
||||
} else {
|
||||
@ -120,7 +125,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
}
|
||||
DbHelper(act).deleteLaunchers(deleteIds)
|
||||
finishActionMode()
|
||||
(act as EditLaunchersInterface).launchersDeleted(positions, deletedLaunchers)
|
||||
(act as RecyclerInterface).launchersDeleted(positions, deletedLaunchers)
|
||||
}
|
||||
|
||||
private fun getRealAppName(launcher: AppLauncher): String {
|
||||
@ -185,9 +190,11 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
}
|
||||
}
|
||||
|
||||
interface EditLaunchersInterface {
|
||||
interface RecyclerInterface {
|
||||
fun launchersDeleted(indexes: List<Int>, deletedLaunchers: List<AppLauncher>)
|
||||
|
||||
fun launcherRenamed()
|
||||
|
||||
fun refreshLauncherIcons()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user