protected async override Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
            var result = await CloudService.GetRandomImages((int)DEFAULT_PER_PAGE, CTSFactory.MakeCTS(5000).Token);

            if (result.IsRequestSuccessful)
            {
                var list = UnsplashImage.ParseListFromJson(result.JsonSrc);
                UpdateHintVisibility(list);
                return(list);
            }
            else
            {
                throw new APIException();
            }
        }
Exemplo n.º 2
0
        private void ListControl_OnClickItemStarted(UnsplashImage img, FrameworkElement container)
        {
            _clickedContainer = container;
            _clickedImg       = img;

            DetailControl.Visibility = Visibility.Visible;
            if (DetailControl.ActualHeight == 0)
            {
                _waitForToggleDetailAnimation = true;
            }
            else
            {
                _waitForToggleDetailAnimation = false;
                ToggleDetailControlAnimation();
            }
        }
        protected async override Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
            var result = await CloudService.SearchImages(pageIndex, (int)20, CTSFactory.MakeCTS(10000).Token, _keyword);

            if (result.IsRequestSuccessful)
            {
                var rootObj     = JsonObject.Parse(result.JsonSrc);
                var resultArray = JsonParser.GetJsonArrayFromJsonObj(rootObj, "results");
                var list        = UnsplashImage.ParseListFromJson(resultArray.ToString());
                UpdateHintVisibility(list);
                return(list);
            }
            else
            {
                throw new APIException();
            }
        }
Exemplo n.º 4
0
        protected async virtual Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
#if DEBUG
            var cts = CTSFactory.MakeCTS();
#else
            var cts = CTSFactory.MakeCTS(15000);
#endif
            try
            {
                var result = await CloudService.GetImages(pageIndex, (int)20u, cts.Token, RequestUrl);

                if (result.IsRequestSuccessful)
                {
                    IEnumerable <UnsplashImageBase> list = null;
                    if (Featured)
                    {
                        list = UnsplashFeaturedImage.ParseListFromJson(result.JsonSrc);
                    }
                    else
                    {
                        list = UnsplashImage.ParseListFromJson(result.JsonSrc);
                    }
                    await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        UpdateHintVisibility(list);
                    });

                    return(list);
                }
                else
                {
                    throw new ArgumentNullException();
                }
            }
            catch (Exception e)
            {
                await Logger.LogAsync(e);

                return(new List <UnsplashImage>());
            }
        }
        protected async virtual Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
            var result = await CloudService.GetImages(pageIndex, (int)DEFAULT_PER_PAGE, CTSFactory.MakeCTS(10000).Token, RequestUrl);

            if (result.IsRequestSuccessful)
            {
                if (Featured)
                {
                    var list = UnsplashFeaturedImage.ParseListFromJson(result.JsonSrc);
                    UpdateHintVisibility(list);
                    return(list);
                }
                else
                {
                    var list = UnsplashImage.ParseListFromJson(result.JsonSrc);
                    UpdateHintVisibility(list);
                    return(list);
                }
            }
            else
            {
                throw new APIException();
            }
        }