Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
Description
Usage of the API can only work reliably if this function is called at app start.
registerActivityLifecycleCallbacks
Otherwise, some Activities might have been created, and there's no way for the app to know about it through public APIs and the callbacks that only dispatch changes but not current state at the time of registering.
I have a use case that involves knowing whether any of the Activities in the process is focused. This requires to get a reference to all resumed activities (there might be mutliple with multi-window on API 29+), and then check if one of them has its window focused (and listen to changes).
So, I'd like to receive on initialization whether the component that calls
registerActivityLifecycleCallbacks
was initialized on process creation, and throw if not, since it cannot work reliably if created after activities start being created.This would be a
Boolean
parameter in thecreate
function, namedprocessJustCreated
or alike.An alternative is to allow specifying that an initializer requires to start at app startup (but I'm worried this apporach might make it easier for some SDK vendors to abuse this when not really needed for the host apps).
A latter alternative is to have an AndroidX API (for API 18+) that exposes a reference to all the currently created Activities, along with their lifecycle, so I can get a property of type
Flow<Set<Pair<Activity, Lifecycle.State>>>
for my use case.