private void OnResultItemClick(int pageNum, PageSearchItem searchItem)
        {
            var record = DataCache.INSTATNCE.Toc.GetNavigationItem() as ContentBrowserRecord;

            if (record == null ||
                !NavigationManagerHelper.CompareActualTocId(record.TOCID, searchItem.TOCID) ||
                record.PageNum != pageNum)
            {
                NavigationManager.Instance.AddRecord(
                    new ContentBrowserRecord(
                        NavigationManagerHelper.GetCurrentBookId(),
                        searchItem.TOCID,
                        pageNum,
                        0));
                //WebViewManager.Instance.ClearWebViewStatus(WebViewManager.WebViewType.Content);
            }
            else
            {
                NavigationManagerHelper.MoveForthAndSetCurrentIndex(record.RecordID);
                WebViewManager.Instance.ClearWebViewStatus(WebViewManager.WebViewType.Content);
                DataCache.INSTATNCE.Toc.ResetNavigationItem();
            }

            ((ContentActivity)Activity).GetMainFragment().SwitchLogicalMainTab(ContentMainFragment.TabContents);
            ((ContentActivity)Activity).GetMainFragment().Refresh();

            Dismiss();
        }
        private void OnPageNumChanged()
        {
            Arguments.PutString(PageNumKey, tvPageNum.Text);
            if (string.IsNullOrEmpty(tvPageNum.Text))
            {
                hrcAdaptor.ResultList  = null;
                tvNoResultMessage.Text = MainApp.ThisApp.Resources.GetString(
                    Resource.String.ContentPboGoTo_EmptyInputMessage);
                tvNoResultMessage.Visibility = ViewStates.Visible;
                return;
            }

            var bookId  = NavigationManagerHelper.GetCurrentBookId();
            var pageNum = Int32.Parse(tvPageNum.Text);

            hrcAdaptor.ResultList = new Tuple <int, List <PageSearchItem> >(
                pageNum,
                AsyncHelpers.RunSync <List <PageSearchItem> >(
                    () => PageSearchUtil.Instance.SeachByPageNum(bookId, pageNum)));

            if (hrcAdaptor.ItemCount == 0)
            {
                tvNoResultMessage.Text = MainApp.ThisApp.Resources.GetString(
                    Resource.String.ContentPboGoTo_NotFoundMessage);
                tvNoResultMessage.Visibility = ViewStates.Visible;
            }
            else
            {
                tvNoResultMessage.Visibility = ViewStates.Gone;
            }
        }
Ejemplo n.º 3
0
 public void UpdatePublicationDownloadingProgress(int bookId)
 {
     // We can't get current Publication of ContentActivity, after NavigationManager is cleared;
     // So we just get current book id from NavigationManager directly.
     // Releated bug: http://wiki.lexiscn.com/issues/15647
     if (NavigationManagerHelper.GetCurrentBookId() != bookId)
     {
         return;
     }
 }
            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();
                }
            }
Ejemplo n.º 5
0
        public override void OnHiddenChanged(bool hidden)
        {
            base.OnHiddenChanged(hidden);

            if (!hidden
                &&
                (DataCache.INSTATNCE.IndexList == null ||
                 DataCache.INSTATNCE.IndexList.IndexList == null ||
                 DataCache.INSTATNCE.IndexList.Publication == null ||
                 DataCache.INSTATNCE.IndexList.Publication.Value.BookId != NavigationManagerHelper.GetCurrentBookId()))
            {
                GetIndexList();
            }
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var v = inflater.Inflate(Resource.Layout.contentpage_content_fragment, container, false);

            if (((ContentActivity)Activity).Publication == null)
            {
                return(v);
            }

            ivExpand        = v.FindViewById <ImageView>(Resource.Id.ivExpand);
            ivExpand.Click += OnIvExpandClick;

            ivPreviousPage = v.FindViewById <ImageView>(Resource.Id.ivPreviousPage);
            ivNextPage     = v.FindViewById <ImageView>(Resource.Id.ivNextPage);

            tvGoToPage        = v.FindViewById <TextView>(Resource.Id.tvGoToPage);
            tvPboPageNumLabel = v.FindViewById <TextView>(Resource.Id.tvPboPageNumLabel);
            tvPboPageNum      = v.FindViewById <TextView>(Resource.Id.tvPboPageNum);

            bflContentContainer = v.FindViewById <BoundedFrameLayout>(Resource.Id.bflContentContainer);
            bflContentContainer.SetBackgroundResource(Resource.Drawable.miscinfo_frame_background);

            flWebViewContainer = v.FindViewById <FrameLayout>(Resource.Id.flWebViewContainer);

            llTopLoadingIndicator    = v.FindViewById <LinearLayout>(Resource.Id.llTopLoadingIndicator);
            tvTopLoadingTocTitle     = v.FindViewById <TextView>(Resource.Id.tvTopLoadingTocTitle);
            llBottomLoadingIndicator = v.FindViewById <LinearLayout>(Resource.Id.llBottomLoadingIndicator);
            tvBottomLoadingTocTitle  = v.FindViewById <TextView>(Resource.Id.tvBottomLoadingTocTitle);

            tvPboPageNumLabel.Text = tvPboPageNumLabel.Text + " ";

            llTopLoadingIndicator.Visibility    = ViewStates.Gone;
            llBottomLoadingIndicator.Visibility = ViewStates.Gone;

            ivPreviousPage.Click += delegate
            {
                var mainFragmentStatus = ((ContentActivity)Activity).GetMainFragment().MainFragmentStatus;
                if (!NavigationManagerHelper.CanBack(mainFragmentStatus))
                {
                    return;
                }

                // ToDo: Use DataCache.INSTATNCE.Toc.GetNavigationItem to find ContentBrowserRecord
                var record = NavigationManager.Instance.CurrentRecord as ContentBrowserRecord;
                if (record != null)
                {
                    record.WebViewScrollPosition = wvContent.ScrollY;
                }

                var fromBookId = NavigationManagerHelper.GetCurrentBookId();
                NavigationManagerHelper.Back(mainFragmentStatus);
                ((ContentActivity)Activity).GetMainFragment().NavigateTo(fromBookId);
            };

            ivNextPage.Click += delegate
            {
                var mainFragmentStatus = ((ContentActivity)Activity).GetMainFragment().MainFragmentStatus;
                if (!NavigationManagerHelper.CanForth(mainFragmentStatus))
                {
                    return;
                }

                var record = NavigationManager.Instance.CurrentRecord as ContentBrowserRecord;
                if (record != null)
                {
                    record.WebViewScrollPosition = wvContent.ScrollY;
                }

                var fromBookId = NavigationManagerHelper.GetCurrentBookId();
                NavigationManagerHelper.Forth(mainFragmentStatus);
                ((ContentActivity)Activity).GetMainFragment().NavigateTo(fromBookId);
            };

            tvGoToPage.Click += delegate
            {
                var goToPageDialogFragment = GoToPageDialogFragment.NewInstance();
                goToPageDialogFragment.Show(FragmentManager.BeginTransaction(), "goToPageDialogFragment");
            };

            //UpdatePboPage();
            //((ContentActivity)Activity).GetMainFragment().SetLeftPanelStatus();

            return(v);
        }