Esempio n. 1
0
        private async Task UploadFile(MediaFile file)
        {
            IsFetching = true;
            try
            {
                var newAsset = await ImageClientService.UploadImage(file.GetStream());

                await Page.Navigation.PushAsync(new ImageDetailView <TService>(newAsset.Id));
            }
            catch (Exception e)
            {
                await Page.DisplayAlert("Error", e.Message, "Ok");
            }
            finally
            {
                IsFetching = false;
            }
        }
Esempio n. 2
0
        private async Task Fetch(bool nextPage)
        {
            if (IsFetching)
            {
                return;
            }
            if (Assets.Count > 500)
            {
                return;
            }
            if (CurrentPage == 0)
            {
                Assets.Clear();
            }
            if (nextPage)
            {
                CurrentPage++;
            }
            IsFetching = true;
            try
            {
                var assets = await(string.IsNullOrEmpty(SearchQuery)
                    ? ImageClientService.GetMainGalery(CurrentPage)
                    : ImageClientService.SearchMainGalery(SearchQuery, CurrentPage));

                foreach (var asset in assets)
                {
                    if (asset.ShouldDisplay)
                    {
                        Assets.Add(asset);
                    }
                }
            }
            catch (Exception e)
            {
                await Page.DisplayAlert("Error", e.Message, "Dismiss");
            }
            finally
            {
                IsFetching = false;
            }
        }
Esempio n. 3
0
        private async Task GetComments()
        {
            try
            {
                var comments = await ImageClientService.GetGalleryAssetComments(ImageAsset);

                Comments.Clear();
                if (comments == null || !comments.Any())
                {
                    return;
                }
                foreach (var comment in comments)
                {
                    Comments.Add(comment);
                }
            }
            catch (Exception e)
            {
            }
        }