pull/138/head
jun 10 months ago
parent 9bcda08ab3
commit bc8c202801
  1. 8
      app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java
  2. 7
      app/src/main/java/com/github/tvbox/osc/util/OkGoHelper.java

@ -1548,6 +1548,7 @@ public class LivePlayActivity extends BaseActivity {
@Override
public String convertResponse(okhttp3.Response response) throws Throwable {
assert response.body() != null;
return response.body().string();
}
@ -1576,6 +1577,13 @@ public class LivePlayActivity extends BaseActivity {
}
});
}
@Override
public void onError(Response<String> response) {
super.onError(response);
// 在请求失败或超时的情况下返回false
Toast.makeText(App.getInstance(), "请求超时", Toast.LENGTH_SHORT).show();
finish();
}
});
}

@ -20,6 +20,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -40,7 +41,7 @@ import xyz.doikki.videoplayer.exo.ExoMediaSourceHelper;
public class OkGoHelper {
public static final long DEFAULT_MILLISECONDS = 8000; //默认的超时时间
public static final long DEFAULT_MILLISECONDS = 6000; //默认的超时时间
static void initExoOkHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
@ -142,9 +143,9 @@ public class OkGoHelper {
// 判断输入是否为 IP 地址
if (isValidIpAddress(hostname)) {
return Collections.singletonList(InetAddress.getByName(hostname));
} else if (!myHosts.isEmpty() && myHosts.containsKey(hostname)) {
return Arrays.asList(InetAddress.getAllByName(myHosts.get(hostname)));
} else {
if(!myHosts.isEmpty() && myHosts.containsKey(hostname))hostname=myHosts.get(hostname);
assert hostname != null;
// return (is_doh?dnsOverHttps:Dns.SYSTEM).lookup(hostname);
return (dnsOverHttps).lookup(hostname);
}

Loading…
Cancel
Save