public void PhotoLibraryDidChange(PHChange changeInstance) { // Call might come on any background queue. Re-dispatch to the main queue to handle it. DispatchQueue.MainQueue.DispatchAsync(() => { // Check if there are changes to the asset we're displaying. PHObjectChangeDetails changeDetails = changeInstance.GetObjectChangeDetails(Asset); if (changeDetails == null) { return; } // Get the updated asset. // TODO: check return type. Catch! ObjectAfterChanges should be PHObject instead of NSObject https://bugzilla.xamarin.com/show_bug.cgi?id=35540 Asset = (PHAsset)changeDetails.ObjectAfterChanges; if (Asset != null) { FavoriteButton.Title = Asset.Favorite ? "♥︎" : "♡"; } // If the asset's content changed, update the image and stop any video playback. if (changeDetails.AssetContentChanged) { UpdateImage(); playerLayer?.RemoveFromSuperLayer(); playerLayer = null; } }); }
public void PhotoLibraryDidChange(PHChange changeInstance) { // Call might come on any background queue. Re-dispatch to the main queue to handle it. DispatchQueue.MainQueue.DispatchAsync(() => { // Check if there are changes to the asset we're displaying. PHObjectChangeDetails changeDetails = changeInstance.GetObjectChangeDetails(Asset); if (changeDetails == null) { return; } // Get the updated asset. var assetAfterChanges = changeDetails.ObjectAfterChanges as PHAsset; if (assetAfterChanges == null) { return; } Asset = (PHAsset)assetAfterChanges; if (Asset != null) { FavoriteButton.Title = Asset.Favorite ? "♥︎" : "♡"; } // If the asset's content changed, update the image and stop any video playback. if (changeDetails.AssetContentChanged) { UpdateContent(); playerLayer?.RemoveFromSuperLayer(); playerLayer = null; playerLooper = null; } }); }
public void PhotoLibraryDidChange (PHChange changeInstance) { // Call might come on any background queue. Re-dispatch to the main queue to handle it. DispatchQueue.MainQueue.DispatchAsync (() => { // Check if there are changes to the asset we're displaying. PHObjectChangeDetails changeDetails = changeInstance.GetObjectChangeDetails (Asset); if (changeDetails == null) return; // Get the updated asset. // TODO check return type. Catch! ObjectAfterChanges should be PHObject instead of NSObject https://bugzilla.xamarin.com/show_bug.cgi?id=35540 Asset = (PHAsset)changeDetails.ObjectAfterChanges; // If the asset's content changed, update the image and stop any video playback. if (changeDetails.AssetContentChanged) { UpdateImage (); RemovePlayerLayer (); } }); }