Paging3 (一) 入门
Paging3 (二) 结合 Room
Paging3 (二) 结合RoomPaging 数据源不开放, 无法随意增删改操作; 只能借助 Room;
这就意味着: 从服务器拉下来的数据全缓存. 刷新时数据全清再重新缓存, 查询条件变更时重新缓存 [让我看看]
当Room数据发生变化时, 会使内存中 PagingSource 失效。从而重新加载库表中的数据
Room: 官方文档点这里
Paging3: 官方文档点这里.
本文内容:
本文导包:
//ViewModel, livedata, lifecycle implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0' //协程 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8' //room implementation "androidx.room:room-runtime:2.3.0" kapt "androidx.room:room-compiler:2.3.0" implementation("androidx.room:room-ktx:2.3.0") //Paging implementation "androidx.paging:paging-runtime:3.0.0"