Example usage for android.net UrlQuerySanitizer UrlQuerySanitizer

List of usage examples for android.net UrlQuerySanitizer UrlQuerySanitizer

Introduction

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

Prototype

public UrlQuerySanitizer() 

Source Link

Document

Constructs a UrlQuerySanitizer.

Usage

From source file:Main.java

static void paramLoader(WebView view, String url) {
    UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
    sanitizer.setAllowUnregisteredParamaters(true);
    sanitizer.parseUrl(url);//  w  ww. j  av a2 s  .  com
    String param = sanitizer.getValue("pageload");
    if (param != null) {
        switch (param) {
        case "composer":
            view.loadUrl(
                    "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);/*  w w w  .  j ava2 s .  co m*/
    return sanitizer;
}