Exemple #1
0
        static void AddHeroImage(this MessageCell cell, NSIndexPath indexPath, string imageUrl)
        {
            var index = cell.AddHeroImage();

            cell.HeroImageViews [index].SetCacheFormat(getCacheFormat(MessageCell.HeroScaledImageSize));

            if (string.IsNullOrEmpty(imageUrl))
            {
                cell.SetHeroImage(indexPath.Row, index, null);
            }
            else
            {
                var placeholder = getPlaceholderImage(MessageCell.HeroScaledImageSize);

                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);
                    });
                }
            }
        }
Exemple #2
0
        static void SetHeader(this MessageCell cell, NSIndexPath indexPath, BotMessage message)
        {
            cell.SetHeader(message.LocalTimeStamp, message.Activity?.From?.Name);

            cell.ImageView.SetCacheFormat(getCacheFormat(MessageCell.AvatarImageSize));

            if (message.Activity.From.Id == "DigitalAgencies")
            {
                cell.SetAvatar(indexPath.Row, UIImage.FromBundle("avatar_microsoft"));
            }
            else
            {
                var avatarUrl = string.IsNullOrEmpty(message.Activity?.From?.Id) ? string.Empty : BotClient.Shared.GetAvatarUrl(message.Activity.From.Id);

                if (string.IsNullOrEmpty(avatarUrl))
                {
                    cell.SetAvatar(indexPath.Row, null);
                }
                else
                {
                    var placeholder = getPlaceholderImage(MessageCell.AvatarImageSize);

                    using (NSUrl url = new NSUrl(avatarUrl))
                    {
                        cell?.ImageView.SetImage(url, placeholder, (img) => cell.SetAvatar(indexPath.Row, img), (err) =>
                        {
                            cell.SetAvatar(indexPath.Row, null);

                            Log.Debug(err.LocalizedDescription);
                        });
                    }
                }
            }
        }