示例#1
0
        private void SetImageCell(AlbumViewCell cell, MediaItem item, int row)
        {
            DispatchQueue.DefaultGlobalQueue.DispatchAsync(() =>
            {
                using (var image = UIImage.FromFile(item.Path))
                {
                    var scaledImage = image.ScaleImage(_cellSize);

                    DispatchQueue.MainQueue.DispatchAsync(() =>
                    {
                        if (cell.Tag == row)
                        {
                            cell.Image = scaledImage;
                        }
                    });
                }
            });
        }
示例#2
0
        private void SetVideoCell(AlbumViewCell cell, MediaItem item, int row)
        {
            DispatchQueue.DefaultGlobalQueue.DispatchAsync(() =>
            {
                using (var asset = AVAsset.FromUrl(new NSUrl(item.Path)))
                    using (var generator = AVAssetImageGenerator.FromAsset(asset))
                    {
                        generator.AppliesPreferredTrackTransform = true;

                        var duration    = asset.Duration.Seconds;
                        var scaledImage = GetVideoThumbnail(generator, duration, _cellSize);

                        DispatchQueue.MainQueue.DispatchAsync(() =>
                        {
                            if (cell.Tag != row)
                            {
                                return;
                            }
                            cell.Duration = duration;
                            cell.Image    = scaledImage;
                        });
                    }
            });
        }
示例#3
0
 private static void SetImageCellImage(AlbumViewCell cell, UIImage image)
 {
     cell.Image = image;
     cell.Tag   = 0;
 }