Search in sources :

Example 1 with FolderInfo

use of io.hefuyi.listener.mvp.model.FolderInfo in project ListenerMusicPlayer by hefuyicoder.

the class FolderAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    ItemHolder itemHolder = (ItemHolder) holder;
    FolderInfo localItem = arraylist.get(position);
    Drawable image = mContext.getResources().getDrawable(R.drawable.ic_folder_black_48dp);
    image.setColorFilter(mContext.getResources().getColor(R.color.folderTint), PorterDuff.Mode.SRC_IN);
    itemHolder.image.setImageDrawable(image);
    itemHolder.folderName.setText(localItem.folderName);
    itemHolder.songcount.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount));
    itemHolder.folderPath.setText(localItem.folderPath);
    itemHolder.folderPath.setMaxWidth(DensityUtil.dip2px(mContext, 240));
    setOnPopupMenuListener(itemHolder, position);
}
Also used : Drawable(android.graphics.drawable.Drawable) FolderInfo(io.hefuyi.listener.mvp.model.FolderInfo)

Example 2 with FolderInfo

use of io.hefuyi.listener.mvp.model.FolderInfo in project ListenerMusicPlayer by hefuyicoder.

the class FolderPresenter method loadFolders.

@Override
public void loadFolders() {
    mCompositeSubscription.clear();
    Subscription subscription = mUsecase.execute(new GetFolders.RequestValues()).getFolderList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<FolderInfo>>() {

        @Override
        public void call(List<FolderInfo> folderInfos) {
            if (folderInfos == null || folderInfos.size() == 0) {
                mView.showEmptyView();
            } else {
                mView.showFolders(folderInfos);
            }
        }
    });
    mCompositeSubscription.add(subscription);
}
Also used : GetFolders(io.hefuyi.listener.mvp.usecase.GetFolders) List(java.util.List) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription) FolderInfo(io.hefuyi.listener.mvp.model.FolderInfo)

Example 3 with FolderInfo

use of io.hefuyi.listener.mvp.model.FolderInfo 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)

Aggregations

FolderInfo (io.hefuyi.listener.mvp.model.FolderInfo)3 Drawable (android.graphics.drawable.Drawable)1 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 MediaUpdateEvent (io.hefuyi.listener.event.MediaUpdateEvent)1 GetFolders (io.hefuyi.listener.mvp.usecase.GetFolders)1 FastScrollRecyclerView (io.hefuyi.listener.widget.fastscroller.FastScrollRecyclerView)1 List (java.util.List)1 Subscription (rx.Subscription)1 Action1 (rx.functions.Action1)1 CompositeSubscription (rx.subscriptions.CompositeSubscription)1