private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var layoutRoot = holder.ItemView; layoutRoot.Post(() => { var width = layoutRoot.Width; var layoutParams = layoutRoot.LayoutParameters; layoutParams.Height = width; layoutRoot.LayoutParameters = layoutParams; }); var thumbnailView = holder.FindCachedViewById<ImageViewAsync>(Resource.Id.Thumbnail); holder.DeleteBinding(thumbnailView); var thumbnailBinding = new Binding<string, string>(item, () => item.Thumbnail) .WhenSourceChanges(() => ImageService.Instance.LoadUrl(item.Thumbnail).Into(thumbnailView)); holder.SaveBinding(thumbnailView, thumbnailBinding); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var thumbnail = holder.FindCachedViewById<ImageViewAsync>(Resource.Id.Thumbnail); thumbnail.Post(() => { var height = item.BigThumbRatio * thumbnail.Width; var layoutParams = thumbnail.LayoutParameters; layoutParams.Height = (int)Math.Floor(height); thumbnail.LayoutParameters = layoutParams; }); holder.DeleteBinding(thumbnail); var imageBinding = new Binding<string, string>(item, () => item.BigThumbnail).WhenSourceChanges(() => { ImageService.Instance.LoadUrl(item.BigThumbnail).Into(thumbnail); }); holder.SaveBinding(thumbnail, imageBinding); var title = holder.FindCachedViewById<TextView>(Resource.Id.TitleTextView); title.Text = item.Title; var ups = holder.FindCachedViewById<TextView>(Resource.Id.UpsTextView); ups.Text = item.Ups.ToString(); var comments = holder.FindCachedViewById<TextView>(Resource.Id.CommentsTextView); comments.Text = item.CommentCount.ToString(); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var hasTitle = !string.IsNullOrEmpty(item.Title); var titleView = holder.FindCachedViewById<TextView>(Resource.Id.TitleTextView); if (hasTitle) titleView.Text = item.Title; else titleView.Visibility = ViewStates.Gone; var image = holder.FindCachedViewById<ImageControl>(Resource.Id.MainImage); image.RenderContent(item); var hasDescription = !string.IsNullOrEmpty(item.Description); var descView = holder.FindCachedViewById<TextView>(Resource.Id.DescriptionTextView); if (hasDescription) descView.Text = item.Description; else descView.Visibility = ViewStates.Gone; }
private void BindGifView(CachingViewHolder holder, GalleryItem item, int position) { var layoutRoot = holder.ItemView; layoutRoot.Post(() => { var width = layoutRoot.Width; var layoutParams = layoutRoot.LayoutParameters; layoutParams.Height = width; layoutRoot.LayoutParameters = layoutParams; }); var thumbnailView = holder.FindCachedViewById<ImageViewAsync>(Resource.Id.Thumbnail); ImageService.Instance.LoadUrl(item.Thumbnail).Into(thumbnailView); }