Ejemplo n.º 1
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);
        }