Exemple #1
0
        public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
        {
            TitlesFragment titleFrag = (TitlesFragment)FragmentManager.FindFragmentById(Resource.Id.frag_title);

            titleFrag.PopulateTitles(tab.Position);

            titleFrag.SelectPosition(0);
        }
Exemple #2
0
        public void ToggleVisibleTitles()
        {
            // Use these for custom animations.
            FragmentManager fm         = FragmentManager;
            TitlesFragment  f          = (TitlesFragment)fm.FindFragmentById(Resource.Id.frag_title);
            View            titlesView = f.View;

            mLabelIndex = 1 - mLabelIndex;

            // Determine if we're in portrait, and whether we're showing or hiding the titles
            // with this toggle.
            bool isPortrait = Resources.Configuration.Orientation ==
                              Android.Content.Res.Orientation.Portrait;

            bool shouldShow = f.IsHidden || mCurrentTitlesAnimator != null;

            // Cancel the current titles animation if there is one.
            if (mCurrentTitlesAnimator != null)
            {
                mCurrentTitlesAnimator.Cancel();
            }

            // Begin setting up the object animator. We'll animate the bottom or right edge of the
            // titles view, as well as its alpha for a fade effect.
            ObjectAnimator objectAnimator = ObjectAnimator.OfPropertyValuesHolder(
                titlesView,
                PropertyValuesHolder.OfInt(
                    isPortrait ? "bottom" : "right",
                    shouldShow ? Resources.GetDimensionPixelSize(Resource.Dimension.titles_size)
                                 : 0),
                PropertyValuesHolder.OfFloat("alpha", shouldShow ? 1 : 0)
                );

            // At each step of the animation, we'll perform layout by calling setLayoutParams.
            ViewGroup.LayoutParams lp = titlesView.LayoutParameters;
            objectAnimator.AddUpdateListener(new AnimatorUpdateListener(isPortrait, titlesView, lp));

            if (shouldShow)
            {
                fm.BeginTransaction().Show(f).Commit();
                objectAnimator.AddListener(new ObjectAnimatorListenerAdapter(this));
            }
            else
            {
                objectAnimator.AddListener(new ObjectAnimatorListenerAdapter2(this, fm, f));
            }

            // Start the animation.
            objectAnimator.Start();
            mCurrentTitlesAnimator = objectAnimator;

            InvalidateOptionsMenu();

            // Manually trigger onNewIntent to check for ACTION_DIALOG.
            OnNewIntent(Intent);
        }
 public ObjectAnimatorListenerAdapter2(MainActivity parent, FragmentManager fm, TitlesFragment f)
 {
     this.parent = parent;
     this.fm = fm;
     this.f = f;
 }
Exemple #4
0
 public ObjectAnimatorListenerAdapter2(MainActivity parent, FragmentManager fm, TitlesFragment f)
 {
     this.parent = parent;
     this.fm     = fm;
     this.f      = f;
 }