Compare commits
2
Commits
133f309d4b
...
c23c215941
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c23c215941 | ||
|
|
3d67dd2c2d |
@@ -231,11 +231,15 @@ class HomeActivity : BaseActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
list.clear()
|
list.clear()
|
||||||
val subList01 = tempList.subList(0, tempList.size / 2)
|
val leftSize = (tempList.size + 1) / 2 // 左列长度(向上取整)
|
||||||
val subList02 = tempList.subList(tempList.size / 2, tempList.size)
|
val rightSize = tempList.size / 2 // 右列长度(向下取整)
|
||||||
repeat(tempList.size / 2) { index ->
|
repeat(rightSize) { index ->
|
||||||
list.add(subList01[index].also { it.deviceId = App.deviceId })
|
list.add(tempList[index].also { it.deviceId = App.deviceId })
|
||||||
list.add(subList02[index].also { it.deviceId = App.deviceId })
|
list.add(tempList[leftSize + index].also { it.deviceId = App.deviceId })
|
||||||
|
}
|
||||||
|
// 处理奇数长度:左列比右列多一个
|
||||||
|
if (tempList.size % 2 != 0) {
|
||||||
|
list.add(tempList[rightSize].also { it.deviceId = App.deviceId })
|
||||||
}
|
}
|
||||||
shelfAdapter.notifyDataSetChanged()
|
shelfAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
@@ -269,6 +273,9 @@ class HomeActivity : BaseActivity() {
|
|||||||
*/
|
*/
|
||||||
private val noDataWatchdogTask = object : Runnable {
|
private val noDataWatchdogTask = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
// 生命周期检查,防止 Activity 销毁后继续执行
|
||||||
|
if (isFinishing || isDestroyed) return
|
||||||
|
|
||||||
val elapsed = System.currentTimeMillis() - lastDataReceivedTime
|
val elapsed = System.currentTimeMillis() - lastDataReceivedTime
|
||||||
if (elapsed >= 5 * 60 * 1000L) {
|
if (elapsed >= 5 * 60 * 1000L) {
|
||||||
if (noDataWarningDialog == null) {
|
if (noDataWarningDialog == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user