【发布时间】:2020-12-05 19:28:32
【问题描述】:
我正在尝试在我的列表中添加分隔符,例如 A、“Apple”、“Anaconda”、B“Boys”、“Bostwana”,但是,insertSeparators 似乎没有表明我们何时开始或结束。
adapter.submitData(pagingData.insertSeparators { before, after ->
val afterDate = DateItem().withDate(after?.transactionDate)
val beforeDate = DateItem().withDate(before?.transactionDate)
if (after != null && (before == null || afterDate.toString() != beforeDate?.toString())) {
return@insertSeparators afterDate
}
return@insertSeparators null
})
我的期望是before 在开头为空,而after 在列表末尾为空。但它永远不会为空,因此很难知道我们是在开始还是结束。
【问题讨论】:
标签: android android-architecture-components android-paging