我正在尝试使用new Paging Library和Roomas数据库,但遇到了一个问题,PagedList数据库返回的列表与发送到UI的列表不应该相同,map在显示给用户之前以及执行此map操作期间,我需要一些实体我更改列表大小(添加项目),显然Paging Library不支持这种操作,因为当我尝试运行应用程序时,出现以下异常:
Caused by: java.lang.IllegalStateException: Invalid Function 'function_name' changed return size. This is not supported.
Run Code Online (Sandbox Code Playgroud)
查看分页库源代码,您会看到以下方法:
static <A, B> List<B> convert(Function<List<A>, List<B>> function, List<A> source) {
List<B> dest = function.apply(source);
if (dest.size() != source.size()) {
throw new IllegalStateException("Invalid Function " + function
+ " changed return size. This is not supported.");
}
return dest;
}
Run Code Online (Sandbox Code Playgroud)
PagedList在使用动态项目添加动态项目之前,是否有解决方法或要解决的问题?
这就是我在做的
道
@Query("SELECT * FROM table_name")
fun getItems(): DataSource.Factory<Int, Item> …Run Code Online (Sandbox Code Playgroud) android android-room android-architecture-components android-paging