use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class FolderPresenter method addFolderToPlayList.
@Override
public void addFolderToPlayList(final Folder folder, PlayList playList) {
if (folder.getSongs().isEmpty())
return;
if (playList.isFavorite()) {
for (Song song : folder.getSongs()) {
song.setFavorite(true);
}
}
playList.addSong(folder.getSongs(), 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 DBUtils method generateFavoritePlayList.
public static PlayList generateFavoritePlayList(Context context) {
PlayList favorite = new PlayList();
favorite.setFavorite(true);
favorite.setName(context.getString(R.string.mp_play_list_favorite));
return favorite;
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class FolderFragment method onAction.
// Adapter Callbacks
@Override
public void onAction(View actionView, final int position) {
final Folder folder = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(getActivity(), actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.folders_action);
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) {
mPresenter.addFolderToPlayList(folder, playList);
}
}).show(getFragmentManager().beginTransaction(), "AddToPlayList");
break;
case R.id.menu_item_create_play_list:
PlayList playList = PlayList.fromFolder(folder);
EditPlayListDialogFragment.editPlayList(playList).setCallback(new EditPlayListDialogFragment.Callback() {
@Override
public void onCreated(PlayList playList) {
// Empty
}
@Override
public void onEdited(PlayList playList) {
mPresenter.createPlayList(playList);
}
}).show(getFragmentManager().beginTransaction(), "CreatePlayList");
break;
case R.id.menu_item_refresh:
mUpdateIndex = position;
mPresenter.refreshFolder(folder);
break;
case R.id.menu_item_delete:
mDeleteIndex = position;
mPresenter.deleteFolder(folder);
break;
}
return true;
}
});
actionMenu.show();
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class FolderPresenter 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 playList) {
mView.onPlayListCreated(playList);
}
});
mSubscriptions.add(subscription);
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class MusicPlayerFragment method onPlayListNowEvent.
private void onPlayListNowEvent(PlayListNowEvent event) {
PlayList playList = event.playList;
int playIndex = event.playIndex;
playSong(playList, playIndex);
}
Aggregations