pull/123/head
FongMi 3 years ago
parent 86833513bd
commit c067b1cd42
  1. 11
      app/src/main/java/com/fongmi/android/tv/player/parse/ParseJob.java
  2. 6
      app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java

@ -103,19 +103,19 @@ public class ParseJob implements ParseCallback {
private void godParse(String webUrl, String flag) throws Exception {
List<Parse> json = ApiConfig.get().getParses(1, flag);
List<Parse> webs = ApiConfig.get().getParses(0, flag);
CountDownLatch cd = new CountDownLatch(json.size());
for (Parse item : json) infinite.execute(() -> jsonParse(cd, item, webUrl));
cd.await();
CountDownLatch latch = new CountDownLatch(json.size());
for (Parse item : json) infinite.execute(() -> jsonParse(latch, item, webUrl));
latch.await();
if (webs.isEmpty()) onParseError();
for (Parse item : webs) App.post(() -> startWeb(item, webUrl));
}
private void jsonParse(CountDownLatch cd, Parse item, String webUrl) {
private void jsonParse(CountDownLatch latch, Parse item, String webUrl) {
try {
jsonParse(item, webUrl, true);
} catch (Exception ignored) {
} finally {
cd.countDown();
latch.countDown();
}
}
@ -161,6 +161,7 @@ public class ParseJob implements ParseCallback {
private void stopWeb() {
for (CustomWebView webView : webViews) webView.stop(false);
webViews.clear();
}
public void stop() {

@ -123,21 +123,21 @@ public class CustomWebView extends WebView {
String cookie = CookieManager.getInstance().getCookie(url);
if (!TextUtils.isEmpty(cookie)) news.put("cookie", cookie);
for (String key : headers.keySet()) if (keys.contains(key.toLowerCase())) news.put(key, headers.get(key));
App.post(() -> onSuccess(news, url));
onSuccess(news, url);
}
public void stop(boolean error) {
stopLoading();
loadUrl("about:blank");
App.removeCallbacks(timer);
if (error) App.post(this::onError);
if (error) onError();
else callback = null;
}
private void onSuccess(Map<String, String> news, String url) {
if (callback != null) callback.onParseSuccess(news, url, from);
App.post(() -> stop(false));
callback = null;
stop(false);
}
private void onError() {

Loading…
Cancel
Save