remove smart playlists for now
This commit is contained in:
parent
4458931f22
commit
9180bf548a
8 changed files with 0 additions and 304 deletions
|
|
@ -29,7 +29,6 @@ import com.kabouzeid.gramophone.misc.WeakContextAsyncTask;
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.model.playlist.AbsSmartPlaylist;
|
import com.kabouzeid.gramophone.model.playlist.AbsSmartPlaylist;
|
||||||
import com.kabouzeid.gramophone.model.playlist.LatestPlaylist;
|
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
|
@ -239,10 +238,6 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
||||||
final Playlist playlist = dataSet.get(getAdapterPosition());
|
final Playlist playlist = dataSet.get(getAdapterPosition());
|
||||||
final PopupMenu popupMenu = new PopupMenu(activity, view);
|
final PopupMenu popupMenu = new PopupMenu(activity, view);
|
||||||
popupMenu.inflate(getItemViewType() == SMART_PLAYLIST ? R.menu.menu_item_smart_playlist : R.menu.menu_item_playlist);
|
popupMenu.inflate(getItemViewType() == SMART_PLAYLIST ? R.menu.menu_item_smart_playlist : R.menu.menu_item_playlist);
|
||||||
if (playlist instanceof LatestPlaylist) {
|
|
||||||
popupMenu.getMenu().findItem(R.id.action_clear_playlist).setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
popupMenu.setOnMenuItemClickListener(item -> {
|
popupMenu.setOnMenuItemClickListener(item -> {
|
||||||
if (item.getItemId() == R.id.action_clear_playlist) {
|
if (item.getItemId() == R.id.action_clear_playlist) {
|
||||||
if (playlist instanceof AbsSmartPlaylist) {
|
if (playlist instanceof AbsSmartPlaylist) {
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.loader;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.provider.MediaStore.Audio.Genres;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.model.Genre;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GenreLoader {
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static List<Genre> getAllGenres(@NonNull final Context context) {
|
|
||||||
return getGenresFromCursor(context, makeGenreCursor(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static List<Song> getSongs(@NonNull final Context context, final int genreId) {
|
|
||||||
return SongLoader.getSongs(makeGenreSongCursor(context, genreId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private static List<Genre> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
|
|
||||||
final List<Genre> genres = new ArrayList<>();
|
|
||||||
if (cursor != null) {
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
Genre genre = getGenreFromCursor(context, cursor);
|
|
||||||
if (genre.songCount > 0) {
|
|
||||||
genres.add(genre);
|
|
||||||
} else {
|
|
||||||
// try to remove the empty genre from the media store
|
|
||||||
try {
|
|
||||||
context.getContentResolver().delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
// nothing we can do then
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
return genres;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private static Genre getGenreFromCursor(@NonNull final Context context, @NonNull final Cursor cursor) {
|
|
||||||
final int id = cursor.getInt(0);
|
|
||||||
final String name = cursor.getString(1);
|
|
||||||
final int songs = getSongs(context, id).size();
|
|
||||||
return new Genre(id, name, songs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static Cursor makeGenreSongCursor(@NonNull final Context context, int genreId) {
|
|
||||||
try {
|
|
||||||
return context.getContentResolver().query(
|
|
||||||
Genres.Members.getContentUri("external", genreId),
|
|
||||||
SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance(context).getSongSortOrder());
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static Cursor makeGenreCursor(@NonNull final Context context) {
|
|
||||||
final String[] projection = new String[]{
|
|
||||||
Genres._ID,
|
|
||||||
Genres.NAME
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
return context.getContentResolver().query(
|
|
||||||
Genres.EXTERNAL_CONTENT_URI,
|
|
||||||
projection, null, null, PreferenceUtil.getInstance(context).getGenreSortOrder());
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.model.playlist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.loader.FrequentLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FrequentPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public FrequentPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public List<Song> getSongs(@NonNull Context context) {
|
|
||||||
return FrequentLoader.getFrequent(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
SongPlayCountStore.getInstance(context).clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FrequentPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<FrequentPlaylist> CREATOR = new Creator<FrequentPlaylist>() {
|
|
||||||
public FrequentPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new FrequentPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FrequentPlaylist[] newArray(int size) {
|
|
||||||
return new FrequentPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.model.playlist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.loader.LatestLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LatestPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public LatestPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public List<Song> getSongs(@NonNull Context context) {
|
|
||||||
return LatestLoader.getLatest(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LatestPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<LatestPlaylist> CREATOR = new Creator<LatestPlaylist>() {
|
|
||||||
public LatestPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new LatestPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LatestPlaylist[] newArray(int size) {
|
|
||||||
return new LatestPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.model.playlist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.loader.RecentLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.provider.HistoryStore;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RecentPlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public RecentPlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public List<Song> getSongs(@NonNull Context context) {
|
|
||||||
return RecentLoader.getRecent(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
HistoryStore.getInstance(context).clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected RecentPlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<RecentPlaylist> CREATOR = new Creator<RecentPlaylist>() {
|
|
||||||
public RecentPlaylist createFromParcel(Parcel source) {
|
|
||||||
return new RecentPlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecentPlaylist[] newArray(int size) {
|
|
||||||
return new RecentPlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.model.playlist;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ShufflePlaylist extends AbsSmartPlaylist {
|
|
||||||
|
|
||||||
public ShufflePlaylist(@NonNull Context context) {
|
|
||||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public List<Song> getSongs(@NonNull Context context) {
|
|
||||||
return SongLoader.getAllSongs(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(@NonNull Context context) {
|
|
||||||
// Shuffle all is not a real "Smart Playlist"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ShufflePlaylist(Parcel in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<ShufflePlaylist> CREATOR = new Creator<ShufflePlaylist>() {
|
|
||||||
public ShufflePlaylist createFromParcel(Parcel source) {
|
|
||||||
return new ShufflePlaylist(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShufflePlaylist[] newArray(int size) {
|
|
||||||
return new ShufflePlaylist[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -8,9 +8,6 @@ import com.kabouzeid.gramophone.shortcuts.shortcuttype.LatestShortcutType;
|
||||||
import com.kabouzeid.gramophone.shortcuts.shortcuttype.ShuffleShortcutType;
|
import com.kabouzeid.gramophone.shortcuts.shortcuttype.ShuffleShortcutType;
|
||||||
import com.kabouzeid.gramophone.shortcuts.shortcuttype.FrequentShortcutType;
|
import com.kabouzeid.gramophone.shortcuts.shortcuttype.FrequentShortcutType;
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
import com.kabouzeid.gramophone.model.playlist.LatestPlaylist;
|
|
||||||
import com.kabouzeid.gramophone.model.playlist.FrequentPlaylist;
|
|
||||||
import com.kabouzeid.gramophone.model.playlist.ShufflePlaylist;
|
|
||||||
import com.kabouzeid.gramophone.service.MusicService;
|
import com.kabouzeid.gramophone.service.MusicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,18 +37,12 @@ public class AppShortcutLauncherActivity extends Activity {
|
||||||
|
|
||||||
switch (shortcutType) {
|
switch (shortcutType) {
|
||||||
case SHORTCUT_TYPE_SHUFFLE:
|
case SHORTCUT_TYPE_SHUFFLE:
|
||||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_SHUFFLE,
|
|
||||||
new ShufflePlaylist(getApplicationContext()));
|
|
||||||
DynamicShortcutManager.reportShortcutUsed(this, ShuffleShortcutType.getId());
|
DynamicShortcutManager.reportShortcutUsed(this, ShuffleShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
case SHORTCUT_TYPE_FREQUENT:
|
case SHORTCUT_TYPE_FREQUENT:
|
||||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_NONE,
|
|
||||||
new FrequentPlaylist(getApplicationContext()));
|
|
||||||
DynamicShortcutManager.reportShortcutUsed(this, FrequentShortcutType.getId());
|
DynamicShortcutManager.reportShortcutUsed(this, FrequentShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
case SHORTCUT_TYPE_LATEST:
|
case SHORTCUT_TYPE_LATEST:
|
||||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_NONE,
|
|
||||||
new LatestPlaylist(getApplicationContext()));
|
|
||||||
DynamicShortcutManager.reportShortcutUsed(this, LatestShortcutType.getId());
|
DynamicShortcutManager.reportShortcutUsed(this, LatestShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ import com.kabouzeid.gramophone.interfaces.LoaderIds;
|
||||||
import com.kabouzeid.gramophone.loader.PlaylistLoader;
|
import com.kabouzeid.gramophone.loader.PlaylistLoader;
|
||||||
import com.kabouzeid.gramophone.misc.WrappedAsyncTaskLoader;
|
import com.kabouzeid.gramophone.misc.WrappedAsyncTaskLoader;
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
import com.kabouzeid.gramophone.model.playlist.RecentPlaylist;
|
|
||||||
import com.kabouzeid.gramophone.model.playlist.LatestPlaylist;
|
|
||||||
import com.kabouzeid.gramophone.model.playlist.FrequentPlaylist;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -79,11 +76,6 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment<Playl
|
||||||
|
|
||||||
private static List<Playlist> getAllPlaylists(Context context) {
|
private static List<Playlist> getAllPlaylists(Context context) {
|
||||||
List<Playlist> playlists = new ArrayList<>();
|
List<Playlist> playlists = new ArrayList<>();
|
||||||
|
|
||||||
playlists.add(new LatestPlaylist(context));
|
|
||||||
playlists.add(new RecentPlaylist(context));
|
|
||||||
playlists.add(new FrequentPlaylist(context));
|
|
||||||
|
|
||||||
playlists.addAll(PlaylistLoader.getAllPlaylists(context));
|
playlists.addAll(PlaylistLoader.getAllPlaylists(context));
|
||||||
|
|
||||||
return playlists;
|
return playlists;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue