Search in sources :

Example 11 with ListUrlBuilder

use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.

the class GalleryListUrlParser method parse.

public static ListUrlBuilder parse(String urlStr) {
    URL url;
    try {
        url = new URL(urlStr);
    } catch (MalformedURLException e) {
        return null;
    }
    if (!Utilities.contain(VALID_HOSTS, url.getHost())) {
        return null;
    }
    String path = url.getPath();
    if (path == null) {
        return null;
    }
    if (PATH_NORMAL.equals(path) || path.length() == 0) {
        ListUrlBuilder builder = new ListUrlBuilder();
        builder.setQuery(url.getQuery());
        return builder;
    } else if (path.startsWith(PATH_UPLOADER)) {
        return parseUploader(path);
    } else if (path.startsWith(PATH_TAG)) {
        return parseTag(path);
    } else if (path.startsWith("/")) {
        int category;
        try {
            category = Integer.parseInt(path.substring(1));
        } catch (NumberFormatException e) {
            return null;
        }
        ListUrlBuilder builder = new ListUrlBuilder();
        builder.setQuery(url.getQuery());
        builder.setCategory(category);
        return builder;
    } else {
        return null;
    }
}
Also used : ListUrlBuilder(com.hippo.ehviewer.client.data.ListUrlBuilder) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL)

Aggregations

ListUrlBuilder (com.hippo.ehviewer.client.data.ListUrlBuilder)11 Context (android.content.Context)3 Announcer (com.hippo.scene.Announcer)3 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 File (java.io.File)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Point (android.graphics.Point)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)1 EditTextDialogBuilder (com.hippo.app.EditTextDialogBuilder)1