Skip to content

Commit

Permalink
1.删除冗余 2.修改默认配置 3.修改版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
xin.li committed Jan 29, 2023
1 parent 5ed813f commit 4e3c202
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 437 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId 'com.github.tvbox.osc.tk'
minSdkVersion 16
targetSdkVersion 33
versionCode 1
versionName "1.0.".concat(buildTime())
versionCode 20000
versionName "2.0.0_".concat(buildTime())
multiDexEnabled true
//设置room的Schema的位置
javaCompileOptions {
Expand Down
34 changes: 10 additions & 24 deletions app/src/main/java/com/github/catvod/crawler/JarLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ private boolean loadClassLoader(String jar, String key) {
boolean success = false;
try {
File cacheDir = new File(App.getInstance().getCacheDir().getAbsolutePath() + "/catvod_csp");
if (!cacheDir.exists())
cacheDir.mkdirs();
if (!cacheDir.exists()) cacheDir.mkdirs();
DexClassLoader classLoader = new DexClassLoader(jar, cacheDir.getAbsolutePath(), null, App.getInstance().getClassLoader());
// make force wait here, some device async dex load
int count = 0;
Expand All @@ -72,10 +71,7 @@ private boolean loadClassLoader(String jar, String key) {
}
count++;
} while (count < 5);

if (success) {
classLoaders.put(key, classLoader);
}
if (success) classLoaders.put(key, classLoader);
} catch (Throwable th) {
th.printStackTrace();
}
Expand All @@ -99,9 +95,7 @@ private DexClassLoader loadJarInternal(String jar, String md5, String key) {
try {
byte[] buffer = new byte[2048];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
while ((length = is.read(buffer)) > 0) os.write(buffer, 0, length);
} finally {
try {
is.close();
Expand Down Expand Up @@ -134,20 +128,15 @@ public Spider getSpider(String key, String cls, String ext, String jar) {
recentJarKey = jarKey;
if (spiders.containsKey(key))
return spiders.get(key);
DexClassLoader classLoader = null;
if (jarKey.equals("main"))
classLoader = classLoaders.get("main");
else {
classLoader = loadJarInternal(jarUrl, jarMd5, jarKey);
}
if (classLoader == null)
return new SpiderNull();
DexClassLoader classLoader;
if (jarKey.equals("main")) classLoader = classLoaders.get("main");
else classLoader = loadJarInternal(jarUrl, jarMd5, jarKey);
if (classLoader == null) return new SpiderNull();
try {
Spider sp = (Spider) classLoader.loadClass("com.github.catvod.spider." + clsKey).newInstance();
sp.init(App.getInstance(), ext);
if (!jar.isEmpty()) {
sp.homeContent(false); // 增加此行 应该可以解决部分写的有问题源的历史记录问题 但会增加这个源的首次加载时间 不需要可以已删掉
}
// 增加此行 应该可以解决部分写的有问题源的历史记录问题 但会增加这个源的首次加载时间 不需要可以已删掉
if (!jar.isEmpty()) sp.homeContent(false);
spiders.put(key, sp);
return sp;
} catch (Throwable th) {
Expand Down Expand Up @@ -187,11 +176,8 @@ public JSONObject jsonExtMix(String flag, String key, String name, LinkedHashMap
public Object[] proxyInvoke(Map params) {
try {
Method proxyFun = proxyMethods.get(recentJarKey);
if (proxyFun != null) {
return (Object[]) proxyFun.invoke(null, params);
}
if (proxyFun != null) return (Object[]) proxyFun.invoke(null, params);
} catch (Throwable ignored) {

}
return null;
}
Expand Down
14 changes: 4 additions & 10 deletions app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,10 @@ public void loadJar(boolean useCache, String spider, LoadConfigCallback callback
String jarUrl = urls[0];
String md5 = urls.length > 1 ? urls[1].trim() : "";
File cache = new File(App.getInstance().getFilesDir().getAbsolutePath() + "/csp.jar");

if (!md5.isEmpty() || useCache) {
if (cache.exists() && (useCache || MD5.getFileMd5(cache).equalsIgnoreCase(md5))) {
if (jarLoader.load(cache.getAbsolutePath())) {
callback.success();
} else {
callback.error("");
}
if (jarLoader.load(cache.getAbsolutePath())) callback.success();
else callback.error("");
return;
}
}
Expand Down Expand Up @@ -295,10 +291,8 @@ private void parseJson(String apiUrl, File f) throws Throwable {
System.out.println("从本地缓存加载" + f.getAbsolutePath());
BufferedReader bReader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
StringBuilder sb = new StringBuilder();
String s = "";
while ((s = bReader.readLine()) != null) {
sb.append(s + "\n");
}
String s;
while ((s = bReader.readLine()) != null) sb.append(s).append("\n");
bReader.close();
parseJson(apiUrl, sb.toString());
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/github/tvbox/osc/base/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import androidx.multidex.MultiDexApplication;

import com.github.tvbox.osc.BuildConfig;
import com.github.tvbox.osc.callback.EmptyCallback;
import com.github.tvbox.osc.callback.LoadingCallback;
import com.github.tvbox.osc.data.AppDataManager;
Expand Down Expand Up @@ -65,10 +64,11 @@ private void initParams() {
putDefault(HawkConfig.PLAY_TYPE, 1); // Player 0=系统, 1=IJK, 2=Exo
putDefault(HawkConfig.IJK_CODEC, "硬解码");// IJK Render 软解码, 硬解码
putDefault(HawkConfig.HOME_SHOW_SOURCE, true);// 数据源
putDefault(HawkConfig.API_URL, "http://0zark.0zark.io/eth/tv/m.json");
putDefault(HawkConfig.LIVE_URL, "http://0zark.0zark.io/eth/tv/live_plus.txt");
// putDefault(HawkConfig.HOME_NUM, 2); // History Number
// putDefault(HawkConfig.DOH_URL, 2); // DNS
putDefault(HawkConfig.DOH_URL, 1); // DNS
// putDefault(HawkConfig.SEARCH_VIEW, 1); // Text or Picture

}

private void initLocale() {
Expand Down
12 changes: 3 additions & 9 deletions app/src/main/java/com/github/tvbox/osc/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,15 @@ protected void setLoadSir(View view) {
}

protected void showLoading() {
if (mLoadService != null) {
mLoadService.showCallback(LoadingCallback.class);
}
if (mLoadService != null) mLoadService.showCallback(LoadingCallback.class);
}

protected void showEmpty() {
if (null != mLoadService) {
mLoadService.showCallback(EmptyCallback.class);
}
if (null != mLoadService) mLoadService.showCallback(EmptyCallback.class);
}

protected void showSuccess() {
if (null != mLoadService) {
mLoadService.showSuccess();
}
if (null != mLoadService) mLoadService.showSuccess();
}

@Override
Expand Down
Loading

0 comments on commit 4e3c202

Please sign in to comment.