Search in sources :

Example 1 with MediaUpdateEvent

use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.

the class ArtistFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.loadArtists(action);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) Subscription(rx.Subscription)

Example 2 with MediaUpdateEvent

use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.

the class SearchFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.search(queryString);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) Subscription(rx.Subscription)

Example 3 with MediaUpdateEvent

use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.

the class SongsFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.loadSongs(action);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) Subscription(rx.Subscription)

Example 4 with MediaUpdateEvent

use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.

the class FolderAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            int adapterPosition = itemHolder.getAdapterPosition();
            final FolderInfo folderInfo = arraylist.get(adapterPosition);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_folder_addto_queue:
                            getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Folder);
                                }
                            });
                            break;
                        case R.id.popup_folder_addto_playlist:
                            getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    ListenerUtil.showAddPlaylistDialog(mContext, ids);
                                }
                            });
                            break;
                        case R.id.popup_folder_delete:
                            new MaterialDialog.Builder(mContext).title(mContext.getResources().getString(R.string.delete_folder)).content("删除文件夹下" + folderInfo.songCount + "首歌曲?").positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                        @Override
                                        public void call(long[] ids) {
                                            ListenerUtil.deleteTracks(mContext, ids);
                                            RxBus.getInstance().post(new MediaUpdateEvent());
                                        }
                                    });
                                }
                            }).onNegative(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            }).show();
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_folder);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Action1(rx.functions.Action1) MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) FastScrollRecyclerView(io.hefuyi.listener.widget.fastscroller.FastScrollRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) FolderInfo(io.hefuyi.listener.mvp.model.FolderInfo) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) PopupMenu(android.widget.PopupMenu)

Example 5 with MediaUpdateEvent

use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.

the class AlbumFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.loadAlbums(action);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) Subscription(rx.Subscription)

Aggregations

MediaUpdateEvent (io.hefuyi.listener.event.MediaUpdateEvent)5 Subscription (rx.Subscription)4 NonNull (android.support.annotation.NonNull)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 PopupMenu (android.widget.PopupMenu)1 TextView (android.widget.TextView)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 FolderInfo (io.hefuyi.listener.mvp.model.FolderInfo)1 FastScrollRecyclerView (io.hefuyi.listener.widget.fastscroller.FastScrollRecyclerView)1 Action1 (rx.functions.Action1)1