Prevent loop

release
FongMi 1 year ago
parent 38c890ec41
commit 91cfe15e30
  1. 5
      app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java

@ -31,6 +31,7 @@ import com.orhanobut.logger.Logger;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@ -44,6 +45,7 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL
private WebResourceResponse empty;
private ParseCallback callback;
private HashSet<String> urls;
private WebDialog dialog;
private Runnable timer;
private boolean detect;
@ -63,6 +65,7 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL
@SuppressLint("SetJavaScriptEnabled")
public void initSettings() {
this.urls = new HashSet<>();
this.timer = () -> stop(true);
this.empty = new WebResourceResponse("text/plain", "utf-8", new ByteArrayInputStream("".getBytes()));
getSettings().setSupportZoom(true);
@ -114,7 +117,7 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL
if (TextUtils.isEmpty(host) || isAd(host)) return empty;
Map<String, String> headers = request.getRequestHeaders();
if (url.contains("challenges.cloudflare.com/turnstile")) App.post(() -> showDialog());
if (detect && PLAYER.matcher(url).find()) onParseAdd(headers, url);
if (detect && PLAYER.matcher(url).find() && urls.add(url)) onParseAdd(headers, url);
else if (isVideoFormat(url)) onParseSuccess(headers, url);
return super.shouldInterceptRequest(view, request);
}

Loading…
Cancel
Save