* It's possible to vary this with list device size, but often unnecessary, unless a user * scrolling on a large device is expected to scroll through items more quickly than a small * device, such as when the large device uses a grid layout of items. */ private const val PAGE_SIZE = 30 /** * If placeholders are enabled, PagedList will report the full size but some items might * be null in onBind method (PagedListAdapter triggers a rebind when data is loaded). *
* If placeholders are disabled, onBind will never receive null but as more pages are * loaded, the scrollbars will jitter as new pages are loaded. You should probably disable * scrollbars if you disable placeholders. */ private const val ENABLE_PLACEHOLDERS = true } val allCheeses = dao.allCheesesByName().create(0, PagedList.Config.Builder() .setPageSize(PAGE_SIZE) .setEnablePlaceholders(ENABLE_PLACEHOLDERS) .build())!! fun insert(text: CharSequence) = ioThread { dao.insert(Cheese(id = 0, name = text.toString())) } fun remove(cheese: Cheese) = ioThread { dao.delete(cheese) } }