From 9b1a43f00670348874f845f9ec07d59240d6a127 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 17 Oct 2021 18:01:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +++++ .../presenter/BookListPresenter.java | 26 +++++++++---------- .../presenter/contract/BookListContract.java | 7 ----- .../view/fragment/BookListFragment.java | 5 ---- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c49b6a10c8..2a8ae95d4c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,12 @@ dependencies { implementation 'androidx.media:media:1.4.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' + //Splitties + def splitties_version = '3.0.0' + implementation("com.louiscad.splitties:splitties-appctx:$splitties_version") + implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version") + implementation("com.louiscad.splitties:splitties-views:$splitties_version") + def exoplayer_version = '2.15.0' implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version" implementation "com.google.android.exoplayer:extension-okhttp:$exoplayer_version" diff --git a/app/src/main/java/com/kunfei/bookshelf/presenter/BookListPresenter.java b/app/src/main/java/com/kunfei/bookshelf/presenter/BookListPresenter.java index f65e958ce0..1b928d07f2 100644 --- a/app/src/main/java/com/kunfei/bookshelf/presenter/BookListPresenter.java +++ b/app/src/main/java/com/kunfei/bookshelf/presenter/BookListPresenter.java @@ -37,6 +37,7 @@ import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; +import timber.log.Timber; public class BookListPresenter extends BasePresenterImpl implements BookListContract.Presenter { private int threadsNum = 6; @@ -44,8 +45,8 @@ public class BookListPresenter extends BasePresenterImpl private List bookShelfBeans; private int group; private boolean hasUpdate = false; - private List errBooks = new ArrayList<>(); - private CompositeDisposable compositeDisposable = new CompositeDisposable(); + private final List errBooks = new ArrayList<>(); + private final CompositeDisposable compositeDisposable = new CompositeDisposable(); @Override public void queryBookShelf(final Boolean needRefresh, final int group) { @@ -68,20 +69,17 @@ public void queryBookShelf(final Boolean needRefresh, final int group) { .observeOn(AndroidSchedulers.mainThread()) .subscribe(new MyObserver>() { @Override - public void onNext(List value) { - if (null != value) { - bookShelfBeans = value; - mView.refreshBookShelf(bookShelfBeans); - if (needRefresh && NetworkUtils.isNetWorkAvailable()) { - startRefreshBook(); - } + public void onNext(@NonNull List value) { + bookShelfBeans = value; + mView.refreshBookShelf(bookShelfBeans); + if (needRefresh && NetworkUtils.isNetWorkAvailable()) { + startRefreshBook(); } } @Override public void onError(Throwable e) { - e.printStackTrace(); - mView.refreshError(NetworkUtils.getErrorTip(NetworkUtils.ERROR_CODE_ANALY)); + Timber.d(e); } }); } @@ -139,12 +137,12 @@ private synchronized void refreshBookshelf() { .compose(RxUtils::toSimpleSingle) .subscribe(new Observer() { @Override - public void onSubscribe(Disposable d) { + public void onSubscribe(@NonNull Disposable d) { compositeDisposable.add(d); } @Override - public void onNext(BookShelfBean value) { + public void onNext(@NonNull BookShelfBean value) { if (value.getErrorMsg() != null) { mView.toast(value.getErrorMsg()); value.setErrorMsg(null); @@ -157,7 +155,7 @@ public void onNext(BookShelfBean value) { } @Override - public void onError(Throwable e) { + public void onError(@NonNull Throwable e) { if (!(e instanceof WebBook.NoSourceThrowable)) { errBooks.add(bookShelfBean.getBookInfoBean().getName()); bookShelfBean.setLoading(false); diff --git a/app/src/main/java/com/kunfei/bookshelf/presenter/contract/BookListContract.java b/app/src/main/java/com/kunfei/bookshelf/presenter/contract/BookListContract.java index ed5e0eff39..4b3ff0cbcf 100644 --- a/app/src/main/java/com/kunfei/bookshelf/presenter/contract/BookListContract.java +++ b/app/src/main/java/com/kunfei/bookshelf/presenter/contract/BookListContract.java @@ -21,13 +21,6 @@ interface View extends IView { void refreshBook(String noteUrl); - /** - * 刷新错误 - * - * @param error 错误 - */ - void refreshError(String error); - SharedPreferences getPreferences(); /** diff --git a/app/src/main/java/com/kunfei/bookshelf/view/fragment/BookListFragment.java b/app/src/main/java/com/kunfei/bookshelf/view/fragment/BookListFragment.java index 0d787b5e69..51cd462266 100644 --- a/app/src/main/java/com/kunfei/bookshelf/view/fragment/BookListFragment.java +++ b/app/src/main/java/com/kunfei/bookshelf/view/fragment/BookListFragment.java @@ -225,11 +225,6 @@ public void updateGroup(Integer group) { this.group = group; } - @Override - public void refreshError(String error) { - toast(error); - } - @Override public SharedPreferences getPreferences() { return preferences;