@Test public void deepLinkArgumentMatch() { String deepLinkArgument = DEEP_LINK_EXACT_HTTPS + "/users/{id}/posts"; NavDeepLink deepLink = new NavDeepLink(deepLinkArgument); String id = "2"; Bundle matchArgs = deepLink.getMatchingArguments( Uri.parse(deepLinkArgument.replace("{id}", id))); assertThat(matchArgs, not(nullValue())); assertThat(matchArgs.getString("id"), is(id)); }
@Nullable Bundle getMatchingArguments(@NonNull Uri deepLink) { Matcher matcher = mPattern.matcher(deepLink.toString()); if (!matcher.matches()) { return null; } Bundle bundle = new Bundle(); int size = mArguments.size(); for (int index = 0; index < size; index++) { String argument = mArguments.get(index); bundle.putString(argument, Uri.decode(matcher.group(index + 1))); } return bundle; }
NavDeepLink { @Nullable Bundle getMatchingArguments(@NonNull Uri deepLink) { Matcher matcher = mPattern.matcher(deepLink.toString()); if (!matcher.matches()) { return null; } Bundle bundle = new Bundle(); int size = mArguments.size(); for (int index = 0; index < size; index++) { String argument = mArguments.get(index); bundle.putString(argument, Uri.decode(matcher.group(index + 1))); } return bundle; } }
NavDeepLink { @Nullable Bundle getMatchingArguments(@NonNull Uri deepLink) { Matcher matcher = mPattern.matcher(deepLink.toString()); if (!matcher.matches()) { return null; } Bundle bundle = new Bundle(); int size = mArguments.size(); for (int index = 0; index < size; index++) { String argument = mArguments.get(index); bundle.putString(argument, Uri.decode(matcher.group(index + 1))); } return bundle; } NavDeepLink(@NonNull String uri); }
NavDeepLink { @Nullable Bundle getMatchingArguments(@NonNull Uri deepLink) { Matcher matcher = mPattern.matcher(deepLink.toString()); if (!matcher.matches()) { return null; } Bundle bundle = new Bundle(); int size = mArguments.size(); for (int index = 0; index < size; index++) { String argument = mArguments.get(index); bundle.putString(argument, Uri.decode(matcher.group(index + 1))); } return bundle; } NavDeepLink(@NonNull String uri);  }
NavDeepLink { @Nullable Bundle getMatchingArguments(@NonNull Uri deepLink) { Matcher matcher = mPattern.matcher(deepLink.toString()); if (!matcher.matches()) { return null; } Bundle bundle = new Bundle(); int size = mArguments.size(); for (int index = 0; index < size; index++) { String argument = mArguments.get(index); bundle.putString(argument, Uri.decode(matcher.group(index + 1))); } return bundle; } NavDeepLink(@NonNull String uri);   }