mirror of
https://github.com/KitsunePie/AppErrorsTracking.git
synced 2025-09-04 02:05:16 +08:00
Fix destroyed Activity reading list data maybe out of bounds or called adapter's data confusion error in ConfigureActivity
This commit is contained in:
@@ -161,13 +161,18 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
binding.listNoDataView.isVisible = false
|
binding.listNoDataView.isVisible = false
|
||||||
binding.titleCountText.text = LocaleString.loading
|
binding.titleCountText.text = LocaleString.loading
|
||||||
FrameworkTool.fetchAppListData(context = this, appFilters) {
|
FrameworkTool.fetchAppListData(context = this, appFilters) {
|
||||||
listData.clear()
|
/** 设置一个临时变量用于更新列表数据 */
|
||||||
|
val tempsData = ArrayList<AppInfoBean>()
|
||||||
newThread {
|
newThread {
|
||||||
it.takeIf { e -> e.isNotEmpty() }?.forEach { e ->
|
runCatching {
|
||||||
listData.add(e)
|
it.takeIf { e -> e.isNotEmpty() }?.forEach { e ->
|
||||||
e.icon = appIconOf(e.packageName)
|
tempsData.add(e)
|
||||||
|
e.icon = appIconOf(e.packageName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runOnUiThread {
|
if (isDestroyed.not()) runOnUiThread {
|
||||||
|
listData.clear()
|
||||||
|
listData.addAll(tempsData)
|
||||||
onChanged?.invoke()
|
onChanged?.invoke()
|
||||||
binding.listView.post { binding.listView.setSelection(0) }
|
binding.listView.post { binding.listView.setSelection(0) }
|
||||||
binding.listProgressView.isVisible = false
|
binding.listProgressView.isVisible = false
|
||||||
@@ -176,7 +181,7 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
binding.listView.isVisible = listData.isNotEmpty()
|
binding.listView.isVisible = listData.isNotEmpty()
|
||||||
binding.listNoDataView.isVisible = listData.isEmpty()
|
binding.listNoDataView.isVisible = listData.isEmpty()
|
||||||
binding.titleCountText.text = LocaleString.resultCount(listData.size)
|
binding.titleCountText.text = LocaleString.resultCount(listData.size)
|
||||||
}
|
} else tempsData.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user