【问题标题】:Android Paging3 insertSeparators doesn't work as intendedAndroid Paging3 insertSeparators 无法按预期工作
【发布时间】: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


    【解决方案1】:

    显然这是 paging3 库 3.0.0alpha10 版本的一个已知错误。

    https://issuetracker.google.com/issues/172254056

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多