use of io.hefuyi.listener.mvp.model.Album in project ListenerMusicPlayer by hefuyicoder.
the class AlbumsPresenter method loadAlbums.
@Override
public void loadAlbums(String action) {
mCompositeSubscription.clear();
Subscription subscription = mUsecase.execute(new GetAlbums.RequestValues(action)).getSongList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Album>>() {
@Override
public void call(List<Album> albumList) {
if (albumList == null || albumList.size() == 0) {
mView.showEmptyView();
} else {
mView.showAlbums(albumList);
}
}
});
mCompositeSubscription.add(subscription);
}
use of io.hefuyi.listener.mvp.model.Album in project ListenerMusicPlayer by hefuyicoder.
the class ArtistAlbumLoader method getAlbumsForArtist.
public static Observable<List<Album>> getAlbumsForArtist(final Context context, final long artistID) {
return Observable.create(new Observable.OnSubscribe<List<Album>>() {
@Override
public void call(Subscriber<? super List<Album>> subscriber) {
List<Album> albumList = new ArrayList<Album>();
Cursor cursor = makeAlbumForArtistCursor(context, artistID);
if (cursor != null) {
if (cursor.moveToFirst())
do {
Album album = new Album(cursor.getLong(0), cursor.getString(1), cursor.getString(2), artistID, cursor.getInt(3), cursor.getInt(4));
albumList.add(album);
} while (cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
subscriber.onNext(albumList);
subscriber.onCompleted();
}
});
}
use of io.hefuyi.listener.mvp.model.Album in project ListenerMusicPlayer by hefuyicoder.
the class AlbumAdapter method setOnPopupMenuListener.
private void setOnPopupMenuListener(final AlbumAdapter.ItemHolder itemHolder, final int position) {
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
int adapterPosition = itemHolder.getAdapterPosition();
final Album album = arraylist.get(adapterPosition);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_album_addto_queue:
getSongListIdByAlbum(arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.NA);
}
});
break;
case R.id.popup_album_addto_playlist:
getSongListIdByAlbum(arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showAddPlaylistDialog(mContext, ids);
}
});
break;
case R.id.popup_album_goto_artist:
NavigationUtil.goToArtist(mContext, arraylist.get(position).artistId, arraylist.get(position).artistName);
break;
case R.id.popup_artist_delete:
switch(action) {
case Constants.NAVIGATE_PLAYLIST_FAVOURATE:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showDeleteFromFavourate(mContext, ids);
}
});
break;
case Constants.NAVIGATE_PLAYLIST_RECENTPLAY:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showDeleteFromRecentlyPlay(mContext, ids);
}
});
break;
default:
AlbumSongLoader.getSongsForAlbum(mContext, arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {
@Override
public void call(List<Song> songs) {
long[] ids = new long[songs.size()];
int i = 0;
for (Song song : songs) {
ids[i] = song.id;
i++;
}
if (ids.length == 1) {
ListenerUtil.showDeleteDialog(mContext, songs.get(0).title, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
arraylist.remove(position);
notifyDataSetChanged();
}
});
} else {
String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, arraylist.get(position).songCount);
ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
arraylist.remove(position);
notifyDataSetChanged();
}
});
}
}
});
break;
}
break;
}
return false;
}
});
menu.inflate(R.menu.popup_album);
menu.show();
}
});
}
use of io.hefuyi.listener.mvp.model.Album in project ListenerMusicPlayer by hefuyicoder.
the class ArtistAlbumAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
Album localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.details.setText(songCount);
Glide.with(mContext).load(ListenerUtil.getAlbumArtUri(localItem.id).toString()).diskCacheStrategy(DiskCacheStrategy.SOURCE).error(ATEUtil.getDefaultAlbumDrawable(mContext)).centerCrop().into(itemHolder.albumArt);
if (ListenerUtil.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of io.hefuyi.listener.mvp.model.Album in project ListenerMusicPlayer by hefuyicoder.
the class SearchAdapter method setAlbumPopupMenu.
private void setAlbumPopupMenu(ItemHolder itemHolder, final int position) {
final Album album = (Album) searchResults.get(position);
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_album_addto_queue:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.NA);
}
});
break;
case R.id.popup_album_addto_playlist:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showAddPlaylistDialog(mContext, ids);
}
});
break;
case R.id.popup_album_goto_artist:
NavigationUtil.goToArtist(mContext, album.artistId, album.artistName);
break;
case R.id.popup_artist_delete:
AlbumSongLoader.getSongsForAlbum(mContext, album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {
@Override
public void call(List<Song> songs) {
long[] ids = new long[songs.size()];
int i = 0;
for (Song song : songs) {
ids[i] = song.id;
i++;
}
if (ids.length == 1) {
ListenerUtil.showDeleteDialog(mContext, songs.get(0).title, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
searchResults.remove(position);
notifyDataSetChanged();
}
});
} else {
String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, album.songCount);
ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
searchResults.remove(position);
notifyDataSetChanged();
}
});
}
}
});
break;
}
return false;
}
});
menu.inflate(R.menu.popup_album);
menu.show();
}
});
}
Aggregations