Esempio n. 1
0
        public PredictionPageViewModel(IPageService pageService) : this()
        {
            _pageService = pageService;

            try
            {
                Movie = new InfiniteScrollCollection <MovieShort>()
                {
                    OnLoadMore = async() =>
                    {
                        IsBusy = true;
                        await _pageService.PushAsync(new PopupLoading());

                        var movies = LoadMoreMovies();
                        await _pageService.PopAsync();

                        IsBusy = false;
                        return(movies);
                    },
                    OnCanLoadMore = () => !_isEnded
                };

                var movieList = LoadMoreMovies();
                Movie.AddRange(movieList);
            }
            catch (Exception) { }
        }
Esempio n. 2
0
        private async Task DownloadDataAsync()
        {
            IsBusy = true;
            var items = await movieService.GetMoviesAsync(pageIndex : 1, pageSize : PageSize);

            movies.AddRange(items);
            IsBusy = false;
        }
Esempio n. 3
0
        public async Task <InfiniteScrollCollection <Movie> > GetMoviesAsync(int pageIndex, int pageSize)
        {
            await Task.Delay(2000);

            RestClient <Models.Page> restClient = new RestClient <Models.Page>(Fullurl + pageIndex);

            try
            {
                var res = await restClient.GetAsync();

                InfiniteScrollCollection <Movie> InfiniteList = new InfiniteScrollCollection <Movie>();
                InfiniteList.AddRange(res.results);
                return(InfiniteList);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
        public RepositoryListPageViewModel(IRestService restService,
                                           INavigationService navigationService,
                                           IPageDialogService dialogService)
            : base(navigationService,
                   dialogService)
        {
            this.restApiService = restService;
            this.dialog         = dialogService;

            Items = new InfiniteScrollCollection <Repository>
            {
                OnLoadMore = async() =>
                {
                    IList <Repository> repositoryList = null;
                    try
                    {
                        if (CrossConnectivity.Current.IsConnected)
                        {
                            IsBusy = true;

                            // load the next page

                            var page = (Items.Count / PageSize) + 1;


                            repositoryList = await restApiService.GetAllRepositories(page, PageSize);

                            if (FullList != null && repositoryList != null)
                            {
                                FullList.AddRange(repositoryList);
                            }
                            Debug.WriteLine(Items.Count);

                            IsBusy = false;
                        }
                        else
                        {
                            DisplayAlert("Connectivity", "No Internet, try again later");
                        }
                    }
                    catch
                    {
                        DisplayAlert("Apologies", "Something went wrong");
                    }

                    // return the items that need to be added
                    return(repositoryList);
                },
                OnCanLoadMore = () =>
                {
                    if (!string.IsNullOrEmpty(SearchText))
                    {
                        return(false);
                    }
                    else
                    {
                        return(Items.Count < 1000);
                    }
                }
            };

            FilterCommand = new Command(() =>
            {
                executeFilter();
            });

            GoToPullRequestPageCommand = new Command <object>(async(p) =>
            {
                Repository r = (Repository)p;
                NavigationParameters parameters = new NavigationParameters();
                parameters.Add("repository", r);
                await navigationService.NavigateAsync("PullRequestsPage", parameters);
            });
        }