2020-05-18 10:39:01 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using MvvmCross.ViewModels;
|
|
|
|
using SpotifyAPI.Web;
|
|
|
|
|
|
|
|
namespace Example.UWP.ViewModels
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Spotify Token is the parameter
|
|
|
|
/// </summary>
|
|
|
|
public class PlaylistsListViewModel : MvxViewModel<string>
|
|
|
|
{
|
|
|
|
private SpotifyClient _spotify;
|
|
|
|
|
2020-11-02 19:27:21 +00:00
|
|
|
private IList<SimplePlaylist> _playlists;
|
|
|
|
public IList<SimplePlaylist> Playlists
|
2020-05-20 19:59:11 +01:00
|
|
|
{
|
2020-05-18 10:39:01 +01:00
|
|
|
get => _playlists ?? (_playlists = new List<SimplePlaylist>());
|
|
|
|
set => SetProperty(ref _playlists, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Prepare(string token)
|
|
|
|
{
|
|
|
|
_spotify = new SpotifyClient(SpotifyClientConfig.CreateDefault(token));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task Initialize()
|
|
|
|
{
|
|
|
|
await base.Initialize();
|
|
|
|
|
2020-11-02 19:27:21 +00:00
|
|
|
Playlists = await _spotify.PaginateAll(await _spotify.Playlists.CurrentUsers());
|
2020-05-18 10:39:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|