コード例 #1
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        private void sendMessageDelayed(Crouton crouton, Int64 messageId, long delay)
        {
            var message = ObtainMessage((int)messageId);

            message.Obj = crouton;
            SendMessageDelayed(message, delay);
        }
コード例 #2
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        public void RemoveCrouton(Crouton crouton)
        {
            var croutonView       = crouton.GetView();
            var croutonParentView = (ViewGroup)croutonView.Parent;

            if (null == croutonParentView)
            {
                return;
            }
            croutonView.StartAnimation(crouton.GetOutAnimation());

            // Remove the Crouton from the queue.
            var removed = (Crouton)croutonQueue.Poll();

            // Remove the crouton from the view's parent.
            croutonParentView.RemoveView(croutonView);
            if (null != removed)
            {
                removed.DetachActivity();
                removed.OnRemoved();
                removed.DetachLifecycleCallback();
            }

            // Send a message to display the next crouton but delay it by the out
            // animation duration to Make sure it finishes
            sendMessageDelayed(crouton, DISPLAY_CROUTON, crouton.GetOutAnimation().Duration);
        }
コード例 #3
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        private void sendMessage(Crouton crouton, int messageId)
        {
            var message = ObtainMessage(messageId);

            message.Obj = crouton;
            SendMessage(message);
        }
コード例 #4
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        private void callOnGlobalLayout(Crouton crouton, View croutonView)
        {
            var layoutListener = new GlobalLayoutListener();

            layoutListener.OnGlobalLayout(delegate
            {
                if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean)
                {
#pragma warning disable 618
                    croutonView?.ViewTreeObserver?.RemoveGlobalOnLayoutListener(layoutListener);
#pragma warning restore 618
                }
                else
                {
                    croutonView?.ViewTreeObserver?.RemoveOnGlobalLayoutListener(layoutListener);
                }

                if (crouton.GetInAnimation() == null)
                {
                    return;
                }
                croutonView?.StartAnimation(crouton.GetInAnimation());
                AnnounceForAccessibilityCompat(crouton.GetActivity(), crouton.DataContext?.ToString() ?? "NULL");
                sendMessageDelayed(crouton, REMOVE_CROUTON,
                                   crouton.DurationInMilliseconds + crouton.GetInAnimation().Duration);
            });
        }
コード例 #5
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        private void addCroutonToView(Crouton crouton)
        {
            // don't Add if it is already showing
            if (crouton.IsShowing())
            {
                return;
            }

            var croutonView = crouton.GetView();

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

                var 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
            var observer = croutonView.ViewTreeObserver;

            if (null != observer)
            {
                callOnGlobalLayout(crouton, croutonView);
            }
        }
コード例 #6
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
        private long CalculateCroutonDuration(Crouton crouton)
        {
            long croutonDuration = crouton.DurationInMilliseconds;

            croutonDuration += crouton.GetInAnimation().Duration;
            croutonDuration += crouton.GetOutAnimation().Duration;
            return(croutonDuration);
        }
コード例 #7
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null, bool clickable = true)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            if (activity == null)
            {
                return(Task.FromResult(false));
            }

            var view = customRenderer.Render(activity, type, title, description, context);

            var crouton = new Crouton(activity, view, (int)duration.TotalMilliseconds,
                                      b =>
            {
                if (clickable)
                {
                    taskCompletionSource.TrySetResult(b);
                }
            }, context);

            crouton.Show();
            return(taskCompletionSource.Task);
        }
コード例 #8
0
ファイル: Manager.cs プロジェクト: uptickguru/MyStash
 public void Add(Crouton crouton)
 {
     croutonQueue.Add(crouton);
     displayCrouton();
 }