Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Oct 17, 2021
1 parent 46a3559 commit 9b1a43f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

public class BookListPresenter extends BasePresenterImpl<BookListContract.View> implements BookListContract.Presenter {
private int threadsNum = 6;
private int refreshIndex;
private List<BookShelfBean> bookShelfBeans;
private int group;
private boolean hasUpdate = false;
private List<String> errBooks = new ArrayList<>();
private CompositeDisposable compositeDisposable = new CompositeDisposable();
private final List<String> errBooks = new ArrayList<>();
private final CompositeDisposable compositeDisposable = new CompositeDisposable();

@Override
public void queryBookShelf(final Boolean needRefresh, final int group) {
Expand All @@ -68,20 +69,17 @@ public void queryBookShelf(final Boolean needRefresh, final int group) {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new MyObserver<List<BookShelfBean>>() {
@Override
public void onNext(List<BookShelfBean> value) {
if (null != value) {
bookShelfBeans = value;
mView.refreshBookShelf(bookShelfBeans);
if (needRefresh && NetworkUtils.isNetWorkAvailable()) {
startRefreshBook();
}
public void onNext(@NonNull List<BookShelfBean> 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);
}
});
}
Expand Down Expand Up @@ -139,12 +137,12 @@ private synchronized void refreshBookshelf() {
.compose(RxUtils::toSimpleSingle)
.subscribe(new Observer<BookShelfBean>() {
@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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ interface View extends IView {

void refreshBook(String noteUrl);

/**
* 刷新错误
*
* @param error 错误
*/
void refreshError(String error);

SharedPreferences getPreferences();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9b1a43f

Please sign in to comment.