Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple snippet building a URL if you have a webview with a pdf, doc, etc URL.
public class URLUtils {
private static final String fGOOGLE_DOC_URL = "";
private enum GoogleDocType{
PDF(".pdf"), DOC(".doc"), XLS(".xls"), DOCX(".docx"), XLSX(".xlsx");
private String mSuffix;
GoogleDocType(String suffix){
mSuffix = suffix;
private boolean isTypeOf(String url){
return url.endsWith(mSuffix);
public static String buildGoogleDocURL(String url){
if(TextUtils.isEmpty(url)) return null;
for(GoogleDocType type : GoogleDocType.values())
return String.format(fGOOGLE_DOC_URL, url);
return url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment