Fixed
Status Update
Comments
il...@google.com <il...@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
Version used: 1.0.0-alpha1, using SDK 27/28
Devices/Android versions reproduced on: Emulators from API 21 to 26
When a Fragment is set as a "pop" destination for a action, it is "resumed" even though it is not shown on the screen.
I attached a sample projet to show the problem.
Here is the setup:
Very simple MainActivity, with one NavHostFragment and 3 Fragments: FragmentOne, FragmentTwo, FragmentThree.
The nav graph is simple:
* FragmentOne can go to FragmentTwo
* FragmentTwo can go to FragmentThree
* The "pop" destination of the action is FragmentOne
FragmentOne contains a Log.v() in its onResume() method.
How to reproduce:
* Start the app
* In Logcat, see "onResume", as the FragmentOne is shown
* Navigate to FragmentTwo
* Navigate to FragmentThree
* In Logcat, see "onResume", as the FragmentOne is resumed for some reason => BUG ?
* Press back
* In Logcat, see "onResume", as the FragmentOne is shown
As you see, the FragmentOne is shown only twice on screen, but Logcat shows "onResume" three times.
Now as a counter example:
* Open the Nav Graph and remove the "pop" destination (line 24, app:popUpTo="@+id/fragmentOne")
* Start the app
* In Logcat, see "onResume", as the FragmentOne is shown
* Navigate to FragmentTwo
* Navigate to FragmentThree
* In Logcat, you don't see anything
* Press back
* FragmentTwo is shown, nothing in Logcat
* Press back
* In Logcat, see "onResume", as the FragmentOne is shown
=> FragmentOne is shown twice, Logcat shows "onResume" twice.
To me it's clearly a bug as the whole lifecycle of FragmentOne is triggered even though the Fragment is never shown on screen.
It cause me a problem: I wanted to refresh my view (doing an HTTP fetch) when the Fragment is resumed. Because of this bug, the fragment fetches from the network even though it is never shown.
I tried to play with isVisible()
(
Any thoughts about this? Thanks!