diff --git a/app/build.gradle b/app/build.gradle index 99797267d..3bc70472a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,7 +27,7 @@ android { applicationId "io.github.nekoinverter.ehviewer" minSdkVersion 21 targetSdkVersion 30 - versionCode 123 + versionCode 124 versionName "1.7.18" resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW", "es", "ja", "ko", "fr", "de", "th" 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 c127d563c..c8f58c5c5 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java @@ -58,7 +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; + private static final OkHttpClient client = new OkHttpClient.Builder().build(); static { NAMESPACE_TO_PREFIX.put("artist", "a:"); @@ -95,7 +95,6 @@ public class EhTagDatabase { int totalBytes = b.length; tags = new byte[totalBytes]; System.arraycopy(b, 0, tags, 0, totalBytes); - client = new OkHttpClient.Builder().build(); } @Nullable @@ -189,7 +188,7 @@ public class EhTagDatabase { return equals(s1, s2); } - private static boolean save(OkHttpClient client, String url, File file) { + private static boolean save(String url, File file) { Request request = new Request.Builder().url(url).build(); Call call = client.newCall(request); try (Response response = call.execute()) { @@ -263,7 +262,7 @@ public class EhTagDatabase { // Save new sha1 File tempSha1File = new File(dir, sha1Name + ".tmp"); - if (!save(client, sha1Url, tempSha1File)) { + if (!save(sha1Url, tempSha1File)) { FileUtils.delete(tempSha1File); return; } @@ -277,7 +276,7 @@ public class EhTagDatabase { // Save new data File tempDataFile = new File(dir, dataName + ".tmp"); - if (!save(client, dataUrl, tempDataFile)) { + if (!save(dataUrl, tempDataFile)) { FileUtils.delete(tempDataFile); return; } @@ -377,7 +376,6 @@ public class EhTagDatabase { return searchTag(tags, keyword); } - @Nullable private ArrayList> searchTag(byte[] tags, String keyword) { ArrayList> searchHints = new ArrayList<>(); int begin = 0;