Exemple #1
0
        private async Task <ListResultBase> GetMoreCommentsMethod(String requestUri)
        {
            if (null == _questionService || CommentsLoading)
            {
                return(null);
            }

            CommentsLoading = true;

            var result = await _questionService.GetCommentsAsync(LoginUser.Current.Token, requestUri, true);

            CommentsLoading = false;

            if (result == null)
            {
                return(null);
            }

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

                Debug.WriteLine(Regex.Unescape(result.Error.Message));

                await Task.Delay(3000);

                return(null);
            }

            return(result);
        }
        private async Task OfflineQuestionComments(Int32 questionId)
        {
            var    iCachePageCount = 0;
            Paging nextPaging      = null;

            var cachePagesCount = CacheCommentsCount / 20;

            while (iCachePageCount < cachePagesCount)
            {
                var request = String.Empty;
                if (nextPaging == null)
                {
                    request = String.Format("questions/{0}/comments", questionId);
                }
                else
                {
                    var url = new Uri(nextPaging.Next);
                    request = url.PathAndQuery.Substring(1);
                }

                Debug.WriteLine(request);

                await Task.Delay(10);

                var comments = await _question.GetCommentsAsync(LoginUser.Current.Token, request, true);

                await Task.Delay(10);

                if (comments.Result != null)
                {
                    iCachePageCount++;

                    nextPaging = comments.Result.Paging;

                    var commentsCount = comments.Result.GetItems().Length;

                    lock (_commentsSync)
                    {
                        CommentsCount += commentsCount;
                    }

                    if (commentsCount < 20)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }