Exemple #1
0
        private async void RefreshLikesMethod()
        {
            #region Checking Network

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

                return;
            }

            #endregion

            if (null == _notify || LikesLoading == true)
            {
                return;
            }

            LikesLoading = true;

            var result = await _notify.CheckLikesAync(LoginUser.Current.Token, "notifications/likes", true);

            LikesLoading = false;

            if (result == null)
            {
                return;
            }

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

            var likesAll = (from object like in Likes select like as NotifyItem).ToList();
            var newLikes = new List <NotifyItem>();

            var query = from i in result.Result.GetItems()
                        let asLike = i as NotifyItem
                                     where likesAll.All(o => asLike != null && o.ThreadId != asLike.ThreadId)
                                     select asLike;

            newLikes.AddRange(query);

            if (newLikes.Count == 20)
            {
                Likes = new IncrementalLoading <NotifyItem>(GetMoreLikes, "notifications/likes", "limit=20&offset=", false);

                return;
            }

            for (var i = 0; i < newLikes.Count; i++)
            {
                Likes.Insert(i, newLikes[i]);
            }
        }