fetch apps on a background thread
This commit is contained in:
parent
a195bff520
commit
4c079b2832
|
@ -13,6 +13,7 @@ import android.view.Surface
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.launcher.BuildConfig
|
import com.simplemobiletools.launcher.BuildConfig
|
||||||
|
@ -61,6 +62,7 @@ class MainActivity : SimpleActivity() {
|
||||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
|
|
||||||
|
ensureBackgroundThread {
|
||||||
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
||||||
for (info in list) {
|
for (info in list) {
|
||||||
val componentInfo = info.activityInfo.applicationInfo
|
val componentInfo = info.activityInfo.applicationInfo
|
||||||
|
@ -96,8 +98,10 @@ class MainActivity : SimpleActivity() {
|
||||||
layoutManager.spanCount = getColumnCount()
|
layoutManager.spanCount = getColumnCount()
|
||||||
setupAdapter(launchers)
|
setupAdapter(launchers)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
||||||
|
runOnUiThread {
|
||||||
LaunchersAdapter(this, launchers, launchers_fastscroller) {
|
LaunchersAdapter(this, launchers, launchers_fastscroller) {
|
||||||
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
||||||
try {
|
try {
|
||||||
|
@ -109,6 +113,7 @@ class MainActivity : SimpleActivity() {
|
||||||
launchers_grid.adapter = this
|
launchers_grid.adapter = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupNavigationBar() {
|
private fun setupNavigationBar() {
|
||||||
var bottomListPadding = 0
|
var bottomListPadding = 0
|
||||||
|
|
Loading…
Reference in New Issue