예제 #1
0
        void ShowActualPhotoPermissionAlert()
        {
            ALAssetsLibrary library = new ALAssetsLibrary();

            library.Enumerate(ALAssetsGroupType.SavedPhotos, HandleALAssetsLibraryGroupsEnumerationResults, delegate(NSError obj)
            {
                FirePhotoPermissionCompletionHandler();
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "All Asset Groups";

            // instantiate a reference to the shared assets library
            assetsLibrary = new ALAssetsLibrary();
            // enumerate the photo albums
            assetsLibrary.Enumerate(ALAssetsGroupType.All, GroupsEnumerator,
                        (NSError e) => { Console.WriteLine ("Could not enumerate albums: " + e.LocalizedDescription); });
        }
예제 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "All Asset Groups";

            // instantiate a reference to the shared assets library
            assetsLibrary = new ALAssetsLibrary();
            // enumerate the photo albums
            assetsLibrary.Enumerate(ALAssetsGroupType.All, GroupsEnumerator,
                                    (NSError e) => { Console.WriteLine("Could not enumerate albums: " + e.LocalizedDescription); });
        }
        static NSUrl fetchMovieUrl()
        {
            NSUrl movieURL   = null;
            var   waitHandle = new AutoResetEvent(false);

            ThreadPool.QueueUserWorkItem(_ => {
                ALAssetsLibrary assetsLibrary = new ALAssetsLibrary();
                assetsLibrary.Enumerate(ALAssetsGroupType.All, (ALAssetsGroup group, ref bool stop) => {
                    if (group == null)
                    {
                        waitHandle.Set();
                        return;
                    }

                    NSDate latest = NSDate.FromTimeIntervalSince1970(0);
                    group.Enumerate((ALAsset result, nint index, ref bool stopGroup) => {
                        if (result == null || result.AssetType != ALAssetType.Video)
                        {
                            return;
                        }

                        NSUrl url = result.DefaultRepresentation.Url;
                        if (url == null)
                        {
                            return;
                        }

                        var diff = result.Date.SecondsSinceReferenceDate - latest.SecondsSinceReferenceDate;
                        if (diff > 0)
                        {
                            latest   = result.Date;
                            movieURL = url;
                        }
                    });

                    stop = movieURL != null;
                }, (error) => {
                    waitHandle.Set();
                });
            });

            waitHandle.WaitOne();

            if (movieURL == null)
            {
                UIAlertView alertView = new UIAlertView(null, "Could not find any movies in assets library to use as sample content.", null, "OK", null);
                alertView.Show();
            }

            return(movieURL);
        }
예제 #5
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                NavigationItem.Title = NSBundle.MainBundle.LocalizedString("Loading", "Loading...");
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear();

                Library = new ALAssetsLibrary();
                Library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                NavigationItem.Title = "Loading...";
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel /*, cancelImagePicker*/);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear();

                Library = new ALAssetsLibrary();
                Library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
        public Task <IList <Picture> > LoadImagesAsync()
        {
            taskCompletionSource = new TaskCompletionSource <IList <Picture> >();
            //Clean the mess
            pictures.Clear();
            var library = new ALAssetsLibrary();

            library.Enumerate(ALAssetsGroupType.All, GroupEnumerator,
                              (NSError e) => {
                Console.WriteLine("Could not enumerate albums: " + e.LocalizedDescription);
            }
                              );


            return(taskCompletionSource.Task);
        }
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();
                var loading = string.IsNullOrWhiteSpace(LoadingTitle) ? NSBundle.MainBundle.GetLocalizedString("Loading", "Loading...") : LoadingTitle;

                NavigationItem.Title = loading;
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                assetGroups.Clear();

                library = new ALAssetsLibrary();
                library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
예제 #9
0
        //AlAssetsGroupSavedPhotos
        public void InitializePhotos()
        {
            assetsLibrary     = new ALAssetsLibrary();
            currentPhotoIndex = -1;
            photoAssets       = new List <ALAsset> (PHOTO_ASSETS_CAPACITY);
            int  photoIndex            = 0;
            bool syncContentController = true;

            assetsLibrary.Enumerate(ALAssetsGroupType.Album, (ALAssetsGroup group, ref bool stop) => {
                if (group != null)
                {
                    string groupName = group.Name;
                    if (groupName.StartsWith(PNALBUM_PREFIX))
                    {
                        group.SetAssetsFilter(ALAssetsFilter.AllPhotos);
                        group.Enumerate((ALAsset asset, int index, ref bool st) => {
                            int notfound = Int32.MaxValue;
                            if (asset != null && index != notfound)
                            {
                                photoAssets.Add(asset);
                                photoIndex++;
                                currentPhotoIndex = 0;
                            }
                            if (photoIndex == PHOTO_ASSETS_CAPACITY)
                            {
                                st = true;
                            }
                        });
                    }
                }

                if (syncContentController)
                {
                    syncContentController = false;
                    DispatchQueue.MainQueue.DispatchAsync(() => {
                        if (currentPhotoIndex == 0)
                        {
                            setCurrentPhotoToIndex(0);
                        }
                        ((PhotoViewController)(ViewController.contentController)).Synchronize(currentPhotoIndex >= 0);
                    });
                }
            },
                                    (NSError error) => {
                Console.WriteLine("User denied access to photo Library... {0}", error);
            });
        }
