private void OnGetApiKeyRPCCompleted(object sender, XMLRPCCompletedEventArgs <Blog> args) { //the blog is updated by the rpc. all we have to do here is unbind GetApiKeyRPC rpc = sender as GetApiKeyRPC; rpc.Completed -= OnGetApiKeyRPCCompleted; //check for empty args.Items, self-hosted blogs will return null here Blog newBlog; if (args.Items.Count == 0) { newBlog = rpc.blog; } else { newBlog = args.Items[0]; } _trackedBlogs.Add(newBlog); this.DebugLog("Blog '" + newBlog.BlogName + "' is now downloading data."); //start with the comments GetAllCommentsRPC getCommentsRPC = new GetAllCommentsRPC(newBlog); getCommentsRPC.Number = CHUNK_SIZE; getCommentsRPC.Offset = 0; getCommentsRPC.Completed += OnGetNewBlogCommentsCompleted; getCommentsRPC.ProgressChanged += OnGetCommentsRPCProgressChanged; getCommentsRPC.ExecuteAsync(); }
public bool FetchCurrentBlogCommentsAsync(bool more) { if (null == CurrentBlog) { throw new ArgumentException("CurrentBlog may not be null", "CurrentBlog"); } //we're already downloading data here--don't allow scenarios where we could be //kicking off another download if (_trackedBlogs.Contains(CurrentBlog)) { return(false); } CurrentBlog.showLoadingIndicator(); int numerberOfComments = 0; if (more) { numerberOfComments = Math.Max(CurrentBlog.Comments.Count, CHUNK_SIZE); if (CurrentBlog.HasOlderComments) { numerberOfComments += CHUNK_SIZE; } else { //removing this block you will enable the refresh of comments when reached the end of the list and no more comments are available CurrentBlog.hideLoadingIndicator(); return(false); } } else { numerberOfComments = CHUNK_SIZE; } CurrentBlog.IsLoadingComments = true; GetAllCommentsRPC rpc = new GetAllCommentsRPC(CurrentBlog); rpc.Number = numerberOfComments; rpc.Offset = 0; rpc.Completed += OnFetchCurrentBlogCommentsCompleted; rpc.ExecuteAsync(); return(true); }