From afcaa6ad95dca5c83f46750ae9266b7cfad11289 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Tue, 2 Aug 2022 08:22:43 +0800 Subject: [PATCH] fix font download --- .../xyz/fycz/myreader/webapi/LanZousApi.java | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java index 127a87c..0928e66 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java @@ -32,6 +32,7 @@ import io.reactivex.SingleOnSubscribe; import okhttp3.MediaType; import okhttp3.RequestBody; import xyz.fycz.myreader.application.App; +import xyz.fycz.myreader.base.observer.MyObserver; import xyz.fycz.myreader.base.observer.MySingleObserver; import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.util.help.StringHelper; @@ -51,40 +52,23 @@ public class LanZousApi { * @param callback */ public static void getUrl(final String lanZouUrl, final ResultCallback callback) { - LanZousApi.getUrl1(lanZouUrl, new ResultCallback() { - @Override - public void onFinish(final Object o, int code) { - LanZousApi.getKey((String) o, new ResultCallback() { - final String referer = (String) o; + getUrl(lanZouUrl, "", callback); + } + public static void getUrl(final String lanZouUrl, String password, final ResultCallback callback) { + LanZouApi.INSTANCE.getFileUrl(lanZouUrl, "") + .compose(RxUtils::toSimpleSingle) + .subscribe(new MyObserver() { @Override - public void onFinish(Object o, int code) { - LanZousApi.getUrl2((String) o, new ResultCallback() { - @Override - public void onFinish(Object o, int code) { - LanZousApi.getRedirectUrl((String) o, callback); - } - - @Override - public void onError(Exception e) { - callback.onError(e); - } - }, referer); + public void onNext(String s) { + callback.onFinish(s, 1); } @Override - public void onError(Exception e) { - callback.onError(e); + public void onError(Throwable e) { + callback.onError((Exception) e); } }); - } - - @Override - public void onError(Exception e) { - callback.onError(e); - } - }); - }