use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class MusicPlayerFragment method playSong.
// Music Controls
private void playSong(Song song) {
PlayList playList = new PlayList(song);
playSong(playList, 0);
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class EditPlayListDialogFragment method onConfirm.
private void onConfirm() {
if (mCallback == null)
return;
PlayList playList = mPlayList;
if (playList == null) {
playList = new PlayList();
}
playList.setName(editTextName.getText().toString());
if ((isEditMode())) {
mCallback.onEdited(playList);
} else {
mCallback.onCreated(playList);
}
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListFragment method onAction.
// Adapter Callbacks
@Override
public void onAction(View actionView, final int position) {
final PlayList playList = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(getActivity(), actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.play_list_action);
if (playList.isFavorite()) {
actionMenu.getMenu().findItem(R.id.menu_item_rename).setVisible(false);
actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(false);
}
actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.menu_item_play_now) {
PlayListNowEvent playListNowEvent = new PlayListNowEvent(playList, 0);
RxBus.getInstance().post(playListNowEvent);
} else if (item.getItemId() == R.id.menu_item_rename) {
mEditIndex = position;
EditPlayListDialogFragment.editPlayList(playList).setCallback(PlayListFragment.this).show(getFragmentManager().beginTransaction(), "EditPlayList");
} else if (item.getItemId() == R.id.menu_item_delete) {
mDeleteIndex = position;
mPresenter.deletePlayList(playList);
}
return true;
}
});
actionMenu.show();
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
mAdapter = new PlayListAdapter(getActivity(), null);
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position) {
PlayList playList = mAdapter.getItem(position);
startActivity(PlayListDetailsActivity.launchIntentForPlayList(getActivity(), playList));
}
});
mAdapter.setAddPlayListCallback(this);
recyclerView.setAdapter(mAdapter);
recyclerView.addItemDecoration(new DefaultDividerDecoration());
new PlayListPresenter(AppRepository.getInstance(), this).subscribe();
}
use of io.github.ryanhoo.music.data.model.PlayList in project StylishMusicPlayer by ryanhoo.
the class PlayListDetailsPresenter method delete.
@Override
public void delete(final Song song, PlayList playList) {
playList.removeSong(song);
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) {
mView.onSongDeleted(song);
RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
}
});
mSubscriptions.add(subscription);
}
Aggregations