Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Hi. Thanks for reporting this. Fixed in alpha-04
ca...@gmail.com <ca...@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
ca...@gmail.com <ca...@gmail.com> #4
deleted
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.tv:tv-material:1.0.0-alpha04
il...@google.com <il...@google.com> #6
We've decided to rename createFragmentNavigator() to onCreateNavController(NavController) to make it more clear that this is something you can override to get a callback for when the NavController is created.
This will be available in Navigation 2.1.0-alpha03
This will be available in Navigation 2.1.0-alpha03
Description
Version used: 1.0.0-alpha09
Devices/Android versions reproduced on: N/A
I have started to make use of the Navigation Component and am very please with it. Well done!
Once recommendation I would like to make, however, is to add some better support for configuring custom Destinations when used with the NavHostFragment. The problem that I am having is that in order to configure a custom Destination Navigator, I need to get reference to the NavigatorProvider from the NavController. If I am using a NavHostFragment, then I must first load the Fragment to have its onCreate method called. I then must call navController.navigatorProvider.addNavigator(...) BEFORE I subsequently call navController.setGraph(...). This means that I cannot specify the graph directly in my XML. In fact, if I make use of the app:navGraph attribute I get a crash because my custom Destination nodes have no configured Navigators.
I've looked into extending NavHostFragment with an implementation that automatically calls navigatorProvider.addNavigator(...). But since the NavController is instantiated in NavHostFragment.onCreate() and the XML-configured graph resource ID is handled in the same method, there is no integration point between these 2 operations that allows for additional Navigators to be configured before the graph xml is inflated. As a result the only way that I've found to do the configuration is do the following:
1. Do NOT specify the NavHostFragment via a fragment tag in the XML. Instead add a FrameLayout container.
2. Manually instantiate an instance of NavHostFragment, and load it via a FragmentTransaction.
3. Manually configure the custom Destination Navigator via navHostFragment.navController.navigatorProvider.addNavigator(...)
4. Manually call navHostFragment.navController.setGraph(...)
It's not a huge problem, but it did take a good bit of experimenting before I figured this out. (I.e. the docs for custom destinations could be better.)
Perhaps a later version of NavHostFragment could have an additional overridable method that could be overridden to specify a list of additional Navigators. ?