public void OnClick(View v) { if (DataCache.INSTATNCE.Toc == null) { return; } if (vh.Node == null) { // The node is "Table of Contents" if (DataCache.INSTATNCE.Toc.CurrentTOCNode != null) { vh.adaptor.SetCurrentNode( GetTopLevelNode(DataCache.INSTATNCE.Toc.CurrentTOCNode), false); } return; } if (vh.Node.IsParent()) { var isExpanded = DataCache.INSTATNCE.Toc.IsExpanded(vh.Node, vh.adaptor.NodeList); // switch the expanded status of current node vh.adaptor.SetCurrentNode(vh.Node, !isExpanded); } else { if (DataCache.INSTATNCE.Toc.IsCurrentNode(vh.Node)) { return; } var record = DataCache.INSTATNCE.Toc.GetNavigationItem(); if (record == null || !NavigationManagerHelper.CompareActualTocId(NavigationManagerHelper.ContentsTabGetTocId(record), vh.Node.ID)) { NavigationManager.Instance.AddRecord( new ContentBrowserRecord( DataCache.INSTATNCE.Toc.Publication.BookId, vh.Node.ID, 0)); } DataCache.INSTATNCE.Toc.CurrentTOCNode = vh.Node; DataCache.INSTATNCE.Toc.BindNavigationItem(); vh.adaptor.Activity.GetMainFragment().OpenContentPage(); vh.adaptor.NotifyDataSetChanged(); } }
private void SyncStatus(Publication pub) { if (!DataCache.INSTATNCE.Toc.IsCurrentNavigationItem()) { var tocid = NavigationManagerHelper.ContentsTabGetTocId(NavigationManager.Instance.CurrentRecord); if (!NavigationManagerHelper.IsShowContentRecord(tocid)) { BrowserRecord record = DataCache.INSTATNCE.Toc.GetNavigationItem(); if (record == null) { record = NavigationManagerHelper.GetLastReasonableRecord( new List <RecordType> { RecordType.ContentRecord, RecordType.SearchResultRecord }); } if (record == null || (tocid = NavigationManagerHelper.ContentsTabGetTocId(record)) == NavigationManagerHelper.TocIdDefaultPage) { DataCache.INSTATNCE.Toc.CurrentTOCNode = DataCache.INSTATNCE.Toc.GetFirstPage(); } else { DataCache.INSTATNCE.Toc.SetCurrentTOCNodeById(tocid); } tocListAdaptor.RefreshNodeList(); ((ContentActivity)Activity).GetMainFragment().OpenContentPage(); return; } if (tocid == NavigationManagerHelper.TocIdDefaultPage && NavigationManager.Instance.Records.Count > 1) { DataCache.INSTATNCE.Toc.CurrentTOCNode = DataCache.INSTATNCE.Toc.GetFirstPage(); } else { DataCache.INSTATNCE.Toc.SetCurrentTOCNodeById(tocid); } DataCache.INSTATNCE.Toc.BindNavigationItem(); } tocListAdaptor.RefreshNodeList(); ((ContentActivity)Activity).GetMainFragment().OpenContentPage(); return; }