Created
July 20, 2012 06:35
-
-
Save checko/3149069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String getJsDialogTitle(String url) { | |
String title = url; | |
if (URLUtil.isDataUrl(url)) { | |
// For data: urls, we just display 'JavaScript' similar to Safari. | |
title = mContext.getString(R.string.js_dialog_title_default); | |
} else { | |
try { | |
URL aUrl = new URL(url); | |
// For example: "The page at 'http://www.mit.edu' says:" | |
title = mContext.getString(R.string.js_dialog_title, | |
aUrl.getProtocol() + "://" + aUrl.getHost()); | |
} catch (MalformedURLException ex) { | |
// do nothing. just use the url as the title | |
} | |
} | |
return title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment