use of io.github.ryanhoo.music.event.PlayListNowEvent 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.event.PlayListNowEvent in project StylishMusicPlayer by ryanhoo.
the class PlayListDetailsActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Folder folder = getIntent().getParcelableExtra(EXTRA_FOLDER);
mPlayList = getIntent().getParcelableExtra(EXTRA_PLAY_LIST);
if (folder == null && mPlayList == null) {
Log.e(TAG, "onCreate: folder & play list can't be both null!");
finish();
}
if (folder != null) {
isFolder = true;
mPlayList = PlayList.fromFolder(folder);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_list_details);
ButterKnife.bind(this);
supportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(mPlayList.getName());
}
mAdapter = new SongAdapter(this, mPlayList.getSongs());
mAdapter.setActionCallback(this);
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position) {
RxBus.getInstance().post(new PlayListNowEvent(mPlayList, position));
}
});
recyclerView.setAdapter(mAdapter);
recyclerView.addItemDecoration(new DefaultDividerDecoration());
emptyView.setVisibility(mPlayList.getNumOfSongs() > 0 ? View.GONE : View.VISIBLE);
new PlayListDetailsPresenter(AppRepository.getInstance(), this).subscribe();
}
Aggregations