Copy grid items before iterating to prevent concurrent modification
This commit is contained in:
parent
d9e333ddb0
commit
e2367dd5a9
|
@ -52,6 +52,7 @@ import com.simplemobiletools.launcher.interfaces.ItemMenuListener
|
|||
import com.simplemobiletools.launcher.models.AppLauncher
|
||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlin.math.abs
|
||||
|
||||
class MainActivity : SimpleActivity(), FlingListener {
|
||||
|
@ -407,7 +408,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val gridItems = homeScreenGridItemsDB.getAllItems() as ArrayList<HomeScreenGridItem>
|
||||
val maxPage = gridItems.maxOf { it.page }
|
||||
val occupiedCells = ArrayList<Triple<Int, Int, Int>>()
|
||||
gridItems.filter { it.parentId == null }.forEach { item ->
|
||||
gridItems.toImmutableList().filter { it.parentId == null }.forEach { item ->
|
||||
for (xCell in item.left..item.right) {
|
||||
for (yCell in item.top..item.bottom) {
|
||||
occupiedCells.add(Triple(item.page, xCell, yCell))
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
|||
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
||||
import com.simplemobiletools.launcher.helpers.*
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlin.math.*
|
||||
|
||||
class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
||||
|
@ -179,7 +180,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
ensureBackgroundThread {
|
||||
val providers = appWidgetManager.installedProviders
|
||||
gridItems = context.homeScreenGridItemsDB.getAllItems() as ArrayList<HomeScreenGridItem>
|
||||
gridItems.forEach { item ->
|
||||
gridItems.toImmutableList().forEach { item ->
|
||||
if (item.type == ITEM_TYPE_ICON) {
|
||||
item.drawable = context.getDrawableForPackageName(item.packageName)
|
||||
} else if (item.type == ITEM_TYPE_FOLDER) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.simplemobiletools.launcher.extensions.config
|
|||
import com.simplemobiletools.launcher.extensions.getCellCount
|
||||
import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
||||
|
@ -80,7 +81,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||
redrawFrame()
|
||||
|
||||
occupiedCells.clear()
|
||||
allGridItems.forEach { item ->
|
||||
allGridItems.toImmutableList().forEach { item ->
|
||||
for (xCell in item.left..item.right) {
|
||||
for (yCell in item.top..item.bottom) {
|
||||
occupiedCells.add(Pair(xCell, yCell))
|
||||
|
|
Loading…
Reference in New Issue