private async void Loading(int pageIndex) { if (_isSearch) { Search(_currentSearchQuery); } if (TheLoaiDangXem == Wrapper.TagTruyen.Favorite) { await LoadingFavorite(); return; } if (!IsLoading) { IsLoading = true; var currentTheload = TheLoaiDangXem; var wrapper = WrapperCreator.Create(TrangDocTruyen); var result = await wrapper.GetTopTruyen(pageIndex, currentTheload); DanhSachTruyen.Clear(); if (result != null) { foreach (var truyen in result.ListTruyen) { DanhSachTruyen.Add(truyen); } MaxPageIndex = result.MaxPageIndex; } IsLoading = false; this.OnPropertyChanged("DanhSachTruyen"); } }
public async void Search(string query) { if (!IsLoading) { IsLoading = true; IsSearch = true; _currentSearchQuery = query; var wrapper = WrapperCreator.Create(TrangDocTruyen); var result = await wrapper.SearchTruyen(query, CurrentPageIndex); DanhSachTruyen.Clear(); foreach (var truyen in result.ListTruyen) { DanhSachTruyen.Add(truyen); } MaxPageIndex = result.MaxPageIndex; IsLoading = false; this.OnPropertyChanged("DanhSachTruyen"); } }
private async Task <bool> LoadingFavorite() { if (await _settingService.IsHaveFavorite()) { if (!IsLoading) { IsLoading = true; DanhSachTruyen.Clear(); TheLoaiDangXem = Wrapper.TagTruyen.Favorite; var list = await _settingService.ListFavoriteSong(); foreach (var truyenKey in list) { DanhSachTruyen.Add(TruyenSqlFavoriteData.Convert(truyenKey)); } IsLoading = false; } return(true); } return(false); }