async Task ExecuteSearchCommandAsync() { pageIndex = 1; CanLoadMore = false; if (KeyWords != "") { await ExecuteRefreshCommandAsync(); } else { if (Searchs.Count > 0) { Searchs.Clear(); } LoadStatus = LoadMoreStatus.StausNodata; } }
async Task ExecuteRefreshCommandAsync() { var result = await StoreManager.SearchService.GetSearchAsync(position, KeyWords, pageIndex, pageSize); if (result.Success) { var articles = JsonConvert.DeserializeObject <List <Search> >(result.Message.ToString()); if (articles.Count > 0) { if (pageIndex == 1 && Searchs.Count > 0) { Searchs.Clear(); } Searchs.AddRange(articles); pageIndex++; if (Searchs.Count >= pageSize) { LoadStatus = LoadMoreStatus.StausDefault; CanLoadMore = true; } else { LoadStatus = LoadMoreStatus.StausEnd; CanLoadMore = false; } } else { CanLoadMore = false; LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata; } } else { Crashes.TrackError(new Exception() { Source = result.Message }); LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail; } }
public async Task ExecuteSearchCommandAsync(string value) { if (value != SearchValue) { searchValue = value; pageIndex = 1; CanLoadMore = false; if (searchValue != "") { await ExecuteRefreshCommandAsync(); } else { if (Searchs.Count > 0) { Searchs.Clear(); } LoadStatus = LoadMoreStatus.StausDefault; } } }