Esempio n. 1
0
        private void AddCroutonToView(Crouton crouton)
        {
            // don't Add if it is already showing
            if (crouton.IsShowing())
            {
                return;
            }

            View croutonView = crouton.GetView();

            if (null == croutonView.Parent)
            {
                ViewGroup.LayoutParams parameters = croutonView.LayoutParameters;
                if (null == parameters)
                {
                    parameters = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                  ViewGroup.LayoutParams.WrapContent);
                }

                Activity activity = crouton.GetActivity();
                if (null == activity || activity.IsFinishing)
                {
                    return;
                }
                HandleTranslucentActionBar((ViewGroup.MarginLayoutParams)parameters, activity);
                HandleActionBarOverlay((ViewGroup.MarginLayoutParams)parameters, activity);

                activity.AddContentView(croutonView, parameters);
            }

            croutonView.RequestLayout(); // This is needed so the animation can use the measured with/height
            ViewTreeObserver observer = croutonView.ViewTreeObserver;

            if (null != observer)
            {
                CallOnGlobalLayout(crouton, croutonView);
            }
        }
Esempio n. 2
0
        private void CallOnGlobalLayout(Crouton crouton, View croutonView)
        {
            var layoutListener = new GlobalLayoutListener();

            layoutListener.OnGlobalLayout(delegate
            {
                if (Build.VERSION.SdkInt < Build.VERSION_CODES.JellyBean)
                {
                    croutonView.ViewTreeObserver.RemoveGlobalOnLayoutListener(layoutListener);
                }
                else
                {
                    croutonView.ViewTreeObserver.RemoveOnGlobalLayoutListener(layoutListener);
                }

                if (crouton.GetInAnimation() != null)
                {
                    croutonView.StartAnimation(crouton.GetInAnimation());
                    AnnounceForAccessibilityCompat(crouton.GetActivity(), crouton.DataContext == null ? "NULL" : crouton.DataContext.ToString());
                    SendMessageDelayed(crouton, REMOVE_CROUTON,
                                       crouton.DurationInMilliseconds + crouton.GetInAnimation().Duration);
                }
            });
        }
        private void CallOnGlobalLayout(Crouton crouton, View croutonView)
        {
            var layoutListener = new GlobalLayoutListener();
            layoutListener.OnGlobalLayout(delegate
            {
                if (Build.VERSION.SdkInt < Build.VERSION_CODES.JellyBean)
                {
                    croutonView.ViewTreeObserver.RemoveGlobalOnLayoutListener(layoutListener);
                }
                else
                {
                    croutonView.ViewTreeObserver.RemoveOnGlobalLayoutListener(layoutListener);
                }

                if (crouton.GetInAnimation() != null)
                {
                    croutonView.StartAnimation(crouton.GetInAnimation());
                    AnnounceForAccessibilityCompat(crouton.GetActivity(), crouton.DataContext == null ? "NULL" : crouton.DataContext.ToString());
                    SendMessageDelayed(crouton, REMOVE_CROUTON,
                    crouton.DurationInMilliseconds + crouton.GetInAnimation().Duration);
                }
            });
        }
        private void AddCroutonToView(Crouton crouton)
        {
            // don't Add if it is already showing
            if (crouton.IsShowing())
            {
                return;
            }

            View croutonView = crouton.GetView();
            if (null == croutonView.Parent)
            {
                ViewGroup.LayoutParams parameters = croutonView.LayoutParameters;
                if (null == parameters)
                {
                    parameters = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MatchParent,
                        ViewGroup.LayoutParams.WrapContent);
                }

                Activity activity = crouton.GetActivity();
                if (null == activity || activity.IsFinishing)
                {
                    return;
                }
                HandleTranslucentActionBar((ViewGroup.MarginLayoutParams) parameters, activity);
                HandleActionBarOverlay((ViewGroup.MarginLayoutParams) parameters, activity);

                activity.AddContentView(croutonView, parameters);
            }

            croutonView.RequestLayout(); // This is needed so the animation can use the measured with/height
            ViewTreeObserver observer = croutonView.ViewTreeObserver;
            if (null != observer)
            {
                CallOnGlobalLayout(crouton, croutonView);
            }
        }