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);
}
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);
}
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();
}
});
}
Aggregations