From c4e853d551caf4677a0a606b12b962d706ba7d32 Mon Sep 17 00:00:00 2001 From: NekoInverter <7741672-NekoInverter@users.noreply.gitlab.com> Date: Fri, 11 Dec 2020 16:45:10 +0800 Subject: [PATCH] Fix tag translations download --- .../com/hippo/ehviewer/client/EhSSLSocketFactory.java | 9 +-------- .../java/com/hippo/ehviewer/client/EhTagDatabase.java | 7 +++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java index d3e2c5eec..6730b06c6 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java @@ -24,14 +24,7 @@ public class EhSSLSocketFactory extends SSLSocketFactory { InetAddress address = s.getInetAddress(); Log.d("EhSSLSocketFactory", "Host: " + host + " Address: " + address.getHostAddress()); if (autoClose) s.close(); - if (host.endsWith("e-hentai.org") || - host.endsWith("exhentai.org") || - host.endsWith("ehgt.org") || - host.endsWith("hath.network")) { - return getDefault().createSocket(address, port); - } else { - return getDefault().createSocket(host, port); - } + return getDefault().createSocket(address, port); } @Override diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java index 2975ae790..c127d563c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java @@ -23,7 +23,6 @@ import androidx.annotation.Nullable; import androidx.core.util.Pair; import com.hippo.ehviewer.AppConfig; -import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; import com.hippo.util.ExceptionUtils; import com.hippo.util.IoThreadPoolExecutor; @@ -59,6 +58,7 @@ public class EhTagDatabase { private static volatile EhTagDatabase instance; // TODO more lock for different language private static final Lock lock = new ReentrantLock(); + private static OkHttpClient client; static { NAMESPACE_TO_PREFIX.put("artist", "a:"); @@ -78,7 +78,7 @@ public class EhTagDatabase { public EhTagDatabase(String name, BufferedSource source) throws IOException { this.name = name; String[] tmp; - StringBuilder buffer = new StringBuilder(""); + StringBuilder buffer = new StringBuilder(); source.readInt(); for (String i : source.readUtf8().split("\n")) { tmp = i.split("\r", 2); @@ -95,6 +95,7 @@ public class EhTagDatabase { int totalBytes = b.length; tags = new byte[totalBytes]; System.arraycopy(b, 0, tags, 0, totalBytes); + client = new OkHttpClient.Builder().build(); } @Nullable @@ -260,8 +261,6 @@ public class EhTagDatabase { } } - OkHttpClient client = EhApplication.getOkHttpClient(EhApplication.getInstance()); - // Save new sha1 File tempSha1File = new File(dir, sha1Name + ".tmp"); if (!save(client, sha1Url, tempSha1File)) {