From fe8bd81c4d73e210a20b5bca9cbe0a1e9e15f8f9 Mon Sep 17 00:00:00 2001 From: FongMi Date: Wed, 18 Jan 2023 13:41:33 +0800 Subject: [PATCH] Update CustomWebView.java --- .../com/fongmi/android/tv/ui/custom/CustomWebView.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java b/app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java index 47ad08ff4..51cf67ec0 100644 --- a/app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java +++ b/app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java @@ -34,7 +34,7 @@ public class CustomWebView extends WebView { private ParseTask.Callback callback; private WebResourceResponse empty; private List keys; - private Runnable mTimer; + private Runnable timer; private String key; public static CustomWebView create(@NonNull Context context) { @@ -48,6 +48,7 @@ public class CustomWebView extends WebView { @SuppressLint("SetJavaScriptEnabled") public void initSettings() { + this.timer = () -> stop(true); this.keys = Arrays.asList("user-agent", "referer", "origin"); this.empty = new WebResourceResponse("text/plain", "utf-8", new ByteArrayInputStream("".getBytes())); getSettings().setUseWideViewPort(true); @@ -70,7 +71,7 @@ public class CustomWebView extends WebView { } public CustomWebView start(String key, String url, Map headers, ParseTask.Callback callback) { - App.post(mTimer = () -> stop(true), Constant.TIMEOUT_PARSE_WEB); + App.post(timer, Constant.TIMEOUT_PARSE_WEB); this.callback = callback; setUserAgent(headers); loadUrl(url, headers); @@ -126,7 +127,7 @@ public class CustomWebView extends WebView { public void stop(boolean error) { stopLoading(); loadUrl("about:blank"); - App.removeCallbacks(mTimer); + App.removeCallbacks(timer); if (error) App.post(this::onError); }