public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (!(holder is QueueItemHolder itemHolder)) { return; } var local = _songs[position]; itemHolder.Title.Text = local.Title; itemHolder.Artist.Text = local.ArtistName; if (MusicPlayer.GetCurrentAudioId() == local.Id) { itemHolder.Title.SetTextColor(new Color(MusicUtils.GetAccentColor(_context))); if (MusicPlayer.IsPlaying()) { itemHolder.Visualizer.SetColor(MusicUtils.GetAccentColor(_context)); itemHolder.Visualizer.Visibility = ViewStates.Visible; } } else { itemHolder.Title.SetTextColor(new Color(MusicUtils.GetTextColorPrimary(_context))); itemHolder.Visualizer.Visibility = ViewStates.Gone; } var builder = new DisplayImageOptions.Builder() .CacheInMemory(true) .ShowImageOnFail(Resource.Drawable.ic_empty_music2) .ResetViewBeforeLoading(true) .Build(); ImageLoader.Instance.DisplayImage(MusicUtils.GetAlbumArtUri(local.AlbumId).ToString(), itemHolder.AlbumArt, builder); itemHolder.PopupMenu.Click += (s, e) => OnPopupMenuClick(s, e, position); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (!(holder is AlbumItemHolder itemHolder)) { return; } var localAlbum = _albums[position]; _itemHolder = itemHolder; itemHolder.Title.Text = localAlbum.Title; itemHolder.Artist.Text = localAlbum.ArtistName; ImageLoader.Instance.DisplayImage(MusicUtils.GetAlbumArtUri(localAlbum.Id).ToString(), itemHolder.AlbumArt, new DisplayImageOptions.Builder().CacheInMemory(true) .ShowImageOnFail(Resource.Drawable.ic_empty_music2) .ResetViewBeforeLoading(true) .Displayer(new FadeInBitmapDisplayer(400)) .Build(), new ImageLoadingListener() { LoadingComplete = (loadedImage) => { if (_isGrid) { new Palette.Builder(loadedImage).Generate(this); } }, LoadingFailed = () => { if (_isGrid) { itemHolder.Footer.SetBackgroundColor(Color.White); if (_context != null) { var textColor = new Color(MusicUtils.GetTextColorPrimary(_context)); itemHolder.Title.SetTextColor(textColor); itemHolder.Artist.SetTextColor(textColor); } } } } ); }