static void AddHeroImage(this MessageCell cell, int row, string imageUrl) { var index = cell.AddHeroImage(); //cell.HeroImageViews [index].SetCacheFormat (getCacheFormat (MessageCell.HeroScaledImageSize)); if (string.IsNullOrEmpty(imageUrl)) { cell.SetHeroImage(row, index, null); } else { var placeholder = getPlaceholderImage(MessageCell.HeroScaledImageSize); Glide.With(cell.Context).Load(imageUrl).Placeholder(placeholder).Into(cell.HeroImageViews [index]); //using (NSUrl url = new NSUrl (imageUrl)) //{ // cell?.HeroImageViews [index].SetImage (url, placeholder, (img) => cell.SetHeroImage (indexPath.Row, index, img), (err) => // { // cell.SetHeroImage (indexPath.Row, index, null); // Log.Debug (err.LocalizedDescription); // }); //} } }
public static void SetMessageCell(this List <BotMessage> messages, MessageCell cell, int row) { if (messages?.Count > 0 && messages.Count > row) { var message = messages [row]; //var cell = holder.ItemView as MessageCell; cell.Key = row; if (message.Head) { cell.SetHeader(row, message); } if (message.HasText) { cell.SetMessage(message.AttributedText); } if (message.HasAtachments) { foreach (var attachment in message.Attachments) { // images if (attachment.Content.HasImages) { foreach (var image in attachment.Content.Images) { cell.AddHeroImage(row, image.Url); } } // title if (attachment.Content.HasTitle) { cell.AddAttachmentTitle(attachment.Content.AttributedTitle); } // subtitle if (attachment.Content.HasSubtitle) { cell.AddAttachmentSubtitle(attachment.Content.AttributedSubtitle); } // text if (attachment.Content.HasText) { cell.AddAttachmentText(attachment.Content.AttributedText); } // buttons if (attachment.Content.HasButtons) { cell.SetButtons(attachment.Content.Buttons.Select(b => (b.Title, b.Value.ToString())).ToArray()); } } } // Cells must inherit the table view's transform // This is very important, since the main table view may be inverted //cell.Transform = tableView.Transform; //return cell; } //return null; }