From 9208c53d4f088eacb1532a9aa29a39edb1be46f8 Mon Sep 17 00:00:00 2001 From: seven332 Date: Tue, 19 Mar 2019 22:37:37 +0800 Subject: [PATCH] Fix gallery list url builder --- .../com/hippo/ehviewer/client/EhConfig.java | 1 + .../ehviewer/client/data/ListUrlBuilder.java | 30 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java b/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java index 600c5851c..026f93b39 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java @@ -289,6 +289,7 @@ public class EhConfig implements Cloneable { public static final int ASIAN_PORN = 0x80; public static final int NON_H = 0x100; public static final int WESTERN = 0x200; + public static final int ALL_CATEGORY = 0x3ff; public static final int NAMESPACES_RECLASS = 0x1; public static final int NAMESPACES_LANGUAGE = 0x2; diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java index 54860228a..ac823646c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java +++ b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java @@ -384,28 +384,19 @@ public class ListUrlBuilder implements Cloneable, Parcelable { switch (mMode) { default: case MODE_NORMAL: { - boolean filter = false; UrlBuilder ub = new UrlBuilder(EhUrl.getHost()); if (mCategory != EhUtils.NONE) { - ub.addQuery("f_doujinshi", ((mCategory & EhConfig.DOUJINSHI) == 0) ? "0" : "1"); - ub.addQuery("f_manga", ((mCategory & EhConfig.MANGA) == 0) ? "0" : "1"); - ub.addQuery("f_artistcg", ((mCategory & EhConfig.ARTIST_CG) == 0) ? "0" : "1"); - ub.addQuery("f_gamecg", ((mCategory & EhConfig.GAME_CG) == 0) ? "0" : "1"); - ub.addQuery("f_western", ((mCategory & EhConfig.WESTERN) == 0) ? "0" : "1"); - ub.addQuery("f_non-h", ((mCategory & EhConfig.NON_H) == 0) ? "0" : "1"); - ub.addQuery("f_imageset", ((mCategory & EhConfig.IMAGE_SET) == 0) ? "0" : "1"); - ub.addQuery("f_cosplay", ((mCategory & EhConfig.COSPLAY) == 0) ? "0" : "1"); - ub.addQuery("f_asianporn", ((mCategory & EhConfig.ASIAN_PORN) == 0) ? "0" : "1"); - ub.addQuery("f_misc", ((mCategory & EhConfig.MISC) == 0) ? "0" : "1"); - filter = true; + ub.addQuery("f_cats", (~mCategory) & EhConfig.ALL_CATEGORY); } // Search key if (mKeyword != null) { - try { - ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8")); - filter = true; - } catch (UnsupportedEncodingException e) { - // Empty + String keyword = mKeyword.trim(); + if (!keyword.isEmpty()) { + try { + ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8")); + } catch (UnsupportedEncodingException e) { + // Empty + } } } // Page index @@ -428,11 +419,6 @@ public class ListUrlBuilder implements Cloneable, Parcelable { ub.addQuery("f_sr", "on"); ub.addQuery("f_srdd", mMinRating); } - filter = true; - } - // Add filter foot - if (filter) { - ub.addQuery("f_apply", "Apply+Filter"); } return ub.build(); }