-
- All Implemented Interfaces:
-
org.readium.r2.navigator.Navigator.Listener
public interface HyperlinkNavigator.Listener implements Navigator.Listener
-
-
Method Summary
Modifier and Type Method Description BooleanshouldFollowInternalLink(Link link, HyperlinkNavigator.LinkContext context)Called when a link to an internal resource was clicked in the navigator. abstract UnitonExternalLinkActivated(AbsoluteUrl url)Called when a link to an external URL was activated in the navigator. -
-
Method Detail
-
shouldFollowInternalLink
Boolean shouldFollowInternalLink(Link link, HyperlinkNavigator.LinkContext context)
Called when a link to an internal resource was clicked in the navigator.
You can use this callback to perform custom navigation like opening a new window or other operations.
By returning false the navigator wont try to open the link itself and it is up to the calling app to decide how to display the resource.
-
onExternalLinkActivated
abstract Unit onExternalLinkActivated(AbsoluteUrl url)
Called when a link to an external URL was activated in the navigator.
If it is an HTTP URL, you should open it with a
CustomTabsIntentorWebView, for example:override fun onExternalLinkActivated(url: AbsoluteUrl) { if (!url.isHttp) return val context = requireActivity() val uri = url.toUri() try { CustomTabsIntent.Builder() .build() .launchUrl(context, uri) } catch (e: ActivityNotFoundException) { context.startActivity(Intent(Intent.ACTION_VIEW, uri)) } }
-
-
-
-