mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-06-05 21:49:21 +02:00
refresh the screen after adding launchers
This commit is contained in:
@ -26,17 +26,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
dbHelper = DbHelper(applicationContext)
|
dbHelper = DbHelper(applicationContext)
|
||||||
launchers = dbHelper.getLaunchers()
|
setupLaunchers()
|
||||||
launchers_holder.adapter = RecyclerAdapter(applicationContext, false, launchers) {
|
|
||||||
val launchIntent = packageManager.getLaunchIntentForPackage(it.pkgName)
|
|
||||||
if (launchIntent != null) {
|
|
||||||
startActivity(launchIntent)
|
|
||||||
} else {
|
|
||||||
startActivity(viewIntent("https://play.google.com/store/apps/details?id=" + it.pkgName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
remainingLaunchers = getNotDisplayedLaunchers()
|
|
||||||
|
|
||||||
fab.setOnClickListener {
|
fab.setOnClickListener {
|
||||||
AddAppDialog.newInstance(this, remainingLaunchers).show(fragmentManager, "")
|
AddAppDialog.newInstance(this, remainingLaunchers).show(fragmentManager, "")
|
||||||
@ -62,6 +52,20 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
|||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupLaunchers() {
|
||||||
|
launchers = dbHelper.getLaunchers()
|
||||||
|
launchers_holder.adapter = RecyclerAdapter(applicationContext, false, launchers) {
|
||||||
|
val launchIntent = packageManager.getLaunchIntentForPackage(it.pkgName)
|
||||||
|
if (launchIntent != null) {
|
||||||
|
startActivity(launchIntent)
|
||||||
|
} else {
|
||||||
|
startActivity(viewIntent("https://play.google.com/store/apps/details?id=" + it.pkgName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
remainingLaunchers = getNotDisplayedLaunchers()
|
||||||
|
}
|
||||||
|
|
||||||
private fun getNotDisplayedLaunchers(): ArrayList<AppLauncher> {
|
private fun getNotDisplayedLaunchers(): ArrayList<AppLauncher> {
|
||||||
val apps = ArrayList<AppLauncher>()
|
val apps = ArrayList<AppLauncher>()
|
||||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||||
@ -84,6 +88,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
|||||||
for ((name, pkgName) in launchers) {
|
for ((name, pkgName) in launchers) {
|
||||||
dbHelper.addLauncher(name, pkgName)
|
dbHelper.addLauncher(name, pkgName)
|
||||||
}
|
}
|
||||||
|
setupLaunchers()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
Reference in New Issue
Block a user