public async void Load(BookItem b, bool useCache = true) { // b is null when back button is pressed before BookLoader load if (b == null) { return; } Shared.LoadMessage("LoadingVolumes"); CurrentBook = b; if (b.Volumes == null) { b.Entry.Volumes = await Shared.BooksDb.LoadCollectionAsync(b.Entry, x => x.Volumes, x => x.Index); } if (b.IsLocal() || (useCache && !b.NeedUpdate && b.Volumes.Any())) { foreach (Volume Vol in b.Volumes) { if (Vol.Chapters == null) { Vol.Chapters = await Shared.BooksDb.LoadCollectionAsync(Vol, x => x.Chapters, x => x.Index); } } OnComplete(b); } else if (b.IsSpider()) { var j = Task.Run(() => LoadInst(( BookInstruction )b)); } else if (b.IsEx()) { IRuntimeCache wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache); // This occurs when tapping pinned book but cache is cleared wCache.InitDownload( b.ZItemId , X.Call <XKey[]>(XProto.WRequest, "GetBookTOC", b.ZItemId) , (DRequestCompletedEventArgs e, string id) => { b.XCall("ParseVolume", e.ResponseString); OnComplete(b); } , (string RequestURI, string id, Exception ex) => { OnComplete(b); } , false ); } }
public void Load(BookItem b, bool useCache = false) { CurrentBook = b; if (b.IsLocal()) { OnComplete(b); } else if (b.IsSpider()) { Task.Run(() => LoadInstruction(( BookInstruction )b, useCache)); } else if (CurrentBook.IsEx()) { string BookId = b.ZItemId; string Mode = CurrentBook.XField <string>("Mode"); if (useCache && b.Info.Flags.Contains(Mode)) { OnComplete(b); } else { b.Info.Flags.Add(Mode); X.Instance <IRuntimeCache>(XProto.WRuntimeCache) .InitDownload( BookId, X.Call <XKey[]>(XProto.WRequest, "DoBookAction", Mode, BookId) , (e, id) => { CurrentBook.XCall("ParseXml", e.ResponseString); CurrentBook.LastCache = DateTime.Now; CurrentBook.SaveInfo(); OnComplete(CurrentBook); } , (cache, id, ex) => { b.Info.Flags.Remove(Mode); OnComplete(null); }, true ); } } }
private void SetContext() { ToggleFav(); ToggleAppBar(); if (ThisBook == null) { // Set Book Unavailable View BrowserBtn.IsEnabled = TOCBtn.IsEnabled = CommentBtn.IsEnabled = false; } else { CommentBtn.IsEnabled = !ThisBook.IsLocal(); BrowserBtn.IsEnabled = !string.IsNullOrEmpty(ThisBook.Info.OriginalUrl); LayoutRoot.DataContext = ThisBook; InfoBgGrid.DataContext = InfoBgContext; } }