Example usage for android.net UrlQuerySanitizer parseUrl

List of usage examples for android.net UrlQuerySanitizer parseUrl

Introduction

In this page you can find the example usage for android.net UrlQuerySanitizer parseUrl.

Prototype

public void parseUrl(String url) 

Source Link

Document

Parse the query parameters out of an encoded URL.

Usage

From source file:Main.java

static void paramLoader(WebView view, String url) {
    UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
    sanitizer.setAllowUnregisteredParamaters(true);
    sanitizer.parseUrl(url);
    String param = sanitizer.getValue("pageload");
    if (param != null) {
        switch (param) {
        case "composer":
            view.loadUrl(//from   w  w  w .j  ava 2s. c om
                    "javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_overview%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
            break;
        case "composer_photo":
            view.loadUrl(
                    "javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_photo%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
            break;
        case "composer_checkin":
            view.loadUrl(
                    "javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_location%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
            break;
        case "composer_top":
            view.scrollTo(0, 0);
            break;
        default:
            break;
        }
    }

}

From source file:com.karura.framework.utils.UrlUtils.java

public static UrlQuerySanitizer sanitizeQuery(String query, String[] parameters) {
    UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();

    sanitizer.registerParameters(parameters, UrlQuerySanitizer.getSpaceLegal());
    sanitizer.parseUrl(query);
    return sanitizer;
}