Commit a02ea8a5 authored by Duncan McNAMARA's avatar Duncan McNAMARA
Browse files

Medialibrary: move Playlist to APlaylist

parent 418bbc70
......@@ -1765,8 +1765,8 @@ static JNINativeMethod methods[] = {
{"nativeSearchGenre", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/interfaces/media/AGenre;", (void*)searchGenre },
{"nativeSearchPagedGenre", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AGenre;", (void*)searchPagedGenre },
{"nativeGetGenreSearchCount", "(Ljava/lang/String;)I", (void*)getGenreSearchCount },
{"nativeSearchPlaylist", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/media/Playlist;", (void*)searchPlaylist },
{"nativeSearchPagedPlaylist", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/media/Playlist;", (void*)searchPagedPlaylist },
{"nativeSearchPlaylist", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)searchPlaylist },
{"nativeSearchPagedPlaylist", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)searchPagedPlaylist },
{"nativeGetPlaylistSearchCount", "(Ljava/lang/String;)I", (void*)getPlaylistSearchCount },
{"nativeGetMedia", "(J)Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getMedia },
{"nativeGetMediaFromMrl", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getMediaFromMrl },
......@@ -1787,10 +1787,10 @@ static JNINativeMethod methods[] = {
{"nativeGetPagedGenres", "(IZII)[Lorg/videolan/medialibrary/interfaces/media/AGenre;", (void*)getPagedGenres },
{"nativeGetGenresCount", "()I", (void*)getGenresCount },
{"nativeGetGenre", "(J)Lorg/videolan/medialibrary/interfaces/media/AGenre;", (void*)getGenre },
{"nativeGetPlaylists", "(IZ)[Lorg/videolan/medialibrary/media/Playlist;", (void*)getPlaylists },
{"nativeGetPagedPlaylists", "(IZII)[Lorg/videolan/medialibrary/media/Playlist;", (void*)getPagedPlaylists },
{"nativeGetPlaylists", "(IZ)[Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)getPlaylists },
{"nativeGetPagedPlaylists", "(IZII)[Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)getPagedPlaylists },
{"nativeGetPlaylistsCount", "()I", (void*)getPlaylistsCount },
{"nativeGetPlaylist", "(J)Lorg/videolan/medialibrary/media/Playlist;", (void*)getPlaylist },
{"nativeGetPlaylist", "(J)Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)getPlaylist },
{"nativeGetFolders", "(IIZII)[Lorg/videolan/medialibrary/interfaces/media/AFolder;", (void*)folders },
{"nativeGetFoldersCount", "(I)I", (void*)foldersCount },
{"nativePauseBackgroundOperations", "()V", (void*)pauseBackgroundOperations },
......@@ -1802,7 +1802,7 @@ static JNINativeMethod methods[] = {
{"nativeIncreasePlayCount", "(J)Z", (void*)increasePlayCount },
{"nativeSetMediaUpdatedCbFlag", "(I)V", (void*)setMediaUpdatedCbFlag },
{"nativeSetMediaAddedCbFlag", "(I)V", (void*)setMediaAddedCbFlag },
{"nativePlaylistCreate", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/Playlist;", (void*)playlistCreate },
{"nativePlaylistCreate", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/APlaylist;", (void*)playlistCreate },
{"nativeRequestThumbnail", "(J)V", (void*)requestThumbnail },
};
......@@ -2008,7 +2008,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetMethodID,
ml_fields.SearchAggregate.initID,
ml_fields.SearchAggregate.clazz,
"<init>", "([Lorg/videolan/medialibrary/interfaces/media/AAlbum;[Lorg/videolan/medialibrary/interfaces/media/AArtist;[Lorg/videolan/medialibrary/interfaces/media/AGenre;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/media/Playlist;)V");
"<init>", "([Lorg/videolan/medialibrary/interfaces/media/AAlbum;[Lorg/videolan/medialibrary/interfaces/media/AArtist;[Lorg/videolan/medialibrary/interfaces/media/AGenre;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/APlaylist;)V");
GET_CLASS(ml_fields.Folder.clazz, "org/videolan/medialibrary/media/Folder", true);
......
......@@ -38,7 +38,7 @@ import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AFolder;
import org.videolan.medialibrary.interfaces.media.AGenre;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.media.Playlist;
import org.videolan.medialibrary.interfaces.media.APlaylist;
import org.videolan.medialibrary.media.SearchAggregate;
import java.io.File;
......@@ -352,18 +352,18 @@ public class Medialibrary {
}
@WorkerThread
public Playlist[] getPlaylists() {
public APlaylist[] getPlaylists() {
return getPlaylists(Medialibrary.SORT_DEFAULT, false);
}
@WorkerThread
public Playlist[] getPlaylists(int sort, boolean desc) {
return mIsInitiated ? nativeGetPlaylists(sort, desc) : new Playlist[0];
public APlaylist[] getPlaylists(int sort, boolean desc) {
return mIsInitiated ? nativeGetPlaylists(sort, desc) : new APlaylist[0];
}
@WorkerThread
public Playlist[] getPagedPlaylists(int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated ? nativeGetPagedPlaylists(sort, desc, nbItems, offset) : new Playlist[0];
public APlaylist[] getPagedPlaylists(int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated ? nativeGetPagedPlaylists(sort, desc, nbItems, offset) : new APlaylist[0];
}
public int getPlaylistsCount() {
......@@ -374,11 +374,11 @@ public class Medialibrary {
return mIsInitiated ? nativeGetPlaylistSearchCount(query) : 0;
}
public Playlist getPlaylist(long playlistId) {
public APlaylist getPlaylist(long playlistId) {
return mIsInitiated ? nativeGetPlaylist(playlistId) : null;
}
public Playlist createPlaylist(String name) {
public APlaylist createPlaylist(String name) {
return mIsInitiated && !TextUtils.isEmpty(name) ? nativePlaylistCreate(name) : null;
}
......@@ -872,11 +872,11 @@ public class Medialibrary {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPagedGenre(query, sort, desc, nbItems, offset) : null;
}
public Playlist[] searchPlaylist(String query) {
public APlaylist[] searchPlaylist(String query) {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPlaylist(query) : null;
}
public Playlist[] searchPlaylist(String query, int sort, boolean desc, int nbItems, int offset) {
public APlaylist[] searchPlaylist(String query, int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPagedPlaylist(query, sort, desc, nbItems, offset) : null;
}
......@@ -1012,11 +1012,11 @@ public class Medialibrary {
private native AGenre[] nativeGetPagedGenres(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetGenresCount();
private native AGenre nativeGetGenre(long genreId);
private native Playlist[] nativeGetPlaylists(int sort, boolean desc);
private native Playlist[] nativeGetPagedPlaylists(int sort, boolean desc, int nbItems, int offset);
private native APlaylist[] nativeGetPlaylists(int sort, boolean desc);
private native APlaylist[] nativeGetPagedPlaylists(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetPlaylistsCount();
private native Playlist nativeGetPlaylist(long playlistId);
private native Playlist nativePlaylistCreate(String name);
private native APlaylist nativeGetPlaylist(long playlistId);
private native APlaylist nativePlaylistCreate(String name);
private native AFolder[] nativeGetFolders(int type, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetFoldersCount(int type);
private native void nativePauseBackgroundOperations();
......@@ -1045,8 +1045,8 @@ public class Medialibrary {
private native AGenre[] nativeSearchGenre(String query);
private native AGenre[] nativeSearchPagedGenre(String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetGenreSearchCount(String query);
private native Playlist[] nativeSearchPlaylist(String query);
private native Playlist[] nativeSearchPagedPlaylist(String query, int sort, boolean desc, int nbItems, int offset);
private native APlaylist[] nativeSearchPlaylist(String query);
private native APlaylist[] nativeSearchPagedPlaylist(String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetPlaylistSearchCount(String query);
private native void nativeRequestThumbnail(long mediaId);
......
......@@ -10,16 +10,19 @@ import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AFolder;
import org.videolan.medialibrary.interfaces.media.AGenre;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.interfaces.media.APlaylist;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.Artist;
import org.videolan.medialibrary.media.Folder;
import org.videolan.medialibrary.media.Genre;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.medialibrary.media.Playlist;
import org.videolan.medialibrary.stubs.StubAlbum;
import org.videolan.medialibrary.stubs.StubArtist;
import org.videolan.medialibrary.stubs.StubFolder;
import org.videolan.medialibrary.stubs.StubGenre;
import org.videolan.medialibrary.stubs.StubMediaWrapper;
import org.videolan.medialibrary.stubs.StubPlaylist;
public class ServiceLocator {
......@@ -170,4 +173,21 @@ public class ServiceLocator {
return new StubFolder(in);
}
}
//Playlist
public static APlaylist getAPlaylist(long id, String name, int trackCount) {
if (mMode == LocatorMode.VLC_ANDROID) {
return new Playlist(id, name, trackCount);
} else {
return new StubPlaylist(id, name, trackCount);
}
}
public static APlaylist getAPlaylist(Parcel in) {
if (mMode == LocatorMode.VLC_ANDROID) {
return new Playlist(in);
} else {
return new StubPlaylist(in);
}
}
}
package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.media.MediaLibraryItem;
import java.util.List;
public abstract class APlaylist extends MediaLibraryItem {
protected int mTracksCount;
protected APlaylist(long id, String name, int trackCount) {
super(id, name);
mTracksCount = trackCount;
}
abstract public AMediaWrapper[] getTracks();
abstract public AMediaWrapper[] getPagedTracks(int nbItems, int offset);
abstract public int getRealTracksCount();
abstract public boolean append(long mediaId);
abstract public boolean append(long[] mediaIds);
abstract public boolean append(List<Long> mediaIds);
abstract public boolean add(long mediaId, int position);
abstract public boolean move(int oldPosition, int newPosition);
abstract public boolean remove(int position);
abstract public boolean delete();
abstract public AMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchTracksCount(String query);
@Override
public int getTracksCount() {
return mTracksCount;
}
@Override
public int getItemType() {
return TYPE_PLAYLIST;
}
public static Parcelable.Creator<APlaylist> CREATOR
= new Parcelable.Creator<APlaylist>() {
@Override
public APlaylist createFromParcel(Parcel in) {
return ServiceLocator.getAPlaylist(in);
}
@Override
public APlaylist[] newArray(int size) {
return new APlaylist[size];
}
};
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(mTracksCount);
}
public APlaylist(Parcel in) {
super(in);
this.mTracksCount = in.readInt();
}
}
package org.videolan.medialibrary.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.interfaces.media.APlaylist;
import java.util.List;
@SuppressWarnings("JniMissingFunction")
public class Playlist extends MediaLibraryItem {
public class Playlist extends APlaylist {
private int mTracksCount;
public Playlist(long id, String name, int trackCount) {
super(id, name, trackCount);
}
protected Playlist(long id, String name, int trackCount) {
super(id, name);
mTracksCount = trackCount;
public Playlist(Parcel in) {
super(in);
}
@Override
......@@ -29,20 +30,11 @@ public class Playlist extends MediaLibraryItem {
return ml.isInitiated() ? nativeGetPagedTracks(ml, mId, nbItems, offset) : Medialibrary.EMPTY_COLLECTION;
}
@Override
public int getTracksCount() {
return mTracksCount;
}
public int getRealTracksCount() {
Medialibrary ml = Medialibrary.getInstance();
return ml.isInitiated() ? nativeGetTracksCount(ml, mId) : 0;
}
@Override
public int getItemType() {
return TYPE_PLAYLIST;
}
public boolean append(long mediaId) {
Medialibrary ml = Medialibrary.getInstance();
......@@ -94,30 +86,6 @@ public class Playlist extends MediaLibraryItem {
return ml.isInitiated() ? nativeGetSearchCount(ml, mId, query) : 0;
}
public static Parcelable.Creator<Playlist> CREATOR
= new Parcelable.Creator<Playlist>() {
@Override
public Playlist createFromParcel(Parcel in) {
return new Playlist(in);
}
@Override
public Playlist[] newArray(int size) {
return new Playlist[size];
}
};
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(mTracksCount);
}
private Playlist(Parcel in) {
super(in);
this.mTracksCount = in.readInt();
}
private native AMediaWrapper[] nativeGetTracks(Medialibrary ml, long id);
private native AMediaWrapper[] nativeGetPagedTracks(Medialibrary ml, long id, int nbItems, int offset);
private native int nativeGetTracksCount(Medialibrary ml, long id);
......
......@@ -5,6 +5,7 @@ import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AGenre;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.interfaces.media.APlaylist;
public class SearchAggregate {
private static final String TAG = "VLC/SearchAggregate";
......@@ -14,7 +15,7 @@ public class SearchAggregate {
private final AGenre[] genres;
private final AMediaWrapper[] videos;
private final AMediaWrapper[] tracks;
private final Playlist[] playlists;
private final APlaylist[] playlists;
public SearchAggregate() {
this.albums = null;
......@@ -25,7 +26,7 @@ public class SearchAggregate {
this.playlists = null;
}
public SearchAggregate(AAlbum[] albums, AArtist[] artists, AGenre[] genres, AMediaWrapper[] videos, AMediaWrapper[] tracks, Playlist[] playlists) {
public SearchAggregate(AAlbum[] albums, AArtist[] artists, AGenre[] genres, AMediaWrapper[] videos, AMediaWrapper[] tracks, APlaylist[] playlists) {
this.albums = albums;
this.artists = artists;
this.genres = genres;
......@@ -54,7 +55,7 @@ public class SearchAggregate {
return tracks;
}
public Playlist[] getPlaylists() {
public APlaylist[] getPlaylists() {
return playlists;
}
......@@ -92,7 +93,7 @@ public class SearchAggregate {
}
if (playlists.length > 0) {
sb.append("Playlists:\n");
for (Playlist playlist : playlists)
for (APlaylist playlist : playlists)
sb.append(playlist.getTitle()).append("\n");
}
return sb.toString();
......
package org.videolan.medialibrary.stubs;
import android.os.Parcel;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.interfaces.media.APlaylist;
import java.util.List;
public class StubPlaylist extends APlaylist {
public StubPlaylist(long id, String name, int trackCount) {
super(id, name, trackCount);
}
public StubPlaylist(Parcel in) {
super(in);
}
public AMediaWrapper[] getTracks() {
return null;
}
public AMediaWrapper[] getPagedTracks(int nbItems, int offset) {
return null;
}
public int getRealTracksCount() {
return 0;
}
public boolean append(long mediaId) {
return true;
}
public boolean append(long[] mediaIds) {
return true;
}
public boolean append(List<Long> mediaIds) {
return true;
}
public boolean add(long mediaId, int position) {
return true;
}
public boolean move(int oldPosition, int newPosition) {
return true;
}
public boolean remove(int position) {
return true;
}
public boolean delete() {
return true;
}
public AMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset) {
return null;
}
public int searchTracksCount(String query) {
return 0;
}
}
......@@ -48,8 +48,8 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.coroutines.*
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.interfaces.media.APlaylist
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Playlist
import org.videolan.tools.isStarted
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
......@@ -206,7 +206,7 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler, IL
override fun onMove(oldPosition: Int, newPosition: Int) {
if (BuildConfig.DEBUG) Log.d(TAG, "Moving item from $oldPosition to $newPosition")
(viewModel.playlist as Playlist).move(oldPosition, newPosition)
(viewModel.playlist as APlaylist).move(oldPosition, newPosition)
}
......@@ -329,7 +329,11 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler, IL
private fun removeItem(position: Int, media: AMediaWrapper) {
val resId = if (isPlaylist) R.string.confirm_remove_from_playlist else R.string.confirm_delete
if (isPlaylist) {
<<<<<<< HEAD
snackerConfirm(binding.root, getString(resId, media.title), Runnable { (viewModel.playlist as Playlist).remove(position) })
=======
UiTools.snackerConfirm(binding.root, getString(resId, media.title), Runnable { (viewModel.playlist as APlaylist).remove(position) })
>>>>>>> Medialibrary: move Playlist to APlaylist
} else {
val deleteAction = Runnable { deleteMedia(media) }
snackerConfirm(binding.root, getString(resId, media.title), Runnable { if (Util.checkWritePermission(this@PlaylistActivity, media, deleteAction)) deleteAction.run() })
......@@ -365,7 +369,7 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler, IL
private fun removeFromPlaylist(list: List<AMediaWrapper>, indexes: List<Int>) {
val itemsRemoved = HashMap<Int, Long>()
val playlist = viewModel.playlist as? Playlist ?: return
val playlist = viewModel.playlist as? APlaylist ?: return
for (mediaItem in list) {
for (i in 0 until playlist.tracks.size) {
......
......@@ -40,8 +40,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
import kotlinx.coroutines.*
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.interfaces.media.APlaylist
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Playlist
import org.videolan.tools.isStarted
import org.videolan.vlc.R
import org.videolan.vlc.VLCApplication
......@@ -173,7 +173,7 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
protected open fun removeItem(item: MediaLibraryItem): Boolean {
view ?: return false
when {
item.itemType == MediaLibraryItem.TYPE_PLAYLIST -> UiTools.snackerConfirm(view!!, getString(R.string.confirm_delete_playlist, item.title), Runnable { MediaUtils.deletePlaylist(item as Playlist) })
item.itemType == MediaLibraryItem.TYPE_PLAYLIST -> UiTools.snackerConfirm(view!!, getString(R.string.confirm_delete_playlist, item.title), Runnable { MediaUtils.deletePlaylist(item as APlaylist) })
item.itemType == MediaLibraryItem.TYPE_MEDIA -> {
<<<<<<< HEAD
val deleteAction = Runnable {
......
......@@ -39,8 +39,8 @@ import com.google.android.material.textfield.TextInputLayout
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.interfaces.media.APlaylist
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Playlist
import org.videolan.vlc.R
import org.videolan.vlc.VLCApplication
import org.videolan.vlc.gui.SimpleAdapter
......@@ -123,7 +123,7 @@ class SavePlaylistDialog : VLCBottomSheetDialogFragment(), View.OnClickListener,
runIO(Runnable {
val name = mEditText!!.text.toString().trim { it <= ' ' }
val addTracks = !Tools.isArrayEmpty(mNewTrack)
var playlist: Playlist? = mMedialibrary.getPlaylist(mPlaylistId)
var playlist: APlaylist? = mMedialibrary.getPlaylist(mPlaylistId)
val exists = playlist != null
val tracks: Array<AMediaWrapper>?
if (!exists) playlist = mMedialibrary.createPlaylist(name)
......
......@@ -26,6 +26,7 @@ import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.interfaces.media.AAlbum
import org.videolan.medialibrary.interfaces.media.AFolder
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.interfaces.media.APlaylist
import org.videolan.medialibrary.media.*
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.R
......@@ -433,7 +434,7 @@ object MediaUtils : CoroutineScope {
} catch (ignored: SecurityException) {
}
fun deletePlaylist(playlist: Playlist) = launch(Dispatchers.IO) { playlist.delete() }
fun deletePlaylist(playlist: APlaylist) = launch(Dispatchers.IO) { playlist.delete() }
}
@WorkerThread
......
......@@ -22,16 +22,16 @@ package org.videolan.vlc.providers.medialibrary
import android.content.Context
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.videolan.medialibrary.media.Playlist
import org.videolan.medialibrary.interfaces.media.APlaylist
import org.videolan.vlc.viewmodels.SortableModel
@ExperimentalCoroutinesApi
class PlaylistsProvider(context: Context, scope: SortableModel) : MedialibraryProvider<Playlist>(context, scope) {
class PlaylistsProvider(context: Context, scope: SortableModel) : MedialibraryProvider<APlaylist>(context, scope) {
override fun getAll() : Array<Playlist> = medialibrary.getPlaylists(sort, scope.desc)
override fun getAll() : Array<APlaylist> = medialibrary.getPlaylists(sort, scope.desc)
override fun getPage(loadSize: Int, startposition: Int) : Array<Playlist> {
override fun getPage(loadSize: Int, startposition: Int) : Array<APlaylist> {
val list = if (scope.filterQuery == null) medialibrary.getPagedPlaylists(sort, scope.desc, loadSize, startposition)
else medialibrary.searchPlaylist(scope.filterQuery, sort, scope.desc, loadSize, startposition)
return list.also { completeHeaders(it, startposition) }
......
......@@ -23,10 +23,7 @@ package org.videolan.vlc.providers.medialibrary
import android.content.Context
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.interfaces.media.AAlbum
import org.videolan.medialibrary.interfaces.media.AArtist
import org.videolan.medialibrary.interfaces.media.AGenre
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.interfaces.media.*
import org.videolan.medialibrary.media.*
import org.videolan.vlc.util.Settings
import org.videolan.vlc.viewmodels.SortableModel
......@@ -57,13 +54,13 @@ class TracksProvider(val parent : MediaLibraryItem?, context: Context, scope: So
is AArtist -> parent.getPagedTracks(sort, scope.desc, loadSize, startposition)
is AAlbum -> parent.getPagedTracks(sort, scope.desc, loadSize, startposition)
is AGenre -> parent.getPagedTracks(sort, scope.desc, loadSize, startposition)
is Playlist -> parent.getPagedTracks(loadSize, startposition)
is APlaylist -> parent.getPagedTracks(loadSize, startposition)
else -> medialibrary.getPagedAudio(sort, scope.desc, loadSize, startposition)
} else when(parent) {
is AArtist -> parent.searchTracks(scope.filterQuery, sort, scope.desc, loadSize, startposition)
is AAlbum -> parent.searchTracks(scope.filterQuery, sort, scope.desc, loadSize, startposition)
is AGenre -> parent.searchTracks(scope.filterQuery, sort, scope.desc, loadSize, startposition)
is Playlist -> parent.searchTracks(scope.filterQuery, sort, scope.desc, loadSize, startposition)
is APlaylist -> parent.searchTracks(scope.filterQuery, sort, scope.desc, loadSize, startposition)
else -> medialibrary.searchAudio(scope.filterQuery, sort, scope.desc, loadSize, startposition)
}