Ejemplo n.º 1
0
        public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var asset = (PHAsset)AssetsFetchResults[indexPath.Item];

            _picker.SelectAsset(asset);
            _picker.NotifyAssetSelected(asset);
        }
        public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var asset = (PHAsset)AssetsFetchResults[indexPath.Item];
            var cell  = (GMGridViewCell)collectionView.CellForItem(indexPath);

            _picker.SelectAsset(asset);
            _picker.NotifyAssetSelected(asset);
            ConfigureSelectCellAccessibilityAttributes(cell, true, null);
        }
Ejemplo n.º 3
0
        public void PhotoLibraryDidChange(PHChange changeInstance)
        {
            Debug.WriteLine($"{this.GetType().Name}: PhotoLibraryDidChange");
            // Call might come on any background queue. Re-dispatch to the main queue to handle it.
            DispatchQueue.MainQueue.DispatchAsync(() => {
                List <PHFetchResult> updatedCollectionsFetchResults = null;

                foreach (var collectionsFetchResult in _collectionsFetchResults)
                {
                    var changeDetails = changeInstance.GetFetchResultChangeDetails(collectionsFetchResult);
                    if (changeDetails != null)
                    {
                        if (updatedCollectionsFetchResults == null)
                        {
                            updatedCollectionsFetchResults = _collectionsFetchResults.ToList();
                        }
                        updatedCollectionsFetchResults[updatedCollectionsFetchResults.IndexOf(collectionsFetchResult)] = changeDetails.FetchResultAfterChanges;
                    }

                    // This only affects to changes in albums level (add/remove/edit album)
                    if (updatedCollectionsFetchResults != null)
                    {
                        _collectionsFetchResults = updatedCollectionsFetchResults;
                    }
                }

                // Search for new photos and select them if camera is turned on
                if (_picker.AutoSelectCameraImages && _picker.ShowCameraButton)
                {
                    foreach (var collection in _collectionsFetchResultsAssets)
                    {
                        foreach (var fetchResult in collection)
                        {
                            var changeDetails = changeInstance.GetFetchResultChangeDetails(fetchResult);

                            if (changeDetails != null && changeDetails.InsertedObjects != null)
                            {
                                foreach (var asset in changeDetails.InsertedObjects.OfType <PHAsset>())
                                {
                                    _picker.SelectAsset(asset);
                                }
                            }
                        }
                    }
                }

                // However, we want to update if photos are added, so the counts of items & thumbnails are updated too.
                // Maybe some checks could be done here , but for now is OKey.
                UpdateFetchResults();

                TableView.ReloadData();
            });
        }