@@ -18,6 +18,7 @@ namespace Mear.ViewModels
|
|||||||
private ObservableCollection<Album> _albumItems;
|
private ObservableCollection<Album> _albumItems;
|
||||||
private Command _refreshAlbums;
|
private Command _refreshAlbums;
|
||||||
private Command _searchAlbumCommand;
|
private Command _searchAlbumCommand;
|
||||||
|
private List<Album> _albums;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -52,19 +53,31 @@ namespace Mear.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
public async void SearchAlbums(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
_albumItems.Clear();
|
||||||
|
_albums.ToList().ForEach(_albumItems.Add);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var albumItems = _albums.Where(a => a.Title.Contains(text)).ToList();
|
||||||
|
_albumItems.Clear();
|
||||||
|
albumItems.ToList().ForEach(_albumItems.Add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task PopulateAlbumsAsync()
|
private async Task PopulateAlbumsAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var albumRepo = new RemoteAlbumRepository();
|
var albumRepo = new RemoteAlbumRepository();
|
||||||
var albums = albumRepo.RetrieveAlbums().OrderBy(a => a.Title).ToList();
|
_albums = albumRepo.RetrieveAlbums().OrderBy(a => a.Title).ToList();
|
||||||
|
|
||||||
_albumItems.Clear();
|
_albumItems.Clear();
|
||||||
|
|
||||||
foreach (var album in albums)
|
_albums.ToList().ForEach(_albumItems.Add);
|
||||||
{
|
|
||||||
_albumItems.Add(album);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace Mear.ViewModels
|
|||||||
private ObservableCollection<Artist> _artistItems;
|
private ObservableCollection<Artist> _artistItems;
|
||||||
private Command _refreshArtists;
|
private Command _refreshArtists;
|
||||||
private Command _searchArtistCommand;
|
private Command _searchArtistCommand;
|
||||||
|
private List<Artist> _artists;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -52,19 +53,30 @@ namespace Mear.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
public async void SearchArtists(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
_artistItems.Clear();
|
||||||
|
_artists.ToList().ForEach(_artistItems.Add);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var artistItems = _artists.Where(a => a.Name.Contains(text)).ToList();
|
||||||
|
_artistItems.Clear();
|
||||||
|
artistItems.ToList().ForEach(_artistItems.Add);
|
||||||
|
}
|
||||||
|
}
|
||||||
private async Task PopulateArtistsAsync()
|
private async Task PopulateArtistsAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var artistRepo = new RemoteArtistRepository();
|
var artistRepo = new RemoteArtistRepository();
|
||||||
var artists = artistRepo.RetrieveArtists().OrderBy(a => a.Name).ToList();
|
_artists = artistRepo.RetrieveArtists().OrderBy(a => a.Name).ToList();
|
||||||
|
|
||||||
_artistItems.Clear();
|
_artistItems.Clear();
|
||||||
|
|
||||||
foreach (var artist in artists)
|
_artists.ToList().ForEach(_artistItems.Add);
|
||||||
{
|
|
||||||
_artistItems.Add(artist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace Mear.ViewModels
|
|||||||
private ObservableCollection<Song> _songItems;
|
private ObservableCollection<Song> _songItems;
|
||||||
private Command _refreshSongs;
|
private Command _refreshSongs;
|
||||||
private Command _searchSongsCommand;
|
private Command _searchSongsCommand;
|
||||||
|
private List<Song> _songs;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ namespace Mear.ViewModels
|
|||||||
_refreshSongs = new Command(async () => await PopulateSongsAsync());
|
_refreshSongs = new Command(async () => await PopulateSongsAsync());
|
||||||
_searchSongsCommand = new Command(async () => await SearchSongText());
|
_searchSongsCommand = new Command(async () => await SearchSongText());
|
||||||
|
|
||||||
PopulateSongs();
|
PopulateSongsAsync();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -73,9 +74,22 @@ namespace Mear.ViewModels
|
|||||||
songs = rmtSongs;
|
songs = rmtSongs;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var song in songs)
|
songs.ToList().ForEach(_songItems.Add);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void FilterSongs(string text)
|
||||||
{
|
{
|
||||||
_songItems.Add(song);
|
if (string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
_songItems.Clear();
|
||||||
|
_songs.ToList().ForEach(_songItems.Add);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var songItems = _songs.Where(s => s.Title.Contains(text) ||
|
||||||
|
s.Artist.Contains(text)).ToList();
|
||||||
|
_songItems.Clear();
|
||||||
|
songItems.ToList().ForEach(_songItems.Add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,23 +121,19 @@ namespace Mear.ViewModels
|
|||||||
var localSongRepo = new LocalSongRepository();
|
var localSongRepo = new LocalSongRepository();
|
||||||
var lclSongs = localSongRepo.RetrieveSongs();
|
var lclSongs = localSongRepo.RetrieveSongs();
|
||||||
var rmtSongs = songRepo.RetrieveSongs().OrderBy(s => s.Title).ToList();
|
var rmtSongs = songRepo.RetrieveSongs().OrderBy(s => s.Title).ToList();
|
||||||
var songs = new List<Song>();
|
|
||||||
if (lclSongs != null)
|
if (lclSongs != null)
|
||||||
{
|
{
|
||||||
lclSongs = lclSongs.OrderBy(s => s.Title).ToList();
|
lclSongs = lclSongs.OrderBy(s => s.Title).ToList();
|
||||||
songs = MergeSongs(lclSongs, rmtSongs);
|
_songs = MergeSongs(lclSongs, rmtSongs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
songs = rmtSongs;
|
_songs = rmtSongs;
|
||||||
}
|
}
|
||||||
|
|
||||||
_songItems.Clear();
|
_songItems.Clear();
|
||||||
|
|
||||||
foreach (var song in songs)
|
_songs.ToList().ForEach(_songItems.Add);
|
||||||
{
|
|
||||||
_songItems.Add(song);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
Placeholder="Album"
|
Placeholder="Album"
|
||||||
SearchCommand="{Binding SearchAlbumCommand}"
|
SearchCommand="{Binding SearchAlbumCommand}"
|
||||||
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
||||||
Text="{Binding SearchedText, Mode=TwoWay}" />
|
Text="{Binding SearchedText, Mode=TwoWay}"
|
||||||
|
TextChanged="SearchAlbum_TextChanged" />
|
||||||
<ListView x:Name="AlbumListView"
|
<ListView x:Name="AlbumListView"
|
||||||
ItemsSource="{Binding AlbumItems}"
|
ItemsSource="{Binding AlbumItems}"
|
||||||
VerticalOptions="FillAndExpand"
|
VerticalOptions="FillAndExpand"
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
var albumItem = (sender as ListView).SelectedItem = null;
|
var albumItem = (sender as ListView).SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void SearchAlbum_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var text = e.NewTextValue;
|
||||||
|
_viewModel.SearchAlbums(text);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
Placeholder="Artist"
|
Placeholder="Artist"
|
||||||
SearchCommand="{Binding SearchArtistCommand}"
|
SearchCommand="{Binding SearchArtistCommand}"
|
||||||
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
||||||
Text="{Binding SearchedText, Mode=TwoWay}" />
|
Text="{Binding SearchedText, Mode=TwoWay}"
|
||||||
|
TextChanged="SearchArtist_TextChanged" />
|
||||||
<ListView x:Name="ArtistListView"
|
<ListView x:Name="ArtistListView"
|
||||||
ItemsSource="{Binding ArtistItems}"
|
ItemsSource="{Binding ArtistItems}"
|
||||||
VerticalOptions="FillAndExpand"
|
VerticalOptions="FillAndExpand"
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
var artistItem = (sender as ListView).SelectedItem = null;
|
var artistItem = (sender as ListView).SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void SearchArtist_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var text = e.NewTextValue.ToString();
|
||||||
|
_viewModel.SearchArtists(text);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,11 +225,11 @@ namespace Mear.Views
|
|||||||
await MearPlayer.SeekTo(progVal);
|
await MearPlayer.SeekTo(progVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Download_Clicked(object sender, EventArgs e)
|
private async void Download_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RemoveSyncToolbar();
|
await MearPlayer.DownloadSongToFS();
|
||||||
MearPlayer.DownloadSongToFS();
|
|
||||||
|
|
||||||
|
RemoveSyncToolbar();
|
||||||
ToolbarItems.Add(RemoveOption());
|
ToolbarItems.Add(RemoveOption());
|
||||||
|
|
||||||
_song.Downloaded = true;
|
_song.Downloaded = true;
|
||||||
@@ -237,11 +237,10 @@ namespace Mear.Views
|
|||||||
private async void Remove_Clicked(object sender, EventArgs e)
|
private async void Remove_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RemoveSyncToolbar();
|
RemoveSyncToolbar();
|
||||||
MearPlayer.RemoveSongFromFS();
|
await MearPlayer.RemoveSongFromFS();
|
||||||
|
|
||||||
_song.Downloaded = false;
|
_song.Downloaded = false;
|
||||||
|
|
||||||
|
|
||||||
ToolbarItems.Add(DownloadOption());
|
ToolbarItems.Add(DownloadOption());
|
||||||
}
|
}
|
||||||
private async void PlayCount_Clicked(object sender, EventArgs e)
|
private async void PlayCount_Clicked(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
Placeholder="Title, Artist"
|
Placeholder="Title, Artist"
|
||||||
SearchCommand="{Binding SearchSongsCommand}"
|
SearchCommand="{Binding SearchSongsCommand}"
|
||||||
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
SearchCommandParameter="{Binding SearchedText, Source=x:Reference Search}"
|
||||||
Text="{Binding SerachedText, Mode=TwoWay}">
|
Text="{Binding SerachedText, Mode=TwoWay}"
|
||||||
|
TextChanged="SearchSong_TextChanged" >
|
||||||
</SearchBar>
|
</SearchBar>
|
||||||
<ListView x:Name="SongListView"
|
<ListView x:Name="SongListView"
|
||||||
ItemsSource="{Binding SongItems}"
|
ItemsSource="{Binding SongItems}"
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ namespace Mear.Views
|
|||||||
#region Events
|
#region Events
|
||||||
private async void SongListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
private async void SongListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var i = "here";
|
|
||||||
if (SongListView.SelectedItem == null)
|
if (SongListView.SelectedItem == null)
|
||||||
{
|
{
|
||||||
SongListView.SelectedItem = null;
|
SongListView.SelectedItem = null;
|
||||||
@@ -72,6 +71,12 @@ namespace Mear.Views
|
|||||||
SongListView.SelectedItem = null;
|
SongListView.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SearchSong_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var text = e.NewTextValue.ToString();
|
||||||
|
_viewModel.FilterSongs(text);
|
||||||
|
}
|
||||||
|
|
||||||
private async void SongOptions_Clicked(object sender, EventArgs e)
|
private async void SongOptions_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user