private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount)
        {
            _buzy = true;
            var         actualCount = 0;
            List <Duan> list        = null;

            try
            {
                DataLoading?.Invoke();
                list = await _api.GetDuan(DataShareManager.Current.DuanItemPage++);
            }
            catch (Exception)
            {
                HasMoreItems = false;
            }

            if (list != null && list.Any())
            {
                actualCount = list.Count;
                list.ForEach((t) =>
                {
                    //if (DataShareManager.Current.ReadedList.Contains(t.ID))
                    //{
                    //    t.Readed = true;
                    //}
                    bool isPassedUnWel = true;
                    if (!DataShareManager.Current.IsShowUnwelcome)
                    {
                        int oo = t.VotePositive;
                        int xx = t.VoteNegative;
                        if ((oo + xx) >= 50 && ((double)oo / (double)xx) < 0.618)
                        {
                            t.Content    += "\n\nUnwelcome";
                            isPassedUnWel = false;
                        }
                    }
                    if (isPassedUnWel)
                    {
                        Add(t);
                    }
                });
                HasMoreItems = true;
            }
            else
            {
                HasMoreItems = false;
                --DataShareManager.Current.DuanItemPage;
            }
            DataLoaded?.Invoke();
            _buzy = false;

            return(new LoadMoreItemsResult {
                Count = (uint)actualCount
            });
        }
        private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount)
        {
            _buzy = true;
            var          actualCount = 0;
            List <Fresh> list        = null;

            try
            {
                DataLoading?.Invoke();
                list = await _api.GetFresh(DataShareManager.Current.FreshNewsPage++);
            }
            catch (Exception)
            {
                HasMoreItems = false;
            }

            if (list != null && list.Any())
            {
                actualCount = list.Count;
                list.ForEach((t) =>
                {
                    //if (DataShareManager.Current.ReadedList.Contains(t.ID))
                    //{
                    //    t.Readed = true;
                    //}
                    if (DataShareManager.Current.isNoImageMode)
                    {
                        t.Thumb_c = "ms-appx:///Assets/No_Image_150.png";
                    }
                    Add(t);
                });
                HasMoreItems = true;
            }
            else
            {
                HasMoreItems = false;
                --DataShareManager.Current.FreshNewsPage;
            }
            DataLoaded?.Invoke();
            _buzy = false;

            return(new LoadMoreItemsResult {
                Count = (uint)actualCount
            });
        }
        private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount)
        {
            _buzy = true;
            var actualCount       = 0;
            List <BoringPic> list = null;

            try
            {
                DataLoading?.Invoke();
                list = await _api.GetMeiziPics(DataShareManager.Current.MeiziItemPage++);
            }
            catch (Exception)
            {
                HasMoreItems = false;
            }

            if (list != null && list.Any())
            {
                actualCount = list.Count;
                list.ForEach((t) =>
                {
                    //if (DataShareManager.Current.ReadedList.Contains(t.ID))
                    //{
                    //    t.Readed = true;
                    //}
                    Add(t);
                });
                HasMoreItems = true;
            }
            else
            {
                HasMoreItems = false;
                --DataShareManager.Current.MeiziItemPage;
            }
            if (DataLoaded != null)
            {
                DataLoaded();
            }
            _buzy = false;

            return(new LoadMoreItemsResult {
                Count = (uint)actualCount
            });
        }
Exemple #4
0
        public async Task LoadMoreHistory()
        {
            if (!HasMore)
            {
                return;
            }
            lock (o)
            {
                loading = true;
            }
            DataLoading?.Invoke();
            CurrentPage++;
            List <Parameters> param = new List <Parameters>();

            param.Add(new Parameters("to", ToUid));
            param.Add(new Parameters("type", "getdetail"));
            param.Add(new Parameters("page", CurrentPage.ToString()));
            param.Add(new Parameters("token", Constants.token));
            Parameters result = await WebConnection.Connect(Constants.domain + "/pkuhelper/../services/msg.php?api_version=2", param);

            if (result.name != "200")
            {
                Util.DealWithDisconnect(result);
            }
            else
            {
                JsonObject temp_json = JsonObject.Parse(result.value);
                int        code      = (int)temp_json.GetNamedNumber("code");
                if (code != 0)
                {
                    Constants.BoxPage.ShowMessage("获取聊天记录失败");
                }
                else
                {
                    AddHistory(result.value);
                }
            }
            DataLoaded?.Invoke();
            lock (o)
            {
                loading = false;
            }
        }
Exemple #5
0
        private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount)
        {
            _buzy = true;
            var actualCount       = 0;
            List <BoringPic> list = null;

            try
            {
                DataLoading?.Invoke();
                list = await _api.GetBoringPics(DataShareManager.Current.BoringItemPage++);
            }
            catch (Exception)
            {
                HasMoreItems = false;
            }

            if (list != null && list.Any())
            {
                actualCount = list.Count;
                list.ForEach((t) =>
                {
                    //if (DataShareManager.Current.ReadedList.Contains(t.ID))
                    //{
                    //    t.Readed = true;
                    //}
                    if (DataShareManager.Current.isNoImageMode)
                    {
                        t.Urls = t.Thumb;
                    }

                    var comment = t.Content.Replace("\n", "").Replace("\r", "");
                    t.Content   = comment;

                    bool isPassedNSFW = true, isPassedUnWel = true;
                    if (!DataShareManager.Current.IsShowNSFW && t.Content.Contains("NSFW"))
                    {
                        isPassedNSFW = false;
                    }
                    if (!DataShareManager.Current.IsShowUnwelcome)
                    {
                        int oo = t.VotePositive;
                        int xx = t.VoteNegative;
                        if ((oo + xx) >= 50 && ((double)oo / (double)xx) < 0.618)
                        {
                            t.Content    += "\n\nUnwelcome";
                            isPassedUnWel = false;
                        }
                    }
                    if (isPassedNSFW && isPassedUnWel)
                    {
                        Add(t);
                    }
                });
                HasMoreItems = true;
            }
            else
            {
                HasMoreItems = false;
                --DataShareManager.Current.BoringItemPage;
            }
            DataLoaded?.Invoke();
            _buzy = false;

            return(new LoadMoreItemsResult {
                Count = (uint)actualCount
            });
        }