use of com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist in project Phonograph by kabouzeid.
the class PlaylistAdapter method onMultipleItemAction.
@Override
protected void onMultipleItemAction(@NonNull MenuItem menuItem, @NonNull ArrayList<Playlist> selection) {
switch(menuItem.getItemId()) {
case R.id.action_delete_playlist:
for (int i = 0; i < selection.size(); i++) {
Playlist playlist = selection.get(i);
if (playlist instanceof AbsSmartPlaylist) {
AbsSmartPlaylist absSmartPlaylist = (AbsSmartPlaylist) playlist;
ClearSmartPlaylistDialog.create(absSmartPlaylist).show(activity.getSupportFragmentManager(), "CLEAR_PLAYLIST_" + absSmartPlaylist.name);
selection.remove(playlist);
i--;
}
}
if (selection.size() > 0) {
DeletePlaylistDialog.create(selection).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
}
break;
default:
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.getItemId());
break;
}
}
use of com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist in project Phonograph by kabouzeid.
the class ClearSmartPlaylistDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// noinspection unchecked
final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist");
int title = R.string.clear_playlist_title;
// noinspection ConstantConditions
CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name));
return new MaterialDialog.Builder(getActivity()).title(title).content(content).positiveText(R.string.clear_action).negativeText(android.R.string.cancel).onPositive((dialog, which) -> {
if (getActivity() == null) {
return;
}
playlist.clear(getActivity());
}).build();
}
use of com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist in project Phonograph by kabouzeid.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final Playlist playlist = dataSet.get(position);
holder.itemView.setActivated(isChecked(playlist));
if (holder.title != null) {
holder.title.setText(playlist.name);
}
if (holder.getAdapterPosition() == getItemCount() - 1) {
if (holder.shortSeparator != null) {
holder.shortSeparator.setVisibility(View.GONE);
}
} else {
if (holder.shortSeparator != null && !(dataSet.get(position) instanceof AbsSmartPlaylist)) {
holder.shortSeparator.setVisibility(View.VISIBLE);
}
}
if (holder.image != null) {
holder.image.setImageResource(getIconRes(playlist));
}
}
use of com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist in project Phonograph by kabouzeid.
the class PlaylistAdapter method onMultipleItemAction.
@Override
protected void onMultipleItemAction(@NonNull MenuItem menuItem, @NonNull List<Playlist> selection) {
switch(menuItem.getItemId()) {
case R.id.action_delete_playlist:
for (int i = 0; i < selection.size(); i++) {
Playlist playlist = selection.get(i);
if (playlist instanceof AbsSmartPlaylist) {
AbsSmartPlaylist absSmartPlaylist = (AbsSmartPlaylist) playlist;
ClearSmartPlaylistDialog.create(absSmartPlaylist).show(activity.getSupportFragmentManager(), "CLEAR_PLAYLIST_" + absSmartPlaylist.name);
selection.remove(playlist);
i--;
}
}
if (selection.size() > 0) {
DeletePlaylistDialog.create(selection).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
}
break;
case R.id.action_save_playlist:
if (selection.size() == 1) {
PlaylistMenuHelper.handleMenuClick(activity, selection.get(0), menuItem);
} else {
new SavePlaylistsAsyncTask(activity).execute(selection);
}
break;
default:
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.getItemId());
break;
}
}
Aggregations