File tree 2 files changed +5
-5
lines changed
PagingSample/app/src/main/java/paging/android/example/com/pagingsample
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package paging.android.example.com.pagingsample
18
18
19
- import android.arch.paging.LivePagedListProvider
19
+ import android.arch.paging.DataSource
20
20
import android.arch.persistence.room.Dao
21
21
import android.arch.persistence.room.Delete
22
22
import android.arch.persistence.room.Insert
@@ -32,7 +32,7 @@ interface CheeseDao {
32
32
* it back to UI via ViewModel.
33
33
*/
34
34
@Query(" SELECT * FROM Cheese ORDER BY name COLLATE NOCASE ASC" )
35
- fun allCheesesByName (): LivePagedListProvider <Int , Cheese >
35
+ fun allCheesesByName (): DataSource . Factory <Int , Cheese >
36
36
37
37
@Insert
38
38
fun insert (cheeses : List <Cheese >)
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package paging.android.example.com.pagingsample
18
18
19
19
import android.app.Application
20
20
import android.arch.lifecycle.AndroidViewModel
21
+ import android.arch.paging.LivePagedListBuilder
21
22
import android.arch.paging.PagedList
22
23
23
24
/* *
@@ -49,11 +50,10 @@ class CheeseViewModel(app: Application) : AndroidViewModel(app) {
49
50
private const val ENABLE_PLACEHOLDERS = true
50
51
}
51
52
52
- val allCheeses = dao.allCheesesByName().create(0 ,
53
- PagedList .Config .Builder ()
53
+ val allCheeses = LivePagedListBuilder (dao.allCheesesByName(), PagedList .Config .Builder ()
54
54
.setPageSize(PAGE_SIZE )
55
55
.setEnablePlaceholders(ENABLE_PLACEHOLDERS )
56
- .build())!!
56
+ .build()).build()
57
57
58
58
fun insert (text : CharSequence ) = ioThread {
59
59
dao.insert(Cheese (id = 0 , name = text.toString()))
You can’t perform that action at this time.
0 commit comments