private void SendMessageDelayed(Crouton crouton, Int64 messageId, long delay) { Message message = ObtainMessage((int)messageId); message.Obj = crouton; SendMessageDelayed(message, delay); }
public void RemoveCrouton(Crouton crouton) { View croutonView = crouton.GetView(); var croutonParentView = (ViewGroup)croutonView.Parent; if (null != croutonParentView) { 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); } }
private void SendMessage(Crouton crouton, int messageId) { Message message = ObtainMessage(messageId); message.Obj = crouton; SendMessage(message); }
private long CalculateCroutonDuration(Crouton crouton) { long croutonDuration = crouton.DurationInMilliseconds; croutonDuration += crouton.GetInAnimation().Duration; croutonDuration += crouton.GetOutAnimation().Duration; return croutonDuration; }
private long CalculateCroutonDuration(Crouton crouton) { long croutonDuration = crouton.DurationInMilliseconds; croutonDuration += crouton.GetInAnimation().Duration; croutonDuration += crouton.GetOutAnimation().Duration; return(croutonDuration); }
public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null, bool clickable = true) { var taskCompletionSource = new TaskCompletionSource<bool>(); Activity currentActivity = _context as Activity; if (currentActivity == null) return Task.FromResult(false); View view = _customRenderer.Render(currentActivity, type, title, description, context); Crouton crouton = new Crouton(currentActivity, view, (int)duration.TotalMilliseconds, b => { if (clickable) { taskCompletionSource.TrySetResult(b); } }, context); crouton.Show(); return taskCompletionSource.Task; }
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); } }
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)); } View view = _customRenderer.Render(_activity, type, title, description, context); Crouton crouton = new Crouton(_activity, view, (int)duration.TotalMilliseconds, b => { if (clickable) { taskCompletionSource.TrySetResult(b); } }, context); crouton.Show(); return(taskCompletionSource.Task); }
private void CallOnGlobalLayout(Crouton crouton, View croutonView) { var layoutListener = new GlobalLayoutListener(); layoutListener.OnGlobalLayout(delegate { if (Build.VERSION.SdkInt < BuildVersionCodes.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); } }); }
public void Add(Crouton crouton) { _croutonQueue.Add(crouton); DisplayCrouton(); }
private void SendMessageDelayed(Crouton crouton, Int64 messageId, long delay) { Message message = ObtainMessage((int) messageId); message.Obj = crouton; SendMessageDelayed(message, delay); }
public void RemoveCrouton(Crouton crouton) { View croutonView = crouton.GetView(); var croutonParentView = (ViewGroup) croutonView.Parent; if (null != croutonParentView) { 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); } }
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); } }