Add the @IdRes annotation to setId
The parameter of setId on NavDestination should be an @IdRes.
RelNote: "The setId method on NavDestination is now properly annotated
with @IdRes, so it only accepts resource ids."
Test: ./gradlew checkApi
Fixes: 187115543
Change-Id: I69b80a6a63c4db257385c96bd07ad21f7665dcb8
diff --git a/navigation/navigation-common/api/current.txt b/navigation/navigation-common/api/current.txt
index 61c3c82..afc02e9 100644
--- a/navigation/navigation-common/api/current.txt
+++ b/navigation/navigation-common/api/current.txt
@@ -201,7 +201,7 @@
method public final void putAction(@IdRes int actionId, androidx.navigation.NavAction action);
method public final void removeAction(@IdRes int actionId);
method public final void removeArgument(String argumentName);
- method public final void setId(int id);
+ method public final void setId(@IdRes int id);
method public final void setLabel(CharSequence? p);
method public final void setRoute(String? route);
property public final java.util.Map<java.lang.String,androidx.navigation.NavArgument> arguments;
diff --git a/navigation/navigation-common/api/public_plus_experimental_current.txt b/navigation/navigation-common/api/public_plus_experimental_current.txt
index 6ca2e72..7c4b7c6 100644
--- a/navigation/navigation-common/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-common/api/public_plus_experimental_current.txt
@@ -225,7 +225,7 @@
method public final void putAction(@IdRes int actionId, androidx.navigation.NavAction action);
method public final void removeAction(@IdRes int actionId);
method public final void removeArgument(String argumentName);
- method public final void setId(int id);
+ method public final void setId(@IdRes int id);
method public final void setLabel(CharSequence? p);
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public final void setParent(androidx.navigation.NavGraph? p);
method public final void setRoute(String? route);
diff --git a/navigation/navigation-common/api/restricted_current.txt b/navigation/navigation-common/api/restricted_current.txt
index 61c3c82..afc02e9 100644
--- a/navigation/navigation-common/api/restricted_current.txt
+++ b/navigation/navigation-common/api/restricted_current.txt
@@ -201,7 +201,7 @@
method public final void putAction(@IdRes int actionId, androidx.navigation.NavAction action);
method public final void removeAction(@IdRes int actionId);
method public final void removeArgument(String argumentName);
- method public final void setId(int id);
+ method public final void setId(@IdRes int id);
method public final void setLabel(CharSequence? p);
method public final void setRoute(String? route);
property public final java.util.Map<java.lang.String,androidx.navigation.NavArgument> arguments;
diff --git a/navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt b/navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
index 4128cc2..6143ed8 100644
--- a/navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
+++ b/navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
@@ -164,7 +164,7 @@
*/
@get:IdRes
public var id: Int = 0
- set(id) {
+ set(@IdRes id) {
field = id
idName = null
}