Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Hmm maybe. I would need that lambda to run before the updates are dispatched to the RV adapter because (conforming to this example) I'm using the title inside the RV items.
My actual example is here:https://github.com/JakeWharton/SdkSearch/blob/35ecf5c5c17edd60da3498eb38eab13786623548/frontend/android/src/main/java/com/jakewharton/sdksearch/ui/ItemAdapter.kt
I have a query term and a list of results. The view holders bold the query term inside the result. Not sure how common it is to use non-list data inside the list items like this. I could make a composite object of query+item and have a list of those, I suppose...
My actual example is here:
I have a query term and a list of results. The view holders bold the query term inside the result. Not sure how common it is to use non-list data inside the list items like this. I could make a composite object of query+item and have a list of those, I suppose...
ap...@google.com <ap...@google.com> #3
I think running the lambda first is very reasonable.
I'm assuming we'll still need to run those lambdas in the rare case a diff is dropped when too many lists are pushed. Would be nice to avoid any extra bind work (e.g. in the setTitle) case, but it would be surprising to have some of those lambdas never run.
I'm assuming we'll still need to run those lambdas in the rare case a diff is dropped when too many lists are pushed. Would be nice to avoid any extra bind work (e.g. in the setTitle) case, but it would be surprising to have some of those lambdas never run.
da...@google.com <da...@google.com> #4
The problem with running the lambda first is that you can't touch the RecyclerView state in many ways, e.g. asking it to scroll to specific content.
May want to differentiate between pre-swap and post swap callbacks.
May want to differentiate between pre-swap and post swap callbacks.
an...@google.com <an...@google.com> #5
When talking about when to run the lambda, I entirely forgot - RecyclerView update notifications (e.g. from DiffUtil.Result or Adapter.notifyItem*) are always deferred.
RecyclerView posts before doing any bind work after dispatching any sort of notifyItem*** signals to coalesce changes. This means it's safe to update data you'll display in the callback, even if it's dispatched after the swap. See triggerUpdateProcessor -https://cs.corp.google.com/android/frameworks/base/core/java/com/android/internal/widget/RecyclerView.java?q=triggerUpdateProcessor&sq=package:%5Eandroid$&g=0&l=4919
I added the requested API, and just have it running after the swap. Also manually verified callback can be used to update adapter state displayed.
Fixed withhttps://android-review.googlesource.com/c/platform/frameworks/support/+/730779 - will go out with next feature release (Paging 2.1)
RecyclerView posts before doing any bind work after dispatching any sort of notifyItem*** signals to coalesce changes. This means it's safe to update data you'll display in the callback, even if it's dispatched after the swap. See triggerUpdateProcessor -
I added the requested API, and just have it running after the swap. Also manually verified callback can be used to update adapter state displayed.
Fixed with
Description
Version used: 2.2.0
Devices/Android versions reproduced on:
- device usb:336662528X product:xcover4ltexx model:SM_G390F device:xcover4lte transport_id:5
- device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:4
- device usb:336662528X product:zerofltexx model:SM_G920F device:zeroflte transport_id:15
In Version 2.1.0 annotation @Relation was only allowed for list types, if you used it on a non-list type the following runtime error occured:
error: Fields annotated with @Relation must be a List or Set.
Since Version 2.2.0 @Relation can be used on non-list types, in order to model relations with a single object reference.
This is handy if you have 1-to-1 relations and you don't have to explicitly get the first item from the result list, instead you get the object directly.
release notes:
One-to-One Relations: The restriction in POJO fields annotated with @Relation to be of type List or Set has been lifted, effectively allowing single-value relations to be represented.
It seems that this new feature is only supported up to a certain amount of table rows. In more details it means that if you run a query on tables with 100 rows, the returned POJOs have all valid non-null references to the object specified by the @Relation annotation. If you run the same query on tables with more than 999 rows (999 still works, 1000 will fail) the result will be that all returned POJOs have NULL as referenced object (see my example project).
If you use the list type with @Relation annotation you don't have this limitation.
Please refer to the attached example project unit test.
In the example project the same entities are used but with two different POJO types. One is using a List<> type annotated with @Relation, and the other is using the newly supported object type.
Android unit test show that the list type always works but the object type works up to 999 rows, after that it starts to fail.