识别jarCache

示例: {"spider":"./spider.jar","jarCache":"false"}
方便调试的时候关闭缓存
pull/144/head
于俊 9 months ago
parent 1c8c740f29
commit ca6cba6abb
  1. 4
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 35
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java

@ -321,7 +321,7 @@ public class ApiConfig {
return;
}
}else {
if (cache.exists() && !FileUtils.isWeekAgo(cache)) {
if (Boolean.parseBoolean(jarCache) && cache.exists() && !FileUtils.isWeekAgo(cache)) {
if (jarLoader.load(cache.getAbsolutePath())) {
callback.success();
} else {
@ -415,10 +415,12 @@ public class ApiConfig {
parseJson(apiUrl, sb.toString());
}
private static String jarCache ="true";
private void parseJson(String apiUrl, String jsonStr) {
JsonObject infoJson = gson.fromJson(jsonStr, JsonObject.class);
// spider
spider = DefaultConfig.safeJsonString(infoJson, "spider", "");
jarCache = DefaultConfig.safeJsonString(infoJson, "jarCache", "true");
// wallpaper
wallpaper = DefaultConfig.safeJsonString(infoJson, "wallpaper", "");
// 远端站点源

@ -237,19 +237,20 @@ public class HomeActivity extends BaseActivity {
String jar=ApiConfig.get().getHomeSourceBean().getJar();
String jarUrl=!jar.isEmpty()?jar:ApiConfig.get().getSpider();
File cspCacheDir = new File(cspCachePath + MD5.string2MD5(jarUrl)+".jar");
Toast.makeText(mContext, "jar缓存已清除", Toast.LENGTH_LONG).show();
if (!cspCacheDir.exists()){
Toast.makeText(mContext, "jar缓存已清除", Toast.LENGTH_LONG).show();
return;
}
new Thread(() -> {
try {
FileUtils.deleteFile(cspCacheDir);
ApiConfig.get().clearJarLoader();
refreshHome();
} catch (Exception e) {
e.printStackTrace();
}
}).start();
ApiConfig.get().clearJarLoader();
Toast.makeText(mContext, "jar缓存已清除", Toast.LENGTH_LONG).show();
}else {
jumpActivity(SettingActivity.class);
}
@ -258,16 +259,7 @@ public class HomeActivity extends BaseActivity {
tvName.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if(dataInitOk && jarInitOk){
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean("useCache", true);
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
}else {
jumpActivity(SettingActivity.class);
}
jumpActivity(SettingActivity.class);
return true;
}
});
@ -675,12 +667,7 @@ public class HomeActivity extends BaseActivity {
@Override
public void click(SourceBean value, int pos) {
ApiConfig.get().setSourceBean(value);
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean("useCache", true);
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
refreshHome();
}
@Override
public String getDisplay(SourceBean val) {
@ -699,4 +686,14 @@ public class HomeActivity extends BaseActivity {
}
mSiteSwitchDialog.show();
}
private void refreshHome()
{
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean("useCache", true);
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
}
}

Loading…
Cancel
Save