/// <summary> /// Provide a view containing either album or song details at the specified position /// Attempt to reuse the supplied view if it previously contained the same type of detail. /// </summary> /// <param name="groupPosition"></param> /// <param name="childPosition"></param> /// <param name="isLastChild"></param> /// <param name="convertView"></param> /// <param name="parent"></param> /// <returns></returns> protected override View GetSpecialisedChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { if (Groups[groupPosition] is SongPlaylist playlist) { // If no view supplied then create a new one if (convertView == null) { convertView = inflator.Inflate(Resource.Layout.playlists_song_layout, null); convertView.Tag = new SongViewHolder() { SelectionBox = GetSelectionBox(convertView), Artist = convertView.FindViewById <TextView>(Resource.Id.artist), Title = convertView.FindViewById <TextView>(Resource.Id.title), Duration = convertView.FindViewById <TextView>(Resource.Id.duration) }; } // Display the SongPlaylistItem (( SongViewHolder )convertView.Tag).DisplaySong(( SongPlaylistItem )playlist.PlaylistItems[childPosition]); // If this song is currently being played then show with a different background convertView.SetBackgroundColor((playlist.SongIndex == childPosition) ? Color.AliceBlue : Color.Transparent); } else { // If the supplied view is null then create one if (convertView == null) { convertView = inflator.Inflate(Resource.Layout.playlists_album_layout, null); convertView.Tag = new AlbumViewHolder() { SelectionBox = GetSelectionBox(convertView), AlbumName = convertView.FindViewById <TextView>(Resource.Id.albumName), ArtistName = convertView.FindViewById <TextView>(Resource.Id.artist), Year = convertView.FindViewById <TextView>(Resource.Id.year), Genre = convertView.FindViewById <TextView>(Resource.Id.genre), }; } // Display the album AlbumPlaylist albumPlaylist = ( AlbumPlaylist )Groups[groupPosition]; Album album = ((AlbumPlaylistItem)albumPlaylist.PlaylistItems[childPosition]).Album; (( AlbumViewHolder )convertView.Tag).DisplayAlbum(album, ActionMode, album.Genre); // If this album is currently being played then show it with a different background convertView.SetBackgroundColor(albumPlaylist.InProgressAlbum == album ? Color.AliceBlue : Color.Transparent); } return(convertView); }
/// <summary> /// Called to display a particular song /// </summary> /// <param name="position"></param> /// <param name="convertView"></param> /// <param name="parent"></param> /// <returns></returns> public override View GetView( int position, View convertView, ViewGroup parent ) { if ( convertView == null ) { convertView = inflator.Inflate( Resource.Layout.popup_song_layout, null ); convertView.Tag = new SongViewHolder() { Title = convertView.FindViewById<TextView>( Resource.Id.title ), Duration = convertView.FindViewById<TextView>( Resource.Id.duration ) }; } // Display the song ( ( SongViewHolder )convertView.Tag ).DisplaySong( songs[ position ] ); // If this song is currently being played then show it with a different background convertView.SetBackgroundColor( songs[ position ].Id == lastPlayedSongId ? Color.AliceBlue : Color.Transparent ); return convertView; }