use of com.xinshang.audient.model.entities.FavoritesResult in project Audient by komamj.
the class MinePresenter method loadFavorites.
@Override
public void loadFavorites() {
LogUtils.i(TAG, "loadFavorites");
Disposable disposable = mRepository.getFavoriteResult().map(new Function<FavoritesResult, List<Favorite>>() {
@Override
public List<Favorite> apply(FavoritesResult favoriteResult) throws Exception {
return favoriteResult.favorites;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Favorite>>() {
@Override
public void onNext(List<Favorite> favorites) {
LogUtils.i(TAG, "loadfavorites " + favorites.toString());
if (mView.isActive()) {
mView.showFavorites(favorites);
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadFavorites error " + t.toString());
if (mView.isActive()) {
mView.showFavoriteProgressBar(false);
}
}
@Override
public void onComplete() {
if (mView.isActive()) {
mView.showFavoriteProgressBar(false);
}
}
});
mDisposables.add(disposable);
}
use of com.xinshang.audient.model.entities.FavoritesResult in project Audient by komamj.
the class MyFavoritesPresenter method loadMyFavorites.
@Override
public void loadMyFavorites() {
Disposable disposable = mRepository.getFavoriteResult().map(new Function<FavoritesResult, List<Favorite>>() {
@Override
public List<Favorite> apply(FavoritesResult favoriteResult) throws Exception {
return favoriteResult.favorites;
}
}).doOnNext(new Consumer<List<Favorite>>() {
@Override
public void accept(List<Favorite> favorites) throws Exception {
LogUtils.i(TAG, "loadFavorites thread name :" + Thread.currentThread().getName() + "," + favorites.isEmpty());
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Favorite>>() {
@Override
public void onNext(List<Favorite> favorites) {
LogUtils.i(TAG, "loadfavorites " + favorites.toString());
if (mView.isActive()) {
mView.setLoadingIndicator(false);
mView.showFavorites(favorites);
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadFavorites error " + t.toString());
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
Aggregations