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