Exemplo n.º 1
0
        /// <inheritdoc />
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var cell = collectionView.DequeueReusableCell(AlbumViewCell.Key, indexPath) as AlbumViewCell ??
                       new AlbumViewCell();

            if (_imageManager == null)
            {
                return(cell);
            }

            if (cell.Tag != 0)
            {
                _imageManager.CancelImageRequest((int)cell.Tag);
            }

            var asset = AllAssets[(int)indexPath.Item];

            cell.IsVideo  = asset.MediaType == PHAssetMediaType.Video;
            cell.Duration = asset.Duration;

            cell.Tag = _imageManager.RequestImageForAsset(asset, _cellSize, PHImageContentMode.AspectFit, null,
                                                          (result, info) => SetImageCellImage(cell, result));

            return(cell);
        }