public bool FetchCurrentBlogPagesAsync(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 numerberOfPages = 0; if (more) { numerberOfPages = Math.Max(CurrentBlog.PageListItems.Count, CHUNK_SIZE); if (CurrentBlog.HasOlderPages) { numerberOfPages += CHUNK_SIZE; } else { //removing this block you will enable the refresh of pages when reached the end of the list and no more pages are available CurrentBlog.hideLoadingIndicator(); return(false); } } else { numerberOfPages = CHUNK_SIZE; } CurrentBlog.IsLoadingPages = true; GetPageListRPC rpc = new GetPageListRPC(CurrentBlog); rpc.NumberOfPages = numerberOfPages; rpc.Completed += OnFetchCurrentBlogPagesCompleted; rpc.ExecuteAsync(); return(true); }
private void OnGetNewBlogOptionsCompleted(object sender, XMLRPCCompletedEventArgs <Option> args) { GetOptionsRPC rpc = sender as GetOptionsRPC; rpc.Completed -= OnGetNewBlogOptionsCompleted; Blog newBlog = _trackedBlogs.Where(blog => blog.BlogId == rpc.BlogId).FirstOrDefault(); if (null == newBlog) { return; } //report the error, but keep trying to get data if (null != args.Error) { this.DebugLog("OnGetNewBlogOptionsCompleted: Exception occurred (" + newBlog.BlogName + ")"); this.DebugLog(args.Error.ToString()); NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } else { newBlog.Options.Clear(); args.Items.ForEach(option => { newBlog.Options.Add(option); }); } this.DebugLog("Blog '" + newBlog.BlogName + "' has finished downloading Options."); if (newBlog == CurrentBlog) { NotifyFetchComplete(); } //get the pages for the new blog GetPageListRPC pageListRPC = new GetPageListRPC(newBlog); pageListRPC.Completed += OnGetNewBlogPagesCompleted; pageListRPC.ProgressChanged += OnGetNewBlogPagesProgressChanged; pageListRPC.ExecuteAsync(); }