public async Task GetPopular(string idx = "0", string last_param = "") { try { Loading = true; var results = await hotAPI.Popular(idx, last_param).Request(); if (results.status) { var data = results.GetJObject(); if (data["code"].ToInt32() == 0) { if (TopItems == null) { TopItems = JsonConvert.DeserializeObject <List <HotTopItemModel> >(data["config"]["top_items"].ToString()); } var items = JsonConvert.DeserializeObject <ObservableCollection <HotDataItemModel> >(data["data"].ToString()); for (int i = items.Count - 1; i >= 0; i--) { if (items[i].card_goto != "av") { items.Remove(items[i]); } } if (HotItems == null) { HotItems = items; } else { foreach (var item in items) { HotItems.Add(item); } } } else { Utils.ShowMessageToast(data["message"].ToString()); } } else { Utils.ShowMessageToast(results.message); } } catch (Exception ex) { var handel = HandelError <AnimeHomeModel>(ex); Utils.ShowMessageToast(handel.message); } finally { Loading = false; } }
public async Task GetPopular() { try { Loading = true; var result = await hotAPI.Popular("0", "").Request(); if (result.status) { var data = result.GetJObject(); if (data["code"].ToInt32() == 0) { if (TopItems == null) { TopItems = JsonConvert.DeserializeObject <List <HotTopItemModel> >(data["config"]["top_items"].ToString()); } var items = JsonConvert.DeserializeObject <List <HotDataItemModel> >(data["data"].ToString()); for (int i = items.Count - 1; i >= 0; i--) { if (items[i].card_goto != "av") { items.Remove(items[i]); } } Items = new IncrementalLoadingCollection <HotItemSource, HotDataItemModel>(new HotItemSource(items)); } else { Utils.ShowMessageToast(data["message"].ToString()); } } else { Utils.ShowMessageToast(result.message); } } catch (Exception ex) { var handel = HandelError(ex); Utils.ShowMessageToast(handel.message); } finally { Loading = false; } }
public async Task <List <HotDataItemModel> > GetHot() { try { var result = await hotAPI.Popular(last_idx, last_param).Request(); if (result.status) { var data = result.GetJObject(); if (data["code"].ToInt32() == 0) { var items = JsonConvert.DeserializeObject <List <HotDataItemModel> >(data["data"].ToString()); for (int i = items.Count - 1; i >= 0; i--) { if (items[i].card_goto != "av") { items.Remove(items[i]); } } last_idx = items.LastOrDefault()?.idx ?? "0"; last_param = items.LastOrDefault()?.param ?? ""; return(items); } else { Utils.ShowMessageToast(data["message"].ToString()); return(new List <HotDataItemModel>()); } } else { Utils.ShowMessageToast(result.message); return(new List <HotDataItemModel>()); } } catch (Exception ex) { LogHelper.WriteLog("加载首页推荐信息失败", LogType.ERROR, ex); Utils.ShowMessageToast("加载首页推荐信息失败"); return(new List <HotDataItemModel>()); } }