Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Hi. Thanks for reporting this. Fixed in alpha-04
jo...@gmail.com <jo...@gmail.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit e782987543a9f8ccd485e970ddc74564b24378db
Author: Vighnesh Raut <vighnesh.raut13@gmail.com>
Date: Mon Jan 02 15:27:40 2023
fix: tab row crashes when only 1 tab is added
Bug: b/264018028
Test: Added unit test
Change-Id: I6381dbac304fc1d69d3708c6655f8b595668e93f
M tv/tv-material/src/androidTest/java/androidx/tv/material/TabRowTest.kt
M tv/tv-material/src/main/java/androidx/tv/material/TabRow.kt
https://android-review.googlesource.com/2373449
Branch: androidx-main
commit e782987543a9f8ccd485e970ddc74564b24378db
Author: Vighnesh Raut <vighnesh.raut13@gmail.com>
Date: Mon Jan 02 15:27:40 2023
fix: tab row crashes when only 1 tab is added
Bug:
Test: Added unit test
Change-Id: I6381dbac304fc1d69d3708c6655f8b595668e93f
M tv/tv-material/src/androidTest/java/androidx/tv/material/TabRowTest.kt
M tv/tv-material/src/main/java/androidx/tv/material/TabRow.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!