separate frequent and recent playlists
This commit is contained in:
parent
734e6a08fa
commit
b85fab728b
14 changed files with 192 additions and 137 deletions
|
|
@ -30,7 +30,7 @@ import com.kabouzeid.gramophone.model.AbsCustomPlaylist;
|
|||
import com.kabouzeid.gramophone.model.Playlist;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LatestPlaylist;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
|
|
@ -242,7 +242,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
final Playlist playlist = dataSet.get(getAdapterPosition());
|
||||
final PopupMenu popupMenu = new PopupMenu(activity, view);
|
||||
popupMenu.inflate(getItemViewType() == SMART_PLAYLIST ? R.menu.menu_item_smart_playlist : R.menu.menu_item_playlist);
|
||||
if (playlist instanceof LastAddedPlaylist) {
|
||||
if (playlist instanceof LatestPlaylist) {
|
||||
popupMenu.getMenu().findItem(R.id.action_clear_playlist).setVisible(false);
|
||||
}
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.LastAddedShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleAllShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.TopTracksShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.LatestShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.FrequentShortcutType;
|
||||
import com.kabouzeid.gramophone.model.Playlist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.MyTopTracksPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.ShuffleAllPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LatestPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.FrequentPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.ShufflePlaylist;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
|
||||
/**
|
||||
|
|
@ -20,9 +20,9 @@ import com.kabouzeid.gramophone.service.MusicService;
|
|||
public class AppShortcutLauncherActivity extends Activity {
|
||||
public static final String KEY_SHORTCUT_TYPE = "com.kabouzeid.gramophone.appshortcuts.ShortcutType";
|
||||
|
||||
public static final int SHORTCUT_TYPE_SHUFFLE_ALL = 0;
|
||||
public static final int SHORTCUT_TYPE_TOP_TRACKS = 1;
|
||||
public static final int SHORTCUT_TYPE_LAST_ADDED = 2;
|
||||
public static final int SHORTCUT_TYPE_SHUFFLE = 0;
|
||||
public static final int SHORTCUT_TYPE_FREQUENT = 1;
|
||||
public static final int SHORTCUT_TYPE_LATEST = 2;
|
||||
public static final int SHORTCUT_TYPE_NONE = 3;
|
||||
|
||||
@Override
|
||||
|
|
@ -39,20 +39,20 @@ public class AppShortcutLauncherActivity extends Activity {
|
|||
}
|
||||
|
||||
switch (shortcutType) {
|
||||
case SHORTCUT_TYPE_SHUFFLE_ALL:
|
||||
case SHORTCUT_TYPE_SHUFFLE:
|
||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_SHUFFLE,
|
||||
new ShuffleAllPlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, ShuffleAllShortcutType.getId());
|
||||
new ShufflePlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, ShuffleShortcutType.getId());
|
||||
break;
|
||||
case SHORTCUT_TYPE_TOP_TRACKS:
|
||||
case SHORTCUT_TYPE_FREQUENT:
|
||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_NONE,
|
||||
new MyTopTracksPlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, TopTracksShortcutType.getId());
|
||||
new FrequentPlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, FrequentShortcutType.getId());
|
||||
break;
|
||||
case SHORTCUT_TYPE_LAST_ADDED:
|
||||
case SHORTCUT_TYPE_LATEST:
|
||||
startServiceWithPlaylist(MusicService.SHUFFLE_MODE_NONE,
|
||||
new LastAddedPlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, LastAddedShortcutType.getId());
|
||||
new LatestPlaylist(getApplicationContext()));
|
||||
DynamicShortcutManager.reportShortcutUsed(this, LatestShortcutType.getId());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import android.content.pm.ShortcutManager;
|
|||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.LastAddedShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleAllShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.TopTracksShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.LatestShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleShortcutType;
|
||||
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.FrequentShortcutType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -51,9 +51,9 @@ public class DynamicShortcutManager {
|
|||
|
||||
public List<ShortcutInfo> getDefaultShortcuts() {
|
||||
return (Arrays.asList(
|
||||
new ShuffleAllShortcutType(context).getShortcutInfo(),
|
||||
new TopTracksShortcutType(context).getShortcutInfo(),
|
||||
new LastAddedShortcutType(context).getShortcutInfo()
|
||||
new ShuffleShortcutType(context).getShortcutInfo(),
|
||||
new FrequentShortcutType(context).getShortcutInfo(),
|
||||
new LatestShortcutType(context).getShortcutInfo()
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import com.kabouzeid.gramophone.appshortcuts.AppShortcutLauncherActivity;
|
|||
* @author Adrian Campos
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.N_MR1)
|
||||
public final class TopTracksShortcutType extends BaseShortcutType {
|
||||
public TopTracksShortcutType(Context context) {
|
||||
public final class FrequentShortcutType extends BaseShortcutType {
|
||||
public FrequentShortcutType(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public final class TopTracksShortcutType extends BaseShortcutType {
|
|||
.setShortLabel(context.getString(R.string.app_shortcut_top_tracks_short))
|
||||
.setLongLabel(context.getString(R.string.my_top_tracks))
|
||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(context, R.drawable.ic_app_shortcut_top_tracks))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_TOP_TRACKS))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_FREQUENT))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ import com.kabouzeid.gramophone.appshortcuts.AppShortcutLauncherActivity;
|
|||
* @author Adrian Campos
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.N_MR1)
|
||||
public final class LastAddedShortcutType extends BaseShortcutType {
|
||||
public LastAddedShortcutType(Context context) {
|
||||
public final class LatestShortcutType extends BaseShortcutType {
|
||||
public LatestShortcutType(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public final class LastAddedShortcutType extends BaseShortcutType {
|
|||
.setShortLabel(context.getString(R.string.app_shortcut_last_added_short))
|
||||
.setLongLabel(context.getString(R.string.last_added))
|
||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(context, R.drawable.ic_app_shortcut_last_added))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LAST_ADDED))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LATEST))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ import com.kabouzeid.gramophone.appshortcuts.AppShortcutLauncherActivity;
|
|||
* @author Adrian Campos
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.N_MR1)
|
||||
public final class ShuffleAllShortcutType extends BaseShortcutType {
|
||||
public ShuffleAllShortcutType(Context context) {
|
||||
public final class ShuffleShortcutType extends BaseShortcutType {
|
||||
public ShuffleShortcutType(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public final class ShuffleAllShortcutType extends BaseShortcutType {
|
|||
.setShortLabel(context.getString(R.string.app_shortcut_shuffle_all_short))
|
||||
.setLongLabel(context.getString(R.string.action_shuffle_all))
|
||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(context, R.drawable.ic_app_shortcut_shuffle_all))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (C) 2014 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.kabouzeid.gramophone.loader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.BaseColumns;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FrequentLoader {
|
||||
@NonNull
|
||||
public static List<Song> getFrequent(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeFrequentCursorAndClearUpDatabase(context));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Cursor makeFrequentCursorAndClearUpDatabase(@NonNull final Context context) {
|
||||
SortedLongCursor retCursor = makeFrequentCursorImpl(context);
|
||||
|
||||
// clean up the databases with any ids not found
|
||||
if (retCursor != null) {
|
||||
List<Long> missingIds = retCursor.getMissingIds();
|
||||
if (missingIds != null && missingIds.size() > 0) {
|
||||
for (long id : missingIds) {
|
||||
SongPlayCountStore.getInstance(context).removeItem(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retCursor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SortedLongCursor makeFrequentCursorImpl(@NonNull final Context context) {
|
||||
// first get the top results ids from the internal database
|
||||
Cursor songs = SongPlayCountStore.getInstance(context).getTopPlayedResults(100);
|
||||
|
||||
try {
|
||||
return makeSortedCursor(context, songs,
|
||||
songs.getColumnIndex(SongPlayCountStore.SongPlayCountColumns.ID));
|
||||
} finally {
|
||||
if (songs != null) {
|
||||
songs.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SortedLongCursor makeSortedCursor(@NonNull final Context context, @Nullable final Cursor cursor, final int idColumn) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
// create the list of ids to select against
|
||||
StringBuilder selection = new StringBuilder();
|
||||
selection.append(BaseColumns._ID);
|
||||
selection.append(" IN (");
|
||||
|
||||
// this tracks the order of the ids
|
||||
long[] order = new long[cursor.getCount()];
|
||||
|
||||
long id = cursor.getLong(idColumn);
|
||||
selection.append(id);
|
||||
order[cursor.getPosition()] = id;
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
selection.append(",");
|
||||
|
||||
id = cursor.getLong(idColumn);
|
||||
order[cursor.getPosition()] = id;
|
||||
selection.append(String.valueOf(id));
|
||||
}
|
||||
|
||||
selection.append(")");
|
||||
|
||||
// get a list of songs with the data given the selection statement
|
||||
Cursor songCursor = SongLoader.makeSongCursor(context, selection.toString(), null);
|
||||
if (songCursor != null) {
|
||||
// now return the wrapped TopTracksCursor to handle sorting given order
|
||||
return new SortedLongCursor(songCursor, order, BaseColumns._ID);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,17 +8,16 @@ import androidx.annotation.NonNull;
|
|||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LastAddedLoader {
|
||||
public class LatestLoader {
|
||||
|
||||
@NonNull
|
||||
public static List<Song> getLastAddedSongs(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeLastAddedCursor(context));
|
||||
public static List<Song> getLatest(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeLatestCursor(context));
|
||||
}
|
||||
|
||||
public static Cursor makeLastAddedCursor(@NonNull final Context context) {
|
||||
public static Cursor makeLatestCursor(@NonNull final Context context) {
|
||||
long cutoff = PreferenceUtil.getInstance(context).getLastAddedCutoff();
|
||||
|
||||
return SongLoader.makeSongCursor(
|
||||
|
|
@ -19,33 +19,24 @@ package com.kabouzeid.gramophone.loader;
|
|||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.BaseColumns;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.provider.HistoryStore;
|
||||
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TopAndRecentlyPlayedTracksLoader {
|
||||
public static final int NUMBER_OF_TOP_TRACKS = 100;
|
||||
|
||||
public class RecentLoader {
|
||||
@NonNull
|
||||
public static List<Song> getRecentlyPlayedTracks(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeRecentTracksCursorAndClearUpDatabase(context));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static List<Song> getTopTracks(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeTopTracksCursorAndClearUpDatabase(context));
|
||||
public static List<Song> getRecent(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeRecentCursorAndClearUpDatabase(context));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Cursor makeRecentTracksCursorAndClearUpDatabase(@NonNull final Context context) {
|
||||
SortedLongCursor retCursor = makeRecentTracksCursorImpl(context);
|
||||
public static Cursor makeRecentCursorAndClearUpDatabase(@NonNull final Context context) {
|
||||
SortedLongCursor retCursor = makeRecentCursorImpl(context);
|
||||
|
||||
// clean up the databases with any ids not found
|
||||
if (retCursor != null) {
|
||||
|
|
@ -60,23 +51,7 @@ public class TopAndRecentlyPlayedTracksLoader {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static Cursor makeTopTracksCursorAndClearUpDatabase(@NonNull final Context context) {
|
||||
SortedLongCursor retCursor = makeTopTracksCursorImpl(context);
|
||||
|
||||
// clean up the databases with any ids not found
|
||||
if (retCursor != null) {
|
||||
List<Long> missingIds = retCursor.getMissingIds();
|
||||
if (missingIds != null && missingIds.size() > 0) {
|
||||
for (long id : missingIds) {
|
||||
SongPlayCountStore.getInstance(context).removeItem(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retCursor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SortedLongCursor makeRecentTracksCursorImpl(@NonNull final Context context) {
|
||||
private static SortedLongCursor makeRecentCursorImpl(@NonNull final Context context) {
|
||||
// first get the top results ids from the internal database
|
||||
Cursor songs = HistoryStore.getInstance(context).queryRecentIds();
|
||||
|
||||
|
|
@ -90,21 +65,6 @@ public class TopAndRecentlyPlayedTracksLoader {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SortedLongCursor makeTopTracksCursorImpl(@NonNull final Context context) {
|
||||
// first get the top results ids from the internal database
|
||||
Cursor songs = SongPlayCountStore.getInstance(context).getTopPlayedResults(NUMBER_OF_TOP_TRACKS);
|
||||
|
||||
try {
|
||||
return makeSortedCursor(context, songs,
|
||||
songs.getColumnIndex(SongPlayCountStore.SongPlayCountColumns.ID));
|
||||
} finally {
|
||||
if (songs != null) {
|
||||
songs.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SortedLongCursor makeSortedCursor(@NonNull final Context context, @Nullable final Cursor cursor, final int idColumn) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
|
|
@ -5,26 +5,25 @@ import android.os.Parcel;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
|
||||
import com.kabouzeid.gramophone.loader.FrequentLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class MyTopTracksPlaylist extends AbsSmartPlaylist {
|
||||
public class FrequentPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public MyTopTracksPlaylist(@NonNull Context context) {
|
||||
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 TopAndRecentlyPlayedTracksLoader.getTopTracks(context);
|
||||
return FrequentLoader.getFrequent(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -38,17 +37,17 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist {
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected MyTopTracksPlaylist(Parcel in) {
|
||||
protected FrequentPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<MyTopTracksPlaylist> CREATOR = new Creator<MyTopTracksPlaylist>() {
|
||||
public MyTopTracksPlaylist createFromParcel(Parcel source) {
|
||||
return new MyTopTracksPlaylist(source);
|
||||
public static final Creator<FrequentPlaylist> CREATOR = new Creator<FrequentPlaylist>() {
|
||||
public FrequentPlaylist createFromParcel(Parcel source) {
|
||||
return new FrequentPlaylist(source);
|
||||
}
|
||||
|
||||
public MyTopTracksPlaylist[] newArray(int size) {
|
||||
return new MyTopTracksPlaylist[size];
|
||||
public FrequentPlaylist[] newArray(int size) {
|
||||
return new FrequentPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -4,27 +4,25 @@ import android.content.Context;
|
|||
import android.os.Parcel;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.loader.LastAddedLoader;
|
||||
import com.kabouzeid.gramophone.loader.LatestLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class LastAddedPlaylist extends AbsSmartPlaylist {
|
||||
public class LatestPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public LastAddedPlaylist(@NonNull Context context) {
|
||||
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 LastAddedLoader.getLastAddedSongs(context);
|
||||
return LatestLoader.getLatest(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -37,17 +35,17 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected LastAddedPlaylist(Parcel in) {
|
||||
protected LatestPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<LastAddedPlaylist> CREATOR = new Creator<LastAddedPlaylist>() {
|
||||
public LastAddedPlaylist createFromParcel(Parcel source) {
|
||||
return new LastAddedPlaylist(source);
|
||||
public static final Creator<LatestPlaylist> CREATOR = new Creator<LatestPlaylist>() {
|
||||
public LatestPlaylist createFromParcel(Parcel source) {
|
||||
return new LatestPlaylist(source);
|
||||
}
|
||||
|
||||
public LastAddedPlaylist[] newArray(int size) {
|
||||
return new LastAddedPlaylist[size];
|
||||
public LatestPlaylist[] newArray(int size) {
|
||||
return new LatestPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -4,28 +4,26 @@ import android.content.Context;
|
|||
import android.os.Parcel;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
|
||||
import com.kabouzeid.gramophone.loader.RecentLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.provider.HistoryStore;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class HistoryPlaylist extends AbsSmartPlaylist {
|
||||
public class RecentPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public HistoryPlaylist(@NonNull Context context) {
|
||||
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 TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context);
|
||||
return RecentLoader.getRecent(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -39,17 +37,17 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected HistoryPlaylist(Parcel in) {
|
||||
protected RecentPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<HistoryPlaylist> CREATOR = new Creator<HistoryPlaylist>() {
|
||||
public HistoryPlaylist createFromParcel(Parcel source) {
|
||||
return new HistoryPlaylist(source);
|
||||
public static final Creator<RecentPlaylist> CREATOR = new Creator<RecentPlaylist>() {
|
||||
public RecentPlaylist createFromParcel(Parcel source) {
|
||||
return new RecentPlaylist(source);
|
||||
}
|
||||
|
||||
public HistoryPlaylist[] newArray(int size) {
|
||||
return new HistoryPlaylist[size];
|
||||
public RecentPlaylist[] newArray(int size) {
|
||||
return new RecentPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -8,12 +8,11 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
||||
public class ShufflePlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public ShuffleAllPlaylist(@NonNull Context context) {
|
||||
public ShufflePlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
|
||||
}
|
||||
|
||||
|
|
@ -33,17 +32,17 @@ public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected ShuffleAllPlaylist(Parcel in) {
|
||||
protected ShufflePlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<ShuffleAllPlaylist> CREATOR = new Creator<ShuffleAllPlaylist>() {
|
||||
public ShuffleAllPlaylist createFromParcel(Parcel source) {
|
||||
return new ShuffleAllPlaylist(source);
|
||||
public static final Creator<ShufflePlaylist> CREATOR = new Creator<ShufflePlaylist>() {
|
||||
public ShufflePlaylist createFromParcel(Parcel source) {
|
||||
return new ShufflePlaylist(source);
|
||||
}
|
||||
|
||||
public ShuffleAllPlaylist[] newArray(int size) {
|
||||
return new ShuffleAllPlaylist[size];
|
||||
public ShufflePlaylist[] newArray(int size) {
|
||||
return new ShufflePlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -14,9 +14,9 @@ import com.kabouzeid.gramophone.interfaces.LoaderIds;
|
|||
import com.kabouzeid.gramophone.loader.PlaylistLoader;
|
||||
import com.kabouzeid.gramophone.misc.WrappedAsyncTaskLoader;
|
||||
import com.kabouzeid.gramophone.model.Playlist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.HistoryPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.MyTopTracksPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.RecentPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LatestPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.FrequentPlaylist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -80,9 +80,9 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment<Playl
|
|||
private static List<Playlist> getAllPlaylists(Context context) {
|
||||
List<Playlist> playlists = new ArrayList<>();
|
||||
|
||||
playlists.add(new LastAddedPlaylist(context));
|
||||
playlists.add(new HistoryPlaylist(context));
|
||||
playlists.add(new MyTopTracksPlaylist(context));
|
||||
playlists.add(new LatestPlaylist(context));
|
||||
playlists.add(new RecentPlaylist(context));
|
||||
playlists.add(new FrequentPlaylist(context));
|
||||
|
||||
playlists.addAll(PlaylistLoader.getAllPlaylists(context));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue