Inheritance: Java.Lang.Object
Example #1
0
        public void ClearMsg(AppMsg appMsg)
        {
            if (msgQueue.Contains(appMsg) || stickyQueue.Contains(appMsg))
            {
                RemoveMessages(MESSAGE_DISPLAY, appMsg);
                RemoveMessages(MESSAGE_ADD_VIEW, appMsg);
                RemoveMessages(MESSAGE_REMOVE, appMsg);
                Queue <AppMsg> save  = new Queue <AppMsg>();
                int            count = msgQueue.Count;
                for (int i = 0; i < count; i++)
                {
                    AppMsg msg = msgQueue.Dequeue();
                    if (msg == appMsg)
                    {
                        continue;
                    }
                    save.Enqueue(msg);
                }
                msgQueue = save;
                save     = new Queue <AppMsg>();

                count = stickyQueue.Count;
                for (int i = 0; i < count; i++)
                {
                    AppMsg msg = stickyQueue.Dequeue();
                    if (msg == appMsg)
                    {
                        continue;
                    }
                    save.Enqueue(msg);
                }
                stickyQueue = save;
            }
        }
Example #2
0
        private static AppMsg MakeText(Activity context, String text, Style style, View view, bool floating, float textSize, View.IOnClickListener clickListener)
        {
            AppMsg result = new AppMsg(context);

            view.SetBackgroundColor(style.BackgroundColor);
            view.Clickable = true;

            TextView tv = view.FindViewById <TextView>(Android.Resource.Id.Message);

            if (textSize > 0)
            {
                tv.SetTextSize(Android.Util.ComplexUnitType.Sp, textSize);
            }
            else
            {
                tv.SetTextSize(Android.Util.ComplexUnitType.Dip, TEXTSIZE);
            }
            tv.Text = text;
            tv.SetTextColor(style.TextColor);

            result.mView     = view;
            result.mDuration = style.Duration;
            result.mFloating = floating;

            view.SetOnClickListener(clickListener);
            return(result);
        }
Example #3
0
 public void Add(AppMsg appMsg)
 {
     msgQueue.Enqueue(appMsg);
     if (appMsg.mInAnimation == null)
     {
         appMsg.mInAnimation = AnimationUtils.LoadAnimation(appMsg.Activity, Android.Resource.Animation.FadeIn);
     }
     if (appMsg.mOutAnimation == null)
     {
         appMsg.mOutAnimation = AnimationUtils.LoadAnimation(appMsg.Activity, Android.Resource.Animation.FadeOut);
     }
     DisplayMsg();
 }
Example #4
0
        public void RemoveMsg(AppMsg appMsg)
        {
            ClearMsg(appMsg);
            View      view   = appMsg.View;
            ViewGroup parent = (ViewGroup)view.Parent;

            if (parent != null)
            {
                appMsg.mOutAnimation.SetAnimationListener(new OutAnimationListener(appMsg));
                view.ClearAnimation();
                view.StartAnimation(appMsg.mOutAnimation);
            }
            Message msg = ObtainMessage(MESSAGE_DISPLAY);

            SendMessage(msg);
        }
Example #5
0
        private void DisplayMsg()
        {
            if (msgQueue.Count <= 0)
            {
                return;
            }
            AppMsg  appMsg = msgQueue.Peek();
            Message msg;

            if (!appMsg.IsShowing)
            {
                msg     = ObtainMessage(MESSAGE_ADD_VIEW);
                msg.Obj = appMsg;
                SendMessage(msg);
            }
            else if (appMsg.Duration != AppMsg.LENGTH_STICKY)
            {
                msg = ObtainMessage(MESSAGE_DISPLAY);
                SendMessageDelayed(msg, appMsg.Duration + appMsg.mInAnimation.Duration + appMsg.mOutAnimation.Duration);
            }
        }
Example #6
0
        private void AddMsgToView(AppMsg appMsg)
        {
            View view = appMsg.View;

            if (view.Parent == null)
            {
                ViewGroup targetParent       = appMsg.Parent;
                ViewGroup.LayoutParams param = appMsg.LayoutParams;
                if (targetParent != null)
                {
                    targetParent.AddView(view, param);
                }
                else
                {
                    appMsg.Activity.AddContentView(view, param);
                }
            }
            view.ClearAnimation();
            view.StartAnimation(appMsg.mInAnimation);
            if (view.Visibility != ViewStates.Visible)
            {
                view.Visibility = ViewStates.Visible;
            }
            int duration = appMsg.Duration;

            if (duration != AppMsg.LENGTH_STICKY)
            {
                Message msg = ObtainMessage(MESSAGE_REMOVE);
                msg.Obj = appMsg;
                SendMessageDelayed(msg, duration);
            }
            else
            {
                stickyQueue.Enqueue(msgQueue.Dequeue());
            }
        }
Example #7
0
 public void Add(AppMsg appMsg)
 {
     msgQueue.Enqueue(appMsg);
     if (appMsg.mInAnimation == null)
     {
         appMsg.mInAnimation = AnimationUtils.LoadAnimation(appMsg.Activity, Android.Resource.Animation.FadeIn);
     }
     if (appMsg.mOutAnimation == null)
     {
         appMsg.mOutAnimation = AnimationUtils.LoadAnimation(appMsg.Activity, Android.Resource.Animation.FadeOut);
     }
     DisplayMsg();
 }
Example #8
0
 private void AddMsgToView(AppMsg appMsg)
 {
     View view = appMsg.View;
     if (view.Parent == null)
     {
         ViewGroup targetParent = appMsg.Parent;
         ViewGroup.LayoutParams param = appMsg.LayoutParams;
         if (targetParent != null)
         {
             targetParent.AddView(view, param);
         }
         else
         {
             appMsg.Activity.AddContentView(view, param);
         }
     }
     view.ClearAnimation();
     view.StartAnimation(appMsg.mInAnimation);
     if (view.Visibility != ViewStates.Visible)
     {
         view.Visibility = ViewStates.Visible;
     }
     int duration = appMsg.Duration;
     if (duration != AppMsg.LENGTH_STICKY)
     {
         Message msg = ObtainMessage(MESSAGE_REMOVE);
         msg.Obj = appMsg;
         SendMessageDelayed(msg, duration);
     }
     else
     {
         stickyQueue.Enqueue(msgQueue.Dequeue());
     }
 }
Example #9
0
 public void RemoveMsg(AppMsg appMsg)
 {
     ClearMsg(appMsg);
     View view = appMsg.View;
     ViewGroup parent = (ViewGroup)view.Parent;
     if (parent != null)
     {
         appMsg.mOutAnimation.SetAnimationListener(new OutAnimationListener(appMsg));
         view.ClearAnimation();
         view.StartAnimation(appMsg.mOutAnimation);
     }
     Message msg = ObtainMessage(MESSAGE_DISPLAY);
     SendMessage(msg);
 }
Example #10
0
        public void ClearMsg(AppMsg appMsg)
        {
            if (msgQueue.Contains(appMsg) || stickyQueue.Contains(appMsg))
            {
                RemoveMessages(MESSAGE_DISPLAY, appMsg);
                RemoveMessages(MESSAGE_ADD_VIEW, appMsg);
                RemoveMessages(MESSAGE_REMOVE, appMsg);
                Queue<AppMsg> save = new Queue<AppMsg>();
                int count = msgQueue.Count;
                for (int i = 0; i < count; i++)
                {
                    AppMsg msg = msgQueue.Dequeue();
                    if (msg == appMsg)
                    {
                        continue;
                    }
                    save.Enqueue(msg);
                }
                msgQueue = save;
                save = new Queue<AppMsg>();

                count = stickyQueue.Count;
                for (int i = 0; i < count; i++)
                {
                    AppMsg msg = stickyQueue.Dequeue();
                    if (msg == appMsg)
                    {
                        continue;
                    }
                    save.Enqueue(msg);
                }
                stickyQueue = save;
            }
        }
Example #11
0
 public OutAnimationListener(AppMsg appMsg)
 {
     this.appMsg = appMsg;
 }
 public OutAnimationListener(AppMsg appMsg)
 {
     this.appMsg = appMsg;
 }
Example #13
0
        private static AppMsg MakeText(Activity context, String text, Style style, View view, bool floating, float textSize, View.IOnClickListener clickListener)
        {
            AppMsg result = new AppMsg(context);

            view.SetBackgroundColor(style.BackgroundColor);
            view.Clickable = true;

            TextView tv = view.FindViewById<TextView>(Android.Resource.Id.Message);
            if (textSize > 0)
            {
                tv.SetTextSize(Android.Util.ComplexUnitType.Sp, textSize);
            }
            else
            {
                tv.SetTextSize(Android.Util.ComplexUnitType.Dip, TEXTSIZE);
            }
            tv.Text = text;
            tv.SetTextColor(style.TextColor);

            result.mView = view;
            result.mDuration = style.Duration;
            result.mFloating = floating;

            view.SetOnClickListener(clickListener);
            return result;
        }