2 * Copyright (C) 2014 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.cyanogenmod.eleven.utils;
19 import android.app.Activity;
20 import android.provider.MediaStore;
21 import android.support.v4.app.FragmentManager;
23 import com.cyanogenmod.eleven.menu.DeleteDialog;
24 import com.cyanogenmod.eleven.menu.FragmentMenuItems;
25 import com.cyanogenmod.eleven.model.Song;
27 import java.util.TreeSet;
29 public abstract class SongPopupMenuHelper extends PopupMenuHelper {
32 public SongPopupMenuHelper(Activity activity, FragmentManager fragmentManager) {
33 super(activity, fragmentManager);
36 public abstract Song getSong(int position);
39 public PopupMenuHelper.PopupMenuType onPreparePopupMenu(int position) {
40 mSong = getSong(position);
46 return PopupMenuType.Song;
50 protected void playAlbum() {
51 MusicUtils.playAlbum(mActivity, mSong.mAlbumId, 0, false);
55 protected long[] getIdList() {
56 return new long[] { mSong.mSongId };
60 protected String getArtistName() {
61 return mSong.mArtistName;
65 protected void onDeleteClicked() {
66 DeleteDialog.newInstance(mSong.mSongName, getIdList(), null)
67 .show(mFragmentManager, "DeleteDialog");
71 protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
72 super.updateMenuIds(type, set);
74 // Don't show more by artist if it is an unknown artist
75 if (MediaStore.UNKNOWN_STRING.equals(mSong.mArtistName)) {
76 set.remove(FragmentMenuItems.MORE_BY_ARTIST);