Пример #1
0
        private async void RefreshHotAnswersMethod()
        {
            #region Checking Network

            if (false == Utility.Instance.IsNetworkAvailable)
            {
                ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3);

                return;
            }

            #endregion

            if (AnswersLoading)
            {
                return;
            }

            AnswersLoading = true;

            var result = await _hot.GetTodayHotAnswers(LoginUser.Current.Token, "/hot/top/answers/day", true);

            AnswersLoading = false;

            if (result == null)
            {
                return;
            }

            if (result.Result == null)
            {
                ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3);

                return;
            }

            var hotAnswersAll = (from object hotAnswer in HotAnswers select hotAnswer as HotAnswer).ToList();
            var newHotAnswers = new List <HotAnswer>();

            var query = from i in result.Result.GetItems()
                        let asHotAnswer = i as HotAnswer
                                          where hotAnswersAll.All(o => asHotAnswer != null && o.Answers[0].Url != asHotAnswer.Answers[0].Url)
                                          select asHotAnswer;

            newHotAnswers.AddRange(query);

            if (newHotAnswers.Count == 20)
            {
                HotAnswers = new IncrementalLoading <HotAnswer>(GetMoreHotAnswers, "/hot/top/answers/day", FirstOffset, false);
                return;
            }

            for (var i = 0; i < newHotAnswers.Count; i++)
            {
                HotAnswers.Insert(i, newHotAnswers[i]);
            }
        }
Пример #2
0
 public HotAnswersResult(HotAnswers result) : base(result)
 {
 }