예제 #10
0
        public void RequestPhotoAccess(bool useImagePicker)
        {
            if (useImagePicker)
            {
                UIImagePickerController picker = new UIImagePickerController();
                picker.Delegate = this;
                PresentViewController(picker, true, null);
            }
            else
            {
                if (assetLibrary == null)
                {
                    assetLibrary = new ALAssetsLibrary();
                }

                assetLibrary.Enumerate(ALAssetsGroupType.All,
                                       delegate { }, delegate { });
            }
        }
예제 #11
0
        private void GetAllAssets()
        {
            var assetsLibrary = new ALAssetsLibrary();

            assetsLibrary.Enumerate(ALAssetsGroupType.All,
                                    (ALAssetsGroup group, ref bool stop) =>
            {
                group?.SetAssetsFilter(ALAssetsFilter.AllPhotos);
                group?.Enumerate((ALAsset asset, nint index, ref bool st) =>
                {
                    int notfound = Int32.MaxValue;
                    if (asset != null && index != notfound)
                    {
                        Images.Add(new AssetImage(asset));
                    }
                });
                ReloadData();
            },
                                    (NSError obj) =>
            {
            });
        }
            public override void ViewDidLoad()
            {
                base.ViewDidLoad ();

                NavigationItem.Title = NSBundle.MainBundle.LocalizedString ("Loading", "Loading...");
                var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);
                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear ();

                Library = new ALAssetsLibrary ();
                Library.Enumerate (ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
예제 #13
0
		//AlAssetsGroupSavedPhotos
		public void InitializePhotos ()
		{
			assetsLibrary = new ALAssetsLibrary ();
			currentPhotoIndex = -1;
			photoAssets = new List<ALAsset> (PHOTO_ASSETS_CAPACITY);
			int photoIndex = 0;
			bool syncContentController = true;
			assetsLibrary.Enumerate (ALAssetsGroupType.Album, ( ALAssetsGroup group, ref bool stop) => {

				if (group != null) {

					string groupName = group.Name;
					if (groupName.StartsWith (PNALBUM_PREFIX)) {
						group.SetAssetsFilter (ALAssetsFilter.AllPhotos);
						group.Enumerate ((ALAsset asset, nint index, ref bool st) => {
							int notfound = Int32.MaxValue;
							if (asset != null && index != notfound) {
								photoAssets.Add (asset);
								photoIndex++;
								currentPhotoIndex = 0;
							}
							if (photoIndex == PHOTO_ASSETS_CAPACITY) {
								st = true;
							}
						});
					}
				}

				if (syncContentController) {
					syncContentController = false;
					DispatchQueue.MainQueue.DispatchAsync (() => {
						if (currentPhotoIndex == 0) {
							setCurrentPhotoToIndex (0);
						}
						((PhotoViewController)(ViewController.contentController)).Synchronize (currentPhotoIndex >= 0);
					});
				}
			},
			(NSError error) => {
				Console.WriteLine ("User denied access to photo Library... {0}", error);
			});
		}
            public override void ViewDidLoad()
            {
                base.ViewDidLoad ();

                NavigationItem.Title = Catalog.GetString ("Loading...");
                var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel/*, cancelImagePicker*/);
                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear ();

                Library = new ALAssetsLibrary ();
                Library.Enumerate (ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
		static NSUrl fetchMovieUrl ()
		{
			NSUrl movieURL = null;
			var waitHandle = new AutoResetEvent (false);

			ThreadPool.QueueUserWorkItem (_ => {
				ALAssetsLibrary assetsLibrary = new ALAssetsLibrary ();
				assetsLibrary.Enumerate (ALAssetsGroupType.All, (ALAssetsGroup group, ref bool stop) => {
					if (group == null) {
						waitHandle.Set ();
						return;
					}

					NSDate latest = NSDate.FromTimeIntervalSince1970(0);
					group.Enumerate ((ALAsset result, nint index, ref bool stopGroup) => {
						if(result == null || result.AssetType != ALAssetType.Video)
							return;

						NSUrl url = result.DefaultRepresentation.Url;
						if (url == null)
							return;

						var diff = result.Date.SecondsSinceReferenceDate - latest.SecondsSinceReferenceDate;
						if(diff > 0) {
							latest = result.Date;
							movieURL = url;
						}
					});

					stop = movieURL != null;
				}, (error) => {
					waitHandle.Set ();
				});
			});

			waitHandle.WaitOne ();

			if (movieURL == null) {
				UIAlertView alertView = new UIAlertView (null, "Could not find any movies in assets library to use as sample content.", null, "OK", null);
				alertView.Show ();
			}

			return movieURL;
		}
 void ShowActualPhotoPermissionAlert()
 {
     ALAssetsLibrary library = new ALAssetsLibrary ();
     library.Enumerate (ALAssetsGroupType.SavedPhotos, HandleALAssetsLibraryGroupsEnumerationResults, delegate (NSError obj)
     {
         FirePhotoPermissionCompletionHandler ();
     });
 }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Gallery.iOS.ImageHandler"/> class.
 /// </summary>
 public ImageHandler()
 {
     _assetLibrary = new ALAssetsLibrary();
     _assets       = new List <string> ();
     _assetLibrary.Enumerate(ALAssetsGroupType.SavedPhotos, GroupEnumerator, Console.WriteLine);
 }