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 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(); }
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(); }
//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(); }
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 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(); }); }
public InfiniteListViewViewModel() { Items = new InfiniteScrollCollection <DataItem> { OnLoadMore = async() => { IsLoadingMore = true; var items = GetItems(false); //Call your Web API next items page. await Task.Delay(1200); IsLoadingMore = false; return(items); } }; Items.LoadMoreAsync(); }
public EventsPageViewModel() { Items = new InfiniteScrollCollection <EventListModel> { OnLoadMore = async() => { var items = new InfiniteScrollCollection <EventListModel>(); if (totalcount > getEventCount && getEventCount != 0 || IsFirstHit == false) { if (!HitinProcess) { HitinProcess = true; IsLoadingMore = true; var response = await CommonLib.EventList(CommonLib.ws_MainUrl + "AccountApi/GetEvents?" + "userId=" + LoginDetails.userId + "&pageIndex=" + pageindex + "&pageSize=" + pageSize + ""); if (response != null && response.events.Count != 0) { pageindex++; IsFirstHit = true; totalcount = response.Count; getEventCount = response.events.Count; items = GetItems(true, response.events); IsLoadingMore = false; HitinProcess = false; } else { getEventCount = 0; HitinProcess = false; IsLoadingMore = false; } } } //Call your Web API next items page. //if (!ProductCategories.IsPull) // await Task.Delay(1200); return(items); } }; Items.LoadMoreAsync(); }
public VotePartiesPageViewModel() { Items = new InfiniteScrollCollection <PartyListModel> { OnLoadMore = async() => { var items = new InfiniteScrollCollection <PartyListModel>(); if (totalcount > getLeaderCount && getLeaderCount != 0 || IsFirstHit == false) { if (!HitinProcess) { HitinProcess = true; IsLoadingMore = true; var response = await CommonLib.PartyList(CommonLib.ws_MainUrlMain + "CandidatureApi/Candidatures?" + "userId=" + LoginDetails.userId + "&pageIndex=" + pageindex + "&pageSize=" + pageSize); if (response.Status == 1) { VotePartiesPage.checkLabel = response.LabelStatus; VotePartiesPage.checkonemonth = false; if (LoginDetails.sessionId == response.SessionId) { pageindex++; IsFirstHit = true; totalcount = response.Count; getLeaderCount = response.Candidatures.Count; items = GetItems(true, response.Candidatures, response.VoteButtonStatus, response.LabelStatus); IsLoadingMore = false; HitinProcess = false; } else { // await App.Current.MainPage.DisplayAlert("", "Your session is expired!", "ok"); await Application.Current.MainPage.Navigation.PushAsync(new Views.LogInPage()); // App.Current.MainPage = new NavigationPage(new Views.LogInPage()); //await Task.Run(async () => //{ // await Task.Delay(300); // Device.BeginInvokeOnMainThread(() => // { // Application.Current.MainPage = new NavigationPage(new Views.LogInPage()); // }); //}); } } else { HitinProcess = false; IsLoadingMore = false; } } } //Call your Web API next items page. //if (!ProductCategories.IsPull) // await Task.Delay(1200); return(items); } }; Items.LoadMoreAsync(); }
private void Popup_Disappearing(object sender, EventArgs e) { if (Device.RuntimePlatform == "iOS") { if (ConfirmVotePopup.isSave) { for (int i = 0; i < Items.Count; i++) { Items[i].voteImag = "votepartiesNew1.png"; } } else { Items[row_index].voteImag = "vote_button_green1.png"; } } else { if (ConfirmVotePopup.isSave) { Items = new InfiniteScrollCollection <PartyListModel>(); RaisePropertyChanged(nameof(Items)); // raise a property change in whatever way is right for your VM Items.CollectionChanged += CollectionDidChange; HitinProcess = false; pageindex = 1; getLeaderCount = 0; totalcount = 0; IsFirstHit = false; Items = new InfiniteScrollCollection <PartyListModel> { OnLoadMore = async() => { var items = new InfiniteScrollCollection <PartyListModel>(); if (totalcount > getLeaderCount && getLeaderCount != 0 || IsFirstHit == false) { if (!HitinProcess) { HitinProcess = true; IsLoadingMore = true; var response = await CommonLib.PartyList(CommonLib.ws_MainUrlMain + "CandidatureApi/Candidatures?" + "userId=" + LoginDetails.userId + "&pageIndex=" + pageindex + "&pageSize=" + pageSize); if (response.Status == 1) { if (LoginDetails.sessionId == response.SessionId) { pageindex++; IsFirstHit = true; totalcount = response.Count; getLeaderCount = response.Candidatures.Count; items = GetItems(true, response.Candidatures, response.VoteButtonStatus, response.LabelStatus); IsLoadingMore = false; HitinProcess = false; } else { LoadPopup.CloseAllPopup(); //await App.Current.MainPage.DisplayAlert("", "Your session is expired!", "ok"); VoteAlertPopup.textmsg = "Your session is expired!"; await App.Current.MainPage.Navigation.PushPopupAsync(new VoteAlertPopup()); App.Current.MainPage = new Views.LogInPage(); } } else { HitinProcess = false; IsLoadingMore = false; } } } //Call your Web API next items page. //if (!ProductCategories.IsPull) // await Task.Delay(1200); return(items); } }; Items.LoadMoreAsync(); //Items = new InfiniteScrollCollection<LeaderListModel>(); RaisePropertyChanged(nameof(Items)); // raise a property change in whatever way is right for your VM Items.CollectionChanged += CollectionDidChange; } } }
public InfiniteListViewViewModel() { homeItems = new InfiniteScrollCollection <DataItem>(new[] { new DataItem { Id = 0, Price = "Rs.1650", NewPrice = "Rs.657", Title = "Smart Relaxed Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338624/2018/2/6/11517900277289-WROGN-Men-Navy-Blue-Slim-Fit-Checked-Casual-Shirt-7881517900277120-1_mini.jpg", }, new DataItem { Id = 1, Price = "Rs.2650", NewPrice = "Rs.657", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2032614/2017/10/24/11508834373908-WROGN-Men-Blue--White-Slim-Fit-Striped-Casual-Shirt-3881508834373652-1_mini.jpg" }, new DataItem { Id = 2, Price = "Rs.1650", NewPrice = "Rs.647", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338627/2018/2/6/11517914484169-WROGN-Men-Navy-Blue--Maroon-Regular-Fit-Checked-Casual-Shirt-3721517914483990-1_mini.jpg" }, new DataItem { Id = 3, Price = "Rs.1350", NewPrice = "Rs.697", Title = "Smart Relaxed Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2478205/2018/5/25/8408b98c-500f-463c-a7f3-563d7d13bc5f1527242936529-WROGN-Men-Green-Manhattan-Slim-Fit-Checked-Casual-Shirt-7681527242935109-1_mini.jpg" }, new DataItem { Id = 4, Price = "Rs.1650", NewPrice = "Rs.697", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/1502379/2016/11/9/11478687493658-WROGN-Men-Black--Olive-Green-Checked-Casual-Shirt-391478687493324-1_mini.jpg" }, new DataItem { Id = 5, Price = "Rs.1950", NewPrice = "Rs.617", Title = "Smart Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2478200/2018/3/9/11520581186038-WROGN-Men-Shirts-3461520581185674-1_mini.jpg" }, new DataItem { Id = 6, Price = "Rs.1250", NewPrice = "Rs.857", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2478248/2018/2/23/11519376947954-WROGN-Men-Black--Red-Slim-Fit-Checked-Casual-Shirt-9121519376947738-1_mini.jpg" }, new DataItem { Id = 7, Price = "Rs.1640", NewPrice = "Rs.757", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/4699468/2018/5/31/e461d4e5-b408-4fa9-9ae2-f963f59fca911527762018271-WROGN-Men-Purple--Red-Slim-Fit-Striped-Casual-Shirt-85115277-1_mini.jpg", }, new DataItem { Id = 8, Price = "Rs.1850", NewPrice = "Rs.687", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338705/2018/2/19/11519038692742-WROGN-Men-Shirts-8911519038692561-1_mini.jpg" }, new DataItem { Id = 9, Price = "Rs.1620", NewPrice = "Rs.957", Title = "Smart Relaxed Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338570/2018/5/31/2d3dbb13-0839-4537-a8db-7b26ced505191527769515870-WROGN-Men-Black-Slim-Fit-Printed-Casual-Shirt-39215277695140-1_mini.jpg" }, new DataItem { Id = 10, Price = "Rs.1650", NewPrice = "Rs.657", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338718/2018/1/17/11516166050176-WROGN-Men-Black--Grey-Regular-Fit-Checked-Casual-Shirt-1481516166050070-1_mini.jpg" }, new DataItem { Id = 11, Price = "Rs.2650", NewPrice = "Rs.637", Title = "Smart Relaxed Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2032685/2017/9/5/11504607857814-WROGN-Men-Gold-Toned--Blue-Slim-Fit-Printed-Casual-Shirt-8221504607857537-1_mini.jpg" }, new DataItem { Id = 12, Price = "Rs.1250", NewPrice = "Rs.657", Title = "Smart Relaxed Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2478214/2018/4/12/11523531611545-WROGN-Men-Khaki-Slim-Fit-Solid-Casual-Shirt-3861523531611399-1_mini.jpg" }, new DataItem { Id = 13, Price = "Rs.1630", NewPrice = "Rs.557", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/1502380/2016/11/9/11478686816093-WROGN-Men-Navy-Checked-Casual-Shirt-3651478686815730-1_mini.jpg" }, new DataItem { Id = 14, Price = "Rs.1450", NewPrice = "Rs.627", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2032636/2017/8/14/11502713439207-WROGN-Men-Off-White-Slim-Fit-Checked-Casual-Shirt-9481502713438924-1_mini.jpg", }, new DataItem { Id = 15, Price = "Rs.1610", NewPrice = "Rs.658", Title = "Smart Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2032646/2018/4/13/11523597484913-WROGN-Men-Blue-Slim-Fit-Checked-Casual-Shirt-5651523597484734-1_mini.jpg" }, new DataItem { Id = 16, Price = "Rs.1680", NewPrice = "Rs.657", Title = "Smart Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2032643/2018/5/21/9a1e941e-c56b-4a5a-9f7a-c744e8da69bf1526902046361-WROGN-Men-Beige--Navy-Slim-Fit-Checked-Casual-Shirt-5441526902044599-1_mini.jpg" }, new DataItem { Id = 17, Price = "Rs.1920", NewPrice = "Rs.837", Title = "Smart Relaxed Fit Casual Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/2338565/2018/5/31/07152ba4-cb4b-43bc-a993-1b7b186782c21527769630054-WROGN-Men-Olive-Green-Slim-Fit-Printed-Casual-Shirt-34152776-1_mini.jpg" }, new DataItem { Id = 18, Price = "Rs.1670", NewPrice = "Rs.657", Title = "Smart Relaxed Fit Formal Shirt", ImageUrl = "https://assets.myntassets.com/dpr_1.5/h_240,q_90,w_180/v1/assets/images/1700781/2016/12/26/11482739978885-WROGN-Men-Shirts-7871482739978587-1_mini.jpg" } }); Items = new InfiniteScrollCollection <DataItem> { OnLoadMore = async() => { IsLoadingMore = true; COUNT++; var items = GetItems(false, COUNT); //Call your Web API next items page. await Task.Delay(1200); IsLoadingMore = false; return(items); } }; Items.LoadMoreAsync(); }
private void _popup_Disappearing(object sender, EventArgs e) { if (Device.RuntimePlatform == "iOS") { if (RateLeaderPopUpPage.isSaved) { Items[row_index].rateImg = "Ratebutton.png"; Items[row_index].labelStatus = false; } else { Items[row_index].rateImg = "rate_button_green.png"; } } else { if (RateLeaderPopUpPage.isSaved) { Items = new InfiniteScrollCollection <LeaderListModel>(); RaisePropertyChanged(nameof(Items)); // raise a property change in whatever way is right for your VM Items.CollectionChanged += CollectionDidChange; HitinProcess = false; pageindex = 1; getLeaderCount = 0; totalcount = 0; IsFirstHit = false; Items = new InfiniteScrollCollection <LeaderListModel> { OnLoadMore = async() => { var items = new InfiniteScrollCollection <LeaderListModel>(); if (totalcount > getLeaderCount && getLeaderCount != 0 || IsFirstHit == false) { if (!HitinProcess) { HitinProcess = true; IsLoadingMore = true; var response = await CommonLib.LeaderList(CommonLib.ws_MainUrlMain + "LeaderApi/Leaders?" + "userId=" + LoginDetails.userId + "&pageIndex=" + pageindex + "&pageSize=" + pageSize); if (response.Status == 1) { pageindex++; IsFirstHit = true; totalcount = response.Count; getLeaderCount = response.Leaders.Count; items = GetItems(true, response.Leaders); IsLoadingMore = false; HitinProcess = false; } else { HitinProcess = false; IsLoadingMore = false; } } } //Call your Web API next items page. //if (!ProductCategories.IsPull) // await Task.Delay(1200); return(items); } }; Items.LoadMoreAsync(); //Items = new InfiniteScrollCollection<LeaderListModel>(); RaisePropertyChanged(nameof(Items)); // raise a property change in whatever way is right for your VM Items.CollectionChanged += CollectionDidChange; } } }