Skip to content

Instantly share code, notes, and snippets.

@fmedlin
Last active November 6, 2021 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmedlin/fcdd9a0c49fd8194fd6c656093c38144 to your computer and use it in GitHub Desktop.
Save fmedlin/fcdd9a0c49fd8194fd6c656093c38144 to your computer and use it in GitHub Desktop.
ClickHandler.handleClick(view.findViewById(R.id.about_blog), v ->
browseOrToastOnError(view.getContext(), SIMPLENOTE_BLOG_URL));
private void browseOrToastOnError(Context context, String url) {
browseOrToastOnError(context, url, R.string.no_browser_available);
}
private void browseOrToastOnError(Context context, String url, @StringRes int stringRes) {
try {
BrowserUtils.launchBrowserOrShowError(requireContext(), url);
} catch (Exception e) {
Toast.makeText(context, stringRes, Toast.LENGTH_LONG).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment