Status Update
Comments
je...@gmail.com <je...@gmail.com> #2
Hi. Thanks for reporting this. Fixed in alpha-04
ap...@google.com <ap...@google.com> #3
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
ap...@google.com <ap...@google.com> #4
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
jb...@google.com <jb...@google.com> #6
This has been fixed internally and will be available in the Navigation 2.4.0-alpha08
release.
This will allow the creation of custom NavTypes, meaning when using the
Given:
@Serializable
@Parcelize
data class SearchParameters(val searchQuery: String, val filters: List<String>)
A custom NavType could be written as:
class SearchParametersType : NavType<SearchParameters>(
isNullableAllowed = false
) {
override fun put(bundle: Bundle, key: String, value: SearchParameters) {
bundle.putParcelable(key, value)
}
override fun get(bundle: Bundle, key: String): SearchParameters {
return bundle.getParcelable(key) as SearchParameters
}
override fun parseValue(value: String): SearchParameters {
return Json.decodeFromString<SearchParameters>(value)
}
// Only required when using Navigation 2.4.0-alpha07 and lower
override val name = "SearchParameters"
}
This can then be used in your Kotlin DSL like any other type:
fragment<SearchFragment>(nav_routes.plant_search) {
label = getString(R.string.plant_search_title)
argument(nav_arguments.search_parameters) {
type = SearchParametersType
defaultValue = SearchParameters("cactus", emptyList())
}
}
This example uses
val params = SearchParameters("rose", listOf("available"))
val searchArgument = Uri.encode(Json.encodeToString(params))
navController.navigate("${nav_routes.plant_search}/$searchArgument")
The custom NavType:
val params: SearchParameters? = arguments?.getParcelable(nav_arguments.search_parameters)
Description
NavType should not require extended classes to override the
name
property. Name is used exclusively internal forNavInflater
for classes that are inflated from XML. All the types that need to implementname
already do, and custom NavTypes should not have this requirement.Instead of being abstract, the
name
property should default to another string (i.e. "nav_type").