Beispiel #1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            try
            {
                ViewHolder holder;
                View       row = convertView;
                if (row == null)
                {
                    row    = LayoutInflater.From(context).Inflate(Resource.Layout.toprowsalbum, null, false);
                    holder = new ViewHolder();

                    //holder.imageView = row.FindViewById<ImageView>(Resource.Id.AlbumCover);
                    holder.artistTextView = row.FindViewById <TextView>(Resource.Id.ArtistTextView);
                    holder.albumTextView  = row.FindViewById <TextView>(Resource.Id.AlbumTextView);

                    /*artistTextView.Text = this.albums[position].Artist;
                     * albumTextView.Text = this.albums[position].Name;
                     * imageView.SetImageBitmap(GetImageBitmapFromUrl(this.albums[position].ImageUrl));*/
                    row.Tag = holder;
                }
                else
                {
                    holder = row.Tag as ViewHolder;
                }

                holder.artistTextView.Text = this.albums[position].Artist;
                holder.albumTextView.Text  = this.albums[position].Name;

                if (albumsImages.ContainsKey(this.albums[position].ImageUrl))
                {
                    holder.imageView.SetImageBitmap(albumsImages[this.albums[position].ImageUrl]);
                }
                else
                {
                    this.UpdateImage(holder, position);
                }

                return(row);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
        private async void UpdateImage(ViewHolder holder, int position)
        {
            albumsImages[this.albums[position].ImageUrl] = await GetImageBitmapFromUrl(this.albums[position].ImageUrl);

            holder.imageView.SetImageBitmap(albumsImages[this.albums[position].ImageUrl]);
        }