Search in sources :

Example 1 with PlayList

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);
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList)

Example 2 with PlayList

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);
    }
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList)

Example 3 with 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();
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListNowEvent(io.github.ryanhoo.music.event.PlayListNowEvent) PopupMenu(android.support.v7.widget.PopupMenu)

Example 4 with PlayList

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();
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)

Example 5 with PlayList

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);
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListUpdatedEvent(io.github.ryanhoo.music.event.PlayListUpdatedEvent) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Aggregations

PlayList (io.github.ryanhoo.music.data.model.PlayList)16 Subscription (rx.Subscription)8 CompositeSubscription (rx.subscriptions.CompositeSubscription)8 PopupMenu (android.support.v7.widget.PopupMenu)3 PlayListUpdatedEvent (io.github.ryanhoo.music.event.PlayListUpdatedEvent)3 Song (io.github.ryanhoo.music.data.model.Song)2 AddToPlayListDialogFragment (io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment)2 MenuItem (android.view.MenuItem)1 Folder (io.github.ryanhoo.music.data.model.Folder)1 PlayListNowEvent (io.github.ryanhoo.music.event.PlayListNowEvent)1 OnItemClickListener (io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener)1 DefaultDividerDecoration (io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)1 EditPlayListDialogFragment (io.github.ryanhoo.music.ui.playlist.EditPlayListDialogFragment)1 List (java.util.List)1