public SimpleViewModel() { var dataSource = new FakeDataSource(); Items = new InfiniteScrollCollection <DataItem> { OnLoadMore = async() => { // load the next page var page = Items.Count / PageSize; var items = await dataSource.GetItemsAsync(page + 1, PageSize); return(items); } }; RefreshCommand = new Command(() => { // clear and start again Items.Clear(); Items.LoadMoreAsync(); }); // load the initial data Items.LoadMoreAsync(); }
InfiniteScrollCollection <EventListModel> GetItems(bool clearList, List <News> eventItemList) { InfiniteScrollCollection <EventListModel> items; if (clearList || Items == null) { items = new InfiniteScrollCollection <EventListModel>(); } else { items = new InfiniteScrollCollection <EventListModel>(Items); } foreach (var eventItem in eventItemList) { items.Add(new EventListModel { Title = UppercaseFirst(eventItem.Title), SubTitle = UppercaseFirst(eventItem.SubTitle), Place = UppercaseFirst(eventItem.Place), Day = eventItem.StartDate.ToString("dddd"), Date = eventItem.StartDate.ToString("dd MMMM"), Year = eventItem.StartDate.ToString("yyyy"), Color = "#" + GetRandamColor() }); } return(items); }
InfiniteScrollCollection <Products> GetItems(bool clearList, List <WSProduct> productItemList) { InfiniteScrollCollection <Products> items; if (clearList || Items == null) { items = new InfiniteScrollCollection <Products>(); } else { items = new InfiniteScrollCollection <Products>(Items); } foreach (var productItem in productItemList) { items.Add(new Products { Title = UppercaseFirst(productItem.PName), Description = UppercaseFirst(productItem.PDescription), ImageUrl = productItem.PictureUrl, Price = Convert.ToString(productItem.PPriceIncVAT) + " kr", }); } return(items); }
public MainViewModel() { Items = new InfiniteScrollCollection <ForumData> { OnLoadMore = async() => { IsBusy = true; // load the next page var page = Items.Count / PageSize; var items = await dataService.GetForumDataAsync(page + 1, PageSize); IsBusy = false; // return the items that need to be added return(items); //njkjk }, OnCanLoadMore = () => { int testvar2 = dataService.GetCountAsync(); int testvar = Items.Count; return(Items.Count != 35); } }; AddItems(); }
//protected override async void PullData() //{ // ApiResponse<MovieList> response; // //using (UserDialogs.Instance.Loading()) // //{ // response = await _movieService.GetUpComingMovieRequest(); // //} // response.Check((result) => // { // MovieList = _movieService.GetMovieList(result); // }, async (statusCode) => // { // await HandleApiError(statusCode, async (errorCode) => await _dialogService.ShowDialogAsync(statusCode)); // }); //} //protected override async void SearchData(string keyword) //{ // ApiResponse<MovieList> response; // // using (UserDialogs.Instance.Loading()) // //{ // response = await _movieService.GetUpComingMovieRequest(); // //} // response.Check((result) => // { // MovieList = _movieService.GetMovieSearchData(result, keyword); // }, async (statusCode) => // { // await HandleApiError(statusCode, async (errorCode) => await _dialogService.ShowDialogAsync(statusCode)); // }); //} protected override void PullData() { ApiResponse <MovieList> response; Task.Run(async() => { MovieList = new InfiniteScrollCollection <Movie> { OnLoadMore = async() => { //await Task.Delay(2000); List <Movie> movie = null; var page = MovieList.Count / pageSize + 1; if (MovieList.Count != 0 && MovieList.Count < pageSize) { return(movie); } response = await _movieService.GetUpComingMovieRequest(page); response.Check((result) => { movie = _movieService.GetMovieList(result); }); return(movie); } }; await MovieList.LoadMoreAsync(); }).Wait(); }
InfiniteScrollCollection <DataItem> GetItems(bool clearList, int COUNT) { InfiniteScrollCollection <DataItem> items; if (clearList || Items == null) { items = new InfiniteScrollCollection <DataItem>(); } else { items = new InfiniteScrollCollection <DataItem>(Items); } int SKIP = COUNT * 10; var obj = homeItems.Skip(SKIP).Take(10); foreach (DataItem item in obj) { items.Add(new DataItem { Title = item.Title.ToString(), ImageUrl = item.ImageUrl }); } return(items); }
public override async Task InitializeAsync(object navigationData) { IsBusy = true; try { var list = await GetMoreUpComingAsync(); Upcoming = new InfiniteScrollCollection <Movie>(list); Upcoming.OnLoadMore += GetMoreUpComingAsync; Upcoming.OnCanLoadMore = () => _hasMorePages; IsEmpty = list.Count() == 0; } catch (RestRequestException ex) { IsEmpty = true; MessagingCenter.Send(this, AppSettings.DialogMessage, ex.Message); } catch (Exception ex) { IsEmpty = true; MessagingCenter.Send(this, AppSettings.DialogMessage, "Ocorreu um erro inesperado ao obter lista de Filmes"); } finally { IsBusy = false; } }
public MainPage() { InitializeComponent(); SetupDataTemplates(); listView.ItemTemplate = new PostTemplateSelector { ImageTemplate = imageTemplate, UnsupportedTemplate = unsupportedTemplate }; Items = new InfiniteScrollCollection <Models.Post> { OnLoadMore = async() => { var result = await PostDataService.GetPosts(25, After); var items = result.Item1; After = result.Item2; return(items); } }; Populate(); }
public MovieViewModel() { movies = new InfiniteScrollCollection <Movie> { OnLoadMore = async() => { IsBusy = true; // load the next page var page = movies.Count / PageSize; var items = await movieService.GetMoviesAsync(page, PageSize); IsBusy = false; // return the items that need to be added return(items); }, OnCanLoadMore = () => { return(movies.Count < 100); } }; _ = DownloadDataAsync(); }
public MovieViewModel() { try { Items = new InfiniteScrollCollection <Result> { OnLoadMore = async() => { IsBusy = true; var page = Items.Count / PageSize; var items = await _dataService.GetItemsAsync(page, PageSize); IsBusy = false; return(items); }, OnCanLoadMore = () => { return(Items.Count > 0); } }; DownloadDataAsync(); } catch (System.Exception ex) { App.Current.MainPage.DisplayAlert("Oops...", "Deu Ruim na conexão. Tente Novamente", "Ok"); } }
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) { } }
public ScrollListViewModel(ObservableCollection <MovieShort> moviesList, LoadMore loadMethod, IPageService pageService) : this() { _loadMore = loadMethod; _pageService = pageService; try { Movie = new InfiniteScrollCollection <MovieShort>(moviesList) { OnLoadMore = async() => { IsBusy = true; await _pageService.PushAsync(new PopupLoading()); var movies = LoadMoreMovies(); await _pageService.PopAsync(); IsBusy = false; return(movies); }, OnCanLoadMore = () => !_isEnded }; } catch (Exception) { } }
// PartyDetailBindData /// <summary> /// This for integrating data in view model from API /// </summary> /// <returns></returns> InfiniteScrollCollection <PartyListModel> GetItems(bool clearList, List <Candidature> Party, string voteButtonStatus, string VotepopUpStatus) { InfiniteScrollCollection <PartyListModel> items; if (clearList || Items == null) { items = new InfiniteScrollCollection <PartyListModel>(); } else { items = new InfiniteScrollCollection <PartyListModel>(Items); } foreach (var partyItem in Party) { items.Add(new PartyListModel { partyID = Convert.ToString(partyItem.CandidatureCode), partyImg = partyItem.Image, partyName = partyItem.CandidatureName, partySortName = partyItem.CandidatureSortName, voteButtonVisiblity = voteButtonStatus == "1" ? false : true, voteImag = voteButtonStatus == "1" ? "votepartiesNew1.png" : "vote_button_green1.png" }); } return(items); }
InfiniteScrollCollection <NewsItems> GetItems(bool clearList, List <wsNews> newsItemList) { InfiniteScrollCollection <NewsItems> items; if (clearList || Items == null) { items = new InfiniteScrollCollection <NewsItems>(); } else { items = new InfiniteScrollCollection <NewsItems>(Items); } foreach (var newsItem in newsItemList) { items.Add(new NewsItems { Title = UppercaseFirst(newsItem.Title), Description = UppercaseFirst(newsItem.SubTitle), ImageUrl = newsItem.PictureUrl }); } return(items); }
public MoviesSearchViewModel() { SearchCommand = new Command(() => { Items = new InfiniteScrollCollection <Result> { OnLoadMore = async() => { IsBusy = true; var page = Items.Count / PageSize; var items = await _dataService.GetSearchAsync(Term, page, PageSize); IsBusy = false; return(items); }, OnCanLoadMore = () => { return(Items.Count > 0); } }; DownloadDataAsync(); }); }
public MainViewModel() { Movies = new InfiniteScrollCollection <MoviesNewClass.Resultado> { //todo scrool dispara esse evento OnLoadMore = async() => { IsBusy = true; pageIndex++; var movies = await _service.GeAllMovies(pageIndex); IsBusy = false; ClearOld(); return(movies); } }; RefreshCommand = new Command(() => { // clear and start again Movies.Clear(); Movies.LoadMoreAsync(); }); Movies.LoadMoreAsync(); }
public StoreViewModel() { StoreCollection = new InfiniteScrollCollection <object>(); StoreCollection.OnCanLoadMore = () => StoreCollection.Count < TotalCount; StoreCollection.OnLoadMore += async() => { return(await LoadData(SelectedItem.Type)); }; }
public GroupedViewModel() { var dataSource = new FakeDataSource(); Items = new InfiniteScrollCollection <GroupCollection <DataItem> > { OnLoadMore = async() => { // load the next page var page = Items.Sum(i => i.Count) / PageSize; var items = await dataSource.GetItemsAsync(page + 1, PageSize); // go through each group from the server foreach (var group in items.GroupBy(i => i.Group)) { // look to see if these items belong to any existing groups var inList = Items.LastOrDefault(i => i.Group == group.Key); if (inList != null) { // this is an existing group, so add the items to that foreach (var item in group) { inList.Add(item); } // TODO: instead of adding each item individually, we could make use of // the RangedObservableCollection from the NuGet: // https://github.com/mattleibow/RangedObservableCollection // this would become: // // inList.AddRange(group); } else { // this is a new group Items.Add(new GroupCollection <DataItem>(group) { Group = group.Key }); } } return(null); // we have added the items ourselves } }; RefreshCommand = new Command(() => { // clear and start again Items.Clear(); Items.LoadMoreAsync(); }); // load the initial data Items.LoadMoreAsync(); }
/// <summary> /// Loads this instance. /// </summary> /// <returns></returns> private async Task <InfiniteScrollCollection <MessageViewModel> > Load() { var list = new InfiniteScrollCollection <MessageViewModel>(); List <ImapMessageInfo> msgs = await loader.LoadMessages(); foreach (var i in msgs) { list.Add(new MessageViewModel(i)); } IsBusy = false; return(list); }
public MainViewModel() { Items = new InfiniteScrollCollection <InstagramModel> { OnLoadMore = async() => { IsBussy = true; var items = await GetWaifus(); IsBussy = false; return(items); } }; GetData(); Histories = new ObservableCollection <InstagramModel>(new List <InstagramModel> { new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/65.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/0.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/men/46.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/54.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/men/24.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/64.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/13.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/18.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/17.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/70.jpg", UserName = "******" }, new InstagramModel { ProfilePicture = "https://randomuser.me/api/portraits/women/91.jpg", UserName = "******" }, new InstagramModel { UserName = "******", ProfilePicture = "https://randomuser.me/api/portraits/men/3.jpg" } }); }
public CarrouselMoviesViewModel() { Title = "Movies List"; ; ItemsMovie = new InfiniteScrollCollection <MoviesModel>(); ItemTresholdReachedCommand = new Command(async() => await ItemsTresholdReached()); ShowMovieDetailCommand = new Command(async() => await ExecuteMovieDetail()); RefreshItemsCommand = new Command(async() => { await ExecuteLoadItemsCommand(); IsRefreshing = false; }); }
public GroupViewList() { InitializeComponent(); //BindingContext = new GroupListViewModel(); Items = new InfiniteScrollCollection <ObservableGroupCollection <string, Items> > { OnLoadMore = async() => { // load the next page IsWorking = true; ListItemsCount = 0; foreach (var _itemslist in Items) { ListItemsCount += _itemslist.Count; } double _pagecount = (double)ListItemsCount / PageSize; var page = Convert.ToInt32(Math.Ceiling(_pagecount)); var items = await DataItems.GetItemsAsync(page, PageSize); var _items = items.GroupBy(e => e.Title).Select(e => new ObservableGroupCollection <string, Items>(e)).ToList(); if (_items.Count > 0) { foreach (var getGroupItems in _items.GroupBy(i => i.Header).ToList()) { var _GetExistingGroupItems = Items.LastOrDefault(i => i.Header == getGroupItems.Key); if (_GetExistingGroupItems != null && _GetExistingGroupItems.Count > 0) { // this is an existing group, so add the items to that foreach (var _ExistingGroupedItems in getGroupItems.ToList()) { foreach (var _GroupListitems in _ExistingGroupedItems.ToList()) { _GetExistingGroupItems.Add(_GroupListitems); //Update items } } } else { //Add new Group Items.AddRange(getGroupItems); GroupItems.ItemsSource = Items; } } } IsWorking = false; return(null); } }; loadDataAsync(); }
public MainPageViewModel(INavigationService navigationService, IPokeApi pokeApi, IPageDialogService pageDialogService) : base(navigationService) { Title = "Main Page"; _pokeApi = pokeApi; _pageDialogService = pageDialogService; NavegarCommand = new DelegateCommand <Pokemon>(async(pokemon) => await NavegarCommandExecute(pokemon)); GaleriaCommand = new DelegateCommand <Pokemon>(async(pokemon) => await GaleriaCommandExecute(pokemon)); RefreshCommand = new DelegateCommand(async() => await RefreshCommandExecute()); Pokemons = new InfiniteScrollCollection <Pokemon> { OnLoadMore = async() => { IsBusy = true; var items = new List <Pokemon>(); PokemonList = await _pokeApi.ObterListaPokemons(offset : OffSet); if (PokemonList != null) { foreach (var poke in PokemonList.results) { var pokemon = await _pokeApi.ObterPokemon(poke.url); if (pokemon != null) { items.Add(pokemon); } } offset += 20; } IsBusy = false; return(items); }, OnCanLoadMore = () => { if (!string.IsNullOrEmpty(PokemonList.next)) { return(true); } return(false); } }; Pokemons.LoadMoreAsync(); }
public TaskPageModel() { canLoadMore = true; PerformSearch = new Command(PerformSearchExcute); JobsList = new InfiniteScrollCollection <JobEmployerDataModel>(); GetJobList = new ObservableCollection <JobEmployerDataModel>(); TempjobList = new ObservableCollection <JobEmployerDataModel>(); showlist = true; thereisnodata = false; Device.BeginInvokeOnMainThread(async() => { await GetInfintyData(pagenumber); }); }
public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IRestRepository restRepository) : base(navigationService) { PageDialogService = pageDialogService; RestRepository = restRepository; SourceCoins = new List <Coin>(); Coins = new InfiniteScrollCollection <Coin> { OnLoadMore = OnLoadList(), OnCanLoadMore = () => Coins.Count < SourceCoins.Count }; SearchCommand = new DelegateCommand(Search); ItemTappedCommand = new DelegateCommand(async() => await ShowCoinDetails()); RefreshCommand = new DelegateCommand(async() => await GetCoins()); RefreshCommand.Execute(); }
public MarketHistoryPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IRestRepository restRepository) : base(navigationService) { PageDialogService = pageDialogService; RestRepository = restRepository; SourceList = new List <MarketHistory>(); MarketHistories = new InfiniteScrollCollection <MarketHistory> { OnLoadMore = async() => { var page = MarketHistories.Count / PageSize; return(await Task.Run(() => LoadMarketHistory(page))); }, OnCanLoadMore = () => MarketHistories.Count < SourceList.Count }; RefreshCommand = new DelegateCommand(async() => await GetMarketHistory()); }
public SearchRequestViewModel() { apiService = new ApiServices(); StatusList = GetStatus().OrderBy(t => t.name).ToList(); Task.Run(async() => { Requests = new InfiniteScrollCollection <Request> { OnLoadMore = async() => { //IsRefreshing = true; // load the next page var page = Requests.Count / PageSize; var _searchModel = new SearchModel { maxResult = 200, order = "desc", sortedBy = "request_creation_date", date = CheckDateFrom, date1 = CheckDateTo, status = SelectedStatus.name }; var cookie = Settings.Cookie; var res = cookie.Substring(11, 32); var response = await apiService.PostRequest <Request>( "https://portalesp.smart-path.it", "/Portalesp", "/request/searchRequest?mobile=mobile", res, _searchModel); requestsList = (List <Request>)response.Result; //IsRefreshing = false; return(requestsList); }, OnCanLoadMore = () => { return(Requests.Count < 100 * PageSize); // return Requests.Count < TotalCount; } }; // GetRequests(); await Requests.LoadMoreAsync(); }); }
/// <summary> /// Initializes a new instance of the <see cref="ListViewModel"/> class. /// </summary> /// <param name="page">The page.</param> public ListViewModel(Page page) { this.page = page; Messages = new InfiniteScrollCollection <MessageViewModel> { OnLoadMore = async() => { IsBusy = true; var list = await Load(); IsBusy = false; return(list); }, OnCanLoadMore = () => loader.MessagesLoaded < loader.MessagesCount }; LoadMessages(); }
public SellOrdersPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IRestRepository restRepository) : base(navigationService) { PageDialogService = pageDialogService; RestRepository = restRepository; SourceList = new List <OrdersData>(); SellOrders = new InfiniteScrollCollection <OrdersData> { OnLoadMore = async() => { var page = SellOrders.Count / PageSize; return(await Task.Run(() => LoadSellOrders(page))); }, OnCanLoadMore = () => SellOrders.Count < SourceList.Count }; RefreshCommand = new DelegateCommand(async() => await GetMarketDataOrders()); }
internal UpcomingMovieViewModel(UpcomingMovieService upcomingMovieService) { _upcomingMovieService = upcomingMovieService ?? throw new ArgumentException("upcomingMovieService"); Title = "TMDb Upcoming Movies"; ListView_ItemsSource = new InfiniteScrollCollection <MovieModel> { OnLoadMore = async() => { try { if (IsBusy) { return(null); } IsBusy = true; var page = (uint)(ListView_ItemsSource.Count / PageSize) + 1; if (totalPages > 0 && page >= totalPages) { IsBusy = false; return(null); } var model = await GetMovieCollectionAsync(page); totalPages = (uint)model.TotalPages; IsBusy = false; return(model.MovieCollection); } catch (Exception ex) { IsBusy = false; Debug.WriteLine(ex); throw; } } }; ListView_RefreshCommand = new Command(async() => await ExecuteListView_RefreshCommand_HandlerAsync()); ToolbarItemSearch_Command = new Command(async() => await ToolbarItemSearch_Command_HandlerAsync()); _ExecuteListView_RefreshCommand_HandlerAsync(); }