1cb45e73a41f91534febb7e5d799e1f703fb3763 |
|
15-Jul-2017 |
Chris Craik <ccraik@google.com> |
Paging refactor to unify list/data source types, and simplify mutability Bug: 64809611 Test: new tests passing - Unified list type for contiguous data sources - null padding is created at initialization, and consumed as items are loaded. Infinite unpadded, and counted padded lists use same list type entirely. - New list and DataSource type for tiled data sources, which can access data at any location. - Split data source based on keyed vs tiled based implementations. This massively simplified the few existing data sources, and allowed us to specialize further, making the trivial test (and limit-offset) code much simpler (and avoiding code that was extremely prone to off by one errors) - Added PagedListAdapter, which provides convenience wrapper for the AdapterHelper, saving users a few extra lines of code. - Uncountable positioning - rework also has relative data source position stored at initialization so that countable items can use position, without being required to count their dataset. This supports cases with simple position IDs, but where you: 1) don't want nulls in the data, 2) don't care about count/scrollbars, 3) can't easily compute the total number. - PagedList requires data to initialize - Removes need for weird warmup API, avoids showing a list of nulls to user in countable case, and unifies initialization codepaths. - PagedList has a snapshot() method that enables DiffUtil to run safely on a background thread on immutable data, and snapshot-aware diffing that allows a new list to load content while it's being used in diffing on a background thread. Not done: - Parameterized initialization (both init from key, storing key, passing key when creating LiveData<PagedList>) Change-Id: I7cb945afe37e68aad44cde45277afd7a27416e52
/frameworks/support/room/runtime/src/main/java/android/arch/persistence/room/Room.java
|