Fix memory leak

pull/594/head
jhengazuki 4 months ago
parent 1cf4f6345a
commit 776ca9bd55
  1. 7
      app/src/main/java/com/fongmi/android/tv/player/ParseJob.java

@ -30,6 +30,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.Response;
public class ParseJob implements ParseCallback { public class ParseJob implements ParseCallback {
@ -112,12 +113,13 @@ public class ParseJob implements ParseCallback {
} }
private void jsonParse(Parse item, String webUrl, boolean error) throws Exception { private void jsonParse(Parse item, String webUrl, boolean error) throws Exception {
String body = OkHttp.newCall(item.getUrl() + webUrl, Headers.of(item.getHeaders())).execute().body().string(); Response res = OkHttp.newCall(item.getUrl() + webUrl, Headers.of(item.getHeaders())).execute();
JsonObject object = Json.parse(body).getAsJsonObject(); JsonObject object = Json.parse(res.body().string()).getAsJsonObject();
String url = Json.safeString(object, "url"); String url = Json.safeString(object, "url");
JsonObject data = object.getAsJsonObject("data"); JsonObject data = object.getAsJsonObject("data");
if (url.isEmpty()) url = Json.safeString(data, "url"); if (url.isEmpty()) url = Json.safeString(data, "url");
checkResult(getHeader(object), url, item.getName(), error); checkResult(getHeader(object), url, item.getName(), error);
res.close();
} }
private void jsonExtend(String webUrl) throws Throwable { private void jsonExtend(String webUrl) throws Throwable {
@ -211,6 +213,7 @@ public class ParseJob implements ParseCallback {
private void stopWeb() { private void stopWeb() {
for (CustomWebView webView : webViews) webView.stop(false); for (CustomWebView webView : webViews) webView.stop(false);
for (CustomWebView webView : webViews) webView.destroy();
if (!webViews.isEmpty()) webViews.clear(); if (!webViews.isEmpty()) webViews.clear();
} }

Loading…
Cancel
Save