Search in sources :

Example 1 with AbsSmartPlaylist

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;
    }
}
Also used : LastAddedPlaylist(com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist) Playlist(com.kabouzeid.gramophone.model.Playlist) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist)

Example 2 with AbsSmartPlaylist

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();
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Html(android.text.Html) Dialog(android.app.Dialog) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) R(com.kabouzeid.gramophone.R) DialogFragment(androidx.fragment.app.DialogFragment) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist) NonNull(androidx.annotation.NonNull)

Example 3 with AbsSmartPlaylist

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));
    }
}
Also used : LastAddedPlaylist(com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist) Playlist(com.kabouzeid.gramophone.model.Playlist) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist)

Example 4 with AbsSmartPlaylist

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;
    }
}
Also used : LastAddedPlaylist(com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist) Playlist(com.kabouzeid.gramophone.model.Playlist) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist) AbsSmartPlaylist(com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist)

Aggregations

AbsSmartPlaylist (com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist)4 AbsCustomPlaylist (com.kabouzeid.gramophone.model.AbsCustomPlaylist)3 Playlist (com.kabouzeid.gramophone.model.Playlist)3 LastAddedPlaylist (com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist)3 Dialog (android.app.Dialog)1 Bundle (android.os.Bundle)1 Html (android.text.Html)1 NonNull (androidx.annotation.NonNull)1 DialogFragment (androidx.fragment.app.DialogFragment)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 R (com.kabouzeid.gramophone.R)1