use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListDetailsActivity method onAction.
// Adapter Action Callback
@Override
public void onAction(View actionView, final int position) {
final Song song = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(this, actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.music_action);
actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(!isFolder);
actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_item_add_to_play_list:
new AddToPlayListDialogFragment().setCallback(new AddToPlayListDialogFragment.Callback() {
@Override
public void onPlayListSelected(PlayList playList) {
if (playList.getId() == mPlayList.getId())
return;
mPresenter.addSongToPlayList(song, playList);
}
}).show(getSupportFragmentManager().beginTransaction(), "AddToPlayList");
break;
case R.id.menu_item_delete:
mDeleteIndex = position;
mPresenter.delete(song, mPlayList);
break;
}
return true;
}
});
actionMenu.show();
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListDetailsPresenter method addSongToPlayList.
@Override
public void addSongToPlayList(Song song, PlayList playList) {
if (playList.isFavorite()) {
song.setFavorite(true);
}
playList.addSong(song, 0);
Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {
@Override
public void onStart() {
mView.showLoading();
}
@Override
public void onCompleted() {
mView.hideLoading();
}
@Override
public void onError(Throwable e) {
mView.hideLoading();
mView.handleError(e);
}
@Override
public void onNext(PlayList playList) {
RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
}
});
mSubscriptions.add(subscription);
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListPresenter method createPlayList.
@Override
public void createPlayList(PlayList playList) {
Subscription subscription = mRepository.create(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {
@Override
public void onStart() {
mView.showLoading();
}
@Override
public void onCompleted() {
mView.hideLoading();
}
@Override
public void onError(Throwable e) {
mView.hideLoading();
mView.handleError(e);
}
@Override
public void onNext(PlayList result) {
mView.onPlayListCreated(result);
}
});
mSubscriptions.add(subscription);
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListPresenter method loadPlayLists.
@Override
public void loadPlayLists() {
Subscription subscription = mRepository.playLists().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<List<PlayList>>() {
@Override
public void onStart() {
mView.showLoading();
}
@Override
public void onCompleted() {
mView.hideLoading();
}
@Override
public void onError(Throwable e) {
mView.hideLoading();
mView.handleError(e);
}
@Override
public void onNext(List<PlayList> playLists) {
mView.onPlayListsLoaded(playLists);
}
});
mSubscriptions.add(subscription);
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListPresenter method editPlayList.
@Override
public void editPlayList(PlayList playList) {
Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {
@Override
public void onStart() {
mView.showLoading();
}
@Override
public void onCompleted() {
mView.hideLoading();
}
@Override
public void onError(Throwable e) {
mView.hideLoading();
mView.handleError(e);
}
@Override
public void onNext(PlayList result) {
mView.onPlayListEdited(result);
}
});
mSubscriptions.add(subscription);
}
Aggregations