use of com.xinshang.audient.model.entities.Favorite in project Audient by komamj.
the class MyFavoritesAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(MyFavoritesVH holder, int position) {
Favorite favorite = mData.get(position);
mGlideRequest.load(favorite.coverImageUrl).into(holder.mImage);
holder.mName.setText(favorite.favoriteName);
holder.mCount.setText(mContext.getResources().getQuantityString(R.plurals.song_count, favorite.itemCount, favorite.itemCount));
}
use of com.xinshang.audient.model.entities.Favorite in project Audient by komamj.
the class MyFavoritesFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
LogUtils.i(TAG, "onViewCreated");
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (mPresenter != null) {
mPresenter.loadMyFavorites();
}
}
});
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryDark, R.color.colorPrimary);
setLoadingIndicator(true);
mAdapter = new MyFavoritesAdapter(mContext);
mAdapter.setListener(new MyFavoritesAdapter.EventListener() {
@Override
public void onItemClick(Favorite favorite) {
if (mPresenter != null) {
mPresenter.addToFavorite(favorite.favoritesId, mAudient);
}
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.addItemDecoration(new AudientItemDecoration(mContext));
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);
if (mPresenter != null) {
mPresenter.loadMyFavorites();
}
}
use of com.xinshang.audient.model.entities.Favorite in project Audient by komamj.
the class FavoriteAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(FavoriteViewHolder holder, int position) {
Favorite favorite = mData.get(position);
mGlideRequest.load(favorite.coverImageUrl).into(holder.mFavoriteImage);
holder.mFavoriteName.setText(favorite.favoriteName);
}
use of com.xinshang.audient.model.entities.Favorite 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.Favorite 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