尝试解决jar频繁提示加载失败;

fix搜索界面软键盘的问题;
pull/144/head
于俊 1 year ago
parent 3eaf11f042
commit c30c942e05
  1. 1
      app/src/main/AndroidManifest.xml
  2. 12
      app/src/main/java/com/github/catvod/crawler/JarLoader.java
  3. 13
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  4. 9
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  5. 19
      app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java

@ -59,6 +59,7 @@
android:screenOrientation="sensorLandscape" />
<activity
android:name=".ui.activity.SearchActivity"
android:windowSoftInputMode="stateHidden|adjustResize"
android:screenOrientation="sensorLandscape" />
<activity
android:name=".ui.activity.FastSearchActivity"

@ -124,13 +124,17 @@ public class JarLoader {
File cache = new File(App.getInstance().getFilesDir().getAbsolutePath() + "/csp/" + key + ".jar");
if (!md5.isEmpty()) {
if (cache.exists() && MD5.getFileMd5(cache).equalsIgnoreCase(md5)) {
loadClassLoader(cache.getAbsolutePath(), key);
return classLoaders.get(key);
if(loadClassLoader(cache.getAbsolutePath(), key)){
return classLoaders.get(key);
}else {
return null;
}
}
}else {
if (cache.exists() && !FileUtils.isWeekAgo(cache)) {
loadClassLoader(cache.getAbsolutePath(), key);
return classLoaders.get(key);
if(loadClassLoader(cache.getAbsolutePath(), key)){
return classLoaders.get(key);
}
}
}
try {

@ -327,10 +327,8 @@ public class ApiConfig {
if (Boolean.parseBoolean(jarCache) && cache.exists() && !FileUtils.isWeekAgo(cache)) {
if (jarLoader.load(cache.getAbsolutePath())) {
callback.success();
} else {
callback.error("");
return;
}
return;
}
}
@ -342,7 +340,7 @@ public class ApiConfig {
.execute(new AbsCallback<File>() {
@Override
public File convertResponse(okhttp3.Response response) throws Throwable {
public File convertResponse(okhttp3.Response response){
File cacheDir = cache.getParentFile();
assert cacheDir != null;
if (!cacheDir.exists()) cacheDir.mkdirs();
@ -355,7 +353,8 @@ public class ApiConfig {
LOG.i("echo---jar Response: " + respData);
byte[] imgJar = getImgJar(respData);
if (imgJar == null || imgJar.length == 0) {
throw new IOException("Generated JAR data is empty");
LOG.e("echo---Generated JAR data is empty");
callback.error("JAR data is empty");
}
fos.write(imgJar);
} else {
@ -388,11 +387,11 @@ public class ApiConfig {
}
} catch (Exception e) {
LOG.e("echo---jar Loader threw exception: " + e.getMessage());
callback.error("加载异常: " + e.getMessage());
callback.error("JAR加载异常: " + e.getMessage());
}
} else {
LOG.e("echo---jar File not found");
callback.error("文件不存在");
callback.error("JAR文件不存在");
}
}

@ -320,8 +320,7 @@ public class HomeActivity extends BaseActivity {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// if (!useCacheConfig)
// Toast.makeText(HomeActivity.this, "自定义jar加载成功", Toast.LENGTH_SHORT).show();
// if (!useCacheConfig) Toast.makeText(HomeActivity.this, "自定义jar加载成功", Toast.LENGTH_SHORT).show();
initData();
}
}, 50);
@ -340,13 +339,13 @@ public class HomeActivity extends BaseActivity {
@Override
public void error(String msg) {
jarInitOk = true;
mHandler.post(new Runnable() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(HomeActivity.this, "jar加载失败;尝试加载上一次缓存", Toast.LENGTH_SHORT).show();
Toast.makeText(HomeActivity.this, msg+"; 尝试加载最近一次的jar", Toast.LENGTH_SHORT).show();
initData();
}
});
},50);
}
});
}

@ -103,11 +103,6 @@ public class SearchActivity extends BaseActivity {
isSearchBack = false;
}
public void openSystemKeyBoard() {
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(this.getCurrentFocus(), InputMethodManager.SHOW_FORCED);
}
private List<Runnable> pauseRunnable = null;
@Override
@ -255,10 +250,7 @@ public class SearchActivity extends BaseActivity {
bundle.putString("title", wd);
jumpActivity(FastSearchActivity.class, bundle);
} else {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(etSearch.getWindowToken(), 0);
}
hiddenImm();
search(wd);
}
} else {
@ -282,6 +274,7 @@ public class SearchActivity extends BaseActivity {
bundle.putString("title", wd);
jumpActivity(FastSearchActivity.class, bundle);
} else {
hiddenImm();
search(wd);
}
} else {
@ -602,4 +595,12 @@ public class SearchActivity extends BaseActivity {
}
EventBus.getDefault().unregister(this);
}
private void hiddenImm()
{
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(etSearch.getWindowToken(), 0);
}
}
}
Loading…
Cancel
Save