Esempio n. 1
0
        private async void OnMoreItemsReady(PhotoBatchResult sender, PhotoBatchResult.EventArgs args)
        {
            var newPhotos = MergePhotos(args.Items);

            if (newPhotos.Count > 0)
            {
                PhotosAdded(this, newPhotos);
                await ShowProgressMessageAsync(Strings.GetProgressIndicatorSearchingPhotosResult(newPhotos.Count));
            }
        }
Esempio n. 2
0
        public Task LoadPersonalPhotosAsync() => Task.Run(async() =>
        {
            var progressId        = ShowProgress(Strings.ProgressIndicator_GettingPhotos);
            IsSearchButtonEnabled = false;
            try
            {
                if (PhotosBatchResult != null)
                {
                    PhotosBatchResult.Cancel          = true;
                    PhotosBatchResult.MoreItemsReady -= OnMoreItemsReady;
                }

                var dates         = GetDates();
                PhotosBatchResult = await App.Model.Photos.GetUsersAsync(User).ConfigureAwait(false);
                PhotosBatchResult.MoreItemsReady += OnMoreItemsReady;
                var newPhotos = MergePhotos(PhotosBatchResult.Items);
                if (newPhotos.Count > 0)
                {
                    PhotosAdded(this, newPhotos);
                }

                HideProgress(progressId, Strings.GetProgressIndicatorSearchingPhotosResult(newPhotos.Count));
            }
            catch (VkRequestException authorizationFailed) when(authorizationFailed.ErrorCode == 5)
            {
                AuthorizationFailed(this, EventArgs.Empty);
                HideProgress(progressId, Strings.ProgressIndicator_SearchingPhotosResult_Error);
            }
            catch (Exception exception)
            {
                App.Diagnostics.Error.Log("MapContext.LoadPersonalPhotosAsync", exception);
                HideProgress(progressId, Strings.ProgressIndicator_SearchingPhotosResult_Error);
            }
            finally
            {
                IsSearchButtonEnabled = true;
            }
        });