diff --git a/app/src/main/java/com/fongmi/android/tv/api/config/WallConfig.java b/app/src/main/java/com/fongmi/android/tv/api/config/WallConfig.java index e6e242c67..3ed4a9c4e 100644 --- a/app/src/main/java/com/fongmi/android/tv/api/config/WallConfig.java +++ b/app/src/main/java/com/fongmi/android/tv/api/config/WallConfig.java @@ -24,6 +24,7 @@ import com.github.catvod.utils.Path; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.InterruptedIOException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; @@ -68,7 +69,7 @@ public class WallConfig { } private boolean isCanceled(Throwable e) { - return e instanceof InterruptedException || e instanceof RuntimeException; + return "Canceled".equals(e.getMessage()) || e instanceof InterruptedException || e.getCause() instanceof InterruptedIOException; } public void load() { @@ -85,7 +86,7 @@ public class WallConfig { private void loadConfig(int id, Config config, Callback callback) { try { OkHttp.cancel(TAG); - download(id, callback); + download(id, config.getUrl(), callback); if (taskId.get() == id) config.update(); } catch (Throwable e) { e.printStackTrace(); @@ -98,10 +99,10 @@ public class WallConfig { } } - private void download(int id, Callback callback) throws Throwable { + private void download(int id, String url, Callback callback) throws Throwable { File file = FileUtil.getWall(0); - if (getUrl().startsWith("file")) Path.copy(Path.local(getUrl()), file); - else Download.create(UrlUtil.convert(getUrl()), file).tag(TAG).get(); + if (url.startsWith("file")) Path.copy(Path.local(url), file); + else Download.create(UrlUtil.convert(url), file).tag(TAG).get(); if (!Path.exists(file)) throw new FileNotFoundException(); if (taskId.get() != id) return; setWallType(file); diff --git a/app/src/main/java/com/fongmi/android/tv/utils/Download.java b/app/src/main/java/com/fongmi/android/tv/utils/Download.java index e865e35a9..e2ec4a5fa 100644 --- a/app/src/main/java/com/fongmi/android/tv/utils/Download.java +++ b/app/src/main/java/com/fongmi/android/tv/utils/Download.java @@ -58,7 +58,7 @@ public class Download { try (Response res = OkHttp.newCall(url, tag).execute()) { download(res.body().byteStream(), getLength(res)); if (callback != null) App.post(() -> callback.success(file)); - } catch (IOException e) { + } catch (Exception e) { Path.clear(file); if (callback != null) App.post(() -> callback.error(e.getMessage())); else throw new RuntimeException(e.getMessage(), e);