修一个t4 ext参数相关的bug;更改一处盒子/手机的判断条件

main
jun 2 months ago
parent 49e6314378
commit 022bad8027
  1. 8
      app/build.gradle
  2. 5
      app/src/main/java/com/github/tvbox/osc/ui/dialog/GridFilterDialog.java
  3. 2
      app/src/main/java/com/github/tvbox/osc/util/OkGoHelper.java
  4. 148
      app/src/main/java/com/github/tvbox/osc/viewmodel/SourceViewModel.java

@ -54,6 +54,14 @@ android {
} }
} }
} }
// ABI
splits {
abi {
enable false // ABI
}
}
applicationVariants.configureEach { variant -> applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output -> variant.outputs.configureEach { output ->
def flavorNames = variant.productFlavors.collect { it.name == "normal" ? "java" : it.name }.join('-') def flavorNames = variant.productFlavors.collect { it.name == "normal" ? "java" : it.name }.join('-')

@ -130,7 +130,10 @@ public class GridFilterDialog extends BaseDialog {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
return false; return false;
} }
// SDK <= Android 9 直接认为是 TV / 机顶盒
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
return true;
}
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
UiModeManager uiMode = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE); UiModeManager uiMode = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);

@ -176,7 +176,7 @@ public class OkGoHelper {
// if (!dohUrl.isEmpty()) is_doh = true; // if (!dohUrl.isEmpty()) is_doh = true;
// LOG.i("echo-initDnsOverHttps dohUrl:"+dohUrl); // LOG.i("echo-initDnsOverHttps dohUrl:"+dohUrl);
// LOG.i("echo-initDnsOverHttps ips:"+ips); // LOG.i("echo-initDnsOverHttps ips:"+ips);
dnsOverHttps = new DnsOverHttps.Builder().client(dohClient).url(dohUrl.isEmpty() ? null : HttpUrl.get(dohUrl)).bootstrapDnsHosts(ips!=null?DohIps(ips):null).build(); dnsOverHttps = new DnsOverHttps.Builder().client(dohClient).url(dohUrl.isEmpty() ? null : HttpUrl.get(dohUrl)).bootstrapDnsHosts((ips!=null && !dohUrl.equals("https://doh.pub/dns-query"))?DohIps(ips):null).build();
} }
// 自定义 DNS 解析器 // 自定义 DNS 解析器

@ -36,6 +36,7 @@ import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.AbsCallback; import com.lzy.okgo.callback.AbsCallback;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.GetRequest;
import com.orhanobut.hawk.Hawk; import com.orhanobut.hawk.Hawk;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
@ -238,11 +239,14 @@ public class SourceViewModel extends ViewModel {
String extend=sourceBean.getExt(); String extend=sourceBean.getExt();
extend=getFixUrl(extend); extend=getFixUrl(extend);
if(URLEncoder.encode(extend).length()<1000){ if(URLEncoder.encode(extend).length()<1000){
OkGo.<String>get(sourceBean.getApi()) GetRequest<String> request = OkGo.<String>get(sourceBean.getApi())
.tag(sourceBean.getKey() + "_sort") .tag(sourceBean.getKey() + "_sort")
.params("filter", "true") .params("filter", "true");
.params("extend", extend) // 当 extend 不为空且非空字符串时添加参数
.execute(new AbsCallback<String>() { if (extend != null && !extend.isEmpty()) {
request.params("extend", extend);
}
request.execute(new AbsCallback<String>() {
@Override @Override
public String convertResponse(okhttp3.Response response) throws Throwable { public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) { if (response.body() != null) {
@ -292,7 +296,9 @@ public class SourceViewModel extends ViewModel {
try { try {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("filter","true"); params.put("filter","true");
params.put("extend",extend); if (extend != null && !extend.isEmpty()) {
params.put("extend",extend);
}
RemoteTVBox.post(sourceBean.getApi(), params, new okhttp3.Callback() { RemoteTVBox.post(sourceBean.getApi(), params, new okhttp3.Callback() {
@Override @Override
public void onFailure(@NonNull Call call, IOException e) { public void onFailure(@NonNull Call call, IOException e) {
@ -337,7 +343,7 @@ public class SourceViewModel extends ViewModel {
try { try {
Spider sp = ApiConfig.get().getCSP(homeSourceBean); Spider sp = ApiConfig.get().getCSP(homeSourceBean);
String json = sp.categoryContent(sortData.id, page + "", true, sortData.filterSelect); String json = sp.categoryContent(sortData.id, page + "", true, sortData.filterSelect);
LOG.i("categoryContent:"+json); LOG.i("echo-categoryContent:"+json);
json(listResult, json,homeSourceBean.getKey()); json(listResult, json,homeSourceBean.getKey());
} catch (Throwable th) { } catch (Throwable th) {
th.printStackTrace(); th.printStackTrace();
@ -394,37 +400,47 @@ public class SourceViewModel extends ViewModel {
}else { }else {
ext = Base64.encodeToString("{}".getBytes(), Base64.DEFAULT | Base64.NO_WRAP); ext = Base64.encodeToString("{}".getBytes(), Base64.DEFAULT | Base64.NO_WRAP);
} }
OkGo.<String>get(homeSourceBean.getApi())
.tag(homeSourceBean.getApi()) GetRequest<String> request = OkGo.<String>get(homeSourceBean.getApi())
.params("ac", "detail") .tag(homeSourceBean.getApi())
.params("filter", "true") .params("ac", "detail")
.params("t", sortData.id) .params("filter", "true")
.params("pg", page) .params("t", sortData.id)
.params("ext", ext) .params("pg", page)
.params("extend", extend) .params("ext", ext);
.execute(new AbsCallback<String>() { // 当 extend 不为空且非空字符串时添加参数
@Override if (extend != null && !extend.isEmpty()) {
public String convertResponse(okhttp3.Response response) throws Throwable { request.params("extend", extend);
if (response.body() != null) { }
return response.body().string(); request.execute(new AbsCallback<String>() {
} else { @Override
throw new IllegalStateException("网络请求错误"); public String convertResponse(okhttp3.Response response) throws Throwable {
try {
if (response.body() != null) {
return response.body().string();
} else {
throw new IllegalStateException("网络请求错误,response body 为 null");
}
} catch (Exception e) {
LOG.i("echo-list: convertResponse error"+ e.getMessage());
throw e; // 重新抛出异常
}
} }
}
@Override @Override
public void onSuccess(Response<String> response) { public void onSuccess(Response<String> response) {
String json = response.body(); String json = response.body();
LOG.i("echo-list:"+json); LOG.i("echo-list: " + json);
json(listResult, json, homeSourceBean.getKey()); json(listResult, json, homeSourceBean.getKey());
} }
@Override
public void onError(Response<String> response) {
super.onError(response);
listResult.postValue(null);
}
});
@Override
public void onError(Response<String> response) {
super.onError(response);
listResult.postValue(null);
}
});
} else { } else {
listResult.postValue(null); listResult.postValue(null);
} }
@ -577,12 +593,16 @@ public class SourceViewModel extends ViewModel {
} else if (type == 0 || type == 1|| type == 4) { } else if (type == 0 || type == 1|| type == 4) {
String extend=sourceBean.getExt(); String extend=sourceBean.getExt();
extend=getFixUrl(extend); extend=getFixUrl(extend);
OkGo.<String>get(sourceBean.getApi())
GetRequest<String> request = OkGo.<String>get(sourceBean.getApi())
.tag("detail") .tag("detail")
.params("ac", type == 0 ? "videolist" : "detail") .params("ac", type == 0 ? "videolist" : "detail")
.params("ids", id) .params("ids", id);
.params("extend", extend) // 当 extend 不为空且非空字符串时添加参数
.execute(new AbsCallback<String>() { if (extend != null && !extend.isEmpty()) {
request.params("extend", extend);
}
request.execute(new AbsCallback<String>() {
@Override @Override
public String convertResponse(okhttp3.Response response) throws Throwable { public String convertResponse(okhttp3.Response response) throws Throwable {
@ -673,13 +693,17 @@ public class SourceViewModel extends ViewModel {
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
OkGo.<String>get(sourceBean.getApi())
.params("wd", wd) GetRequest<String> request = OkGo.<String>get(sourceBean.getApi())
.params("ac" ,"detail") .tag("search")
.params("quick" ,"false") .params("wd", wd)
.params("extend" ,extend) .params("ac" ,"detail")
.tag("search") .params("quick" ,"false");
.execute(new AbsCallback<String>() { // 当 extend 不为空且非空字符串时添加参数
if (extend != null && !extend.isEmpty()) {
request.params("extend", extend);
}
request.execute(new AbsCallback<String>() {
@Override @Override
public String convertResponse(okhttp3.Response response) throws Throwable { public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) { if (response.body() != null) {
@ -756,13 +780,17 @@ public class SourceViewModel extends ViewModel {
}else if (type == 4) { }else if (type == 4) {
String extend=sourceBean.getExt(); String extend=sourceBean.getExt();
extend=getFixUrl(extend); extend=getFixUrl(extend);
OkGo.<String>get(sourceBean.getApi())
.params("wd", wd) GetRequest<String> request = OkGo.<String>get(sourceBean.getApi())
.params("ac" ,"detail") .tag("search")
.params("quick" ,"true") .params("wd", wd)
.params("extend" ,extend) .params("ac" ,"detail")
.tag("search") .params("quick" ,"true");
.execute(new AbsCallback<String>() { // 当 extend 不为空且非空字符串时添加参数
if (extend != null && !extend.isEmpty()) {
request.params("extend", extend);
}
request.execute(new AbsCallback<String>() {
@Override @Override
public String convertResponse(okhttp3.Response response) throws Throwable { public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) { if (response.body() != null) {
@ -866,12 +894,16 @@ public class SourceViewModel extends ViewModel {
} else if (type == 4) { } else if (type == 4) {
String extend=sourceBean.getExt(); String extend=sourceBean.getExt();
extend=getFixUrl(extend); extend=getFixUrl(extend);
OkGo.<String>get(sourceBean.getApi())
.params("play", url) GetRequest<String> request = OkGo.<String>get(sourceBean.getApi())
.params("flag" ,playFlag) .tag("play")
.params("extend", extend) .params("play", url)
.tag("play") .params("flag" ,playFlag);
.execute(new AbsCallback<String>() { // 当 extend 不为空且非空字符串时添加参数
if (extend != null && !extend.isEmpty()) {
request.params("extend", extend);
}
request.execute(new AbsCallback<String>() {
@Override @Override
public String convertResponse(okhttp3.Response response) throws Throwable { public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) { if (response.body() != null) {

Loading…
Cancel
Save