Install icon packs in 100 icon chunks to avoid OOM
This commit is contained in:
parent
0322fae58a
commit
6c60819f09
@ -484,6 +484,9 @@ class UpdateIconPacksWorker(val context: Context) {
|
|||||||
val icons = mutableListOf<IconPackIcon>()
|
val icons = mutableListOf<IconPackIcon>()
|
||||||
val iconDao = AppDatabase.getInstance(context).iconDao()
|
val iconDao = AppDatabase.getInstance(context).iconDao()
|
||||||
|
|
||||||
|
iconDao.deleteIconPack(iconPack.toDatabaseEntity())
|
||||||
|
iconDao.deleteIcons(iconPack.packageName)
|
||||||
|
|
||||||
loop@ while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
loop@ while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
||||||
if (parser.eventType != XmlPullParser.START_TAG) continue
|
if (parser.eventType != XmlPullParser.START_TAG) continue
|
||||||
when (parser.name) {
|
when (parser.name) {
|
||||||
@ -577,11 +580,16 @@ class UpdateIconPacksWorker(val context: Context) {
|
|||||||
iconPack.scale = scale
|
iconPack.scale = scale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (icons.size >= 100) {
|
||||||
|
iconDao.insertAll(icons.map { it.toDatabaseEntity() })
|
||||||
|
icons.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iconDao.installIconPack(
|
if (icons.isNotEmpty()) {
|
||||||
iconPack.toDatabaseEntity(),
|
iconDao.insertAll(icons.map { it.toDatabaseEntity() })
|
||||||
icons.map { it.toDatabaseEntity() })
|
}
|
||||||
|
iconDao.installIconPack(iconPack.toDatabaseEntity())
|
||||||
|
|
||||||
(parser as? XmlResourceParser)?.close()
|
(parser as? XmlResourceParser)?.close()
|
||||||
inStream?.close()
|
inStream?.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user