Example #1
0
 private android.animation.Animator makeInAnimation()
 {
     mClose.setTranslationX(-mClose.getWidth() - ((android.view.ViewGroup.MarginLayoutParams
                                                   )mClose.getLayoutParams()).leftMargin);
     android.animation.ObjectAnimator buttonAnimator = android.animation.ObjectAnimator
                                                       .ofFloat(mClose, "translationX", 0);
     buttonAnimator.setDuration(200);
     buttonAnimator.addListener(this);
     buttonAnimator.setInterpolator(new android.view.animation.DecelerateInterpolator(
                                        ));
     android.animation.AnimatorSet         set = new android.animation.AnimatorSet();
     android.animation.AnimatorSet.Builder b   = set.play(buttonAnimator);
     if (mMenuView != null)
     {
         int count = mMenuView.getChildCount();
         if (count > 0)
         {
             {
                 int i = count - 1;
                 int j = 0;
                 for (; i >= 0; i--, j++)
                 {
                     android.view.View child = mMenuView.getChildAt(i);
                     child.setScaleY(0);
                     android.animation.ObjectAnimator a = android.animation.ObjectAnimator.ofFloat(child
                                                                                                   , "scaleY", 0, 1);
                     a.setDuration(100);
                     a.setStartDelay(j * 70);
                     b.with(a);
                 }
             }
         }
     }
     return(set);
 }
Example #2
0
        /// <summary>
        /// Will forward touch events to the delegate view if the event is within the bounds
        /// specified in the constructor.
        /// </summary>
        /// <remarks>
        /// Will forward touch events to the delegate view if the event is within the bounds
        /// specified in the constructor.
        /// </remarks>
        /// <param name="event">The touch event to forward</param>
        /// <returns>True if the event was forwarded to the delegate, false otherwise.</returns>
        public virtual bool onTouchEvent(android.view.MotionEvent @event)
        {
            int  x = (int)@event.getX();
            int  y = (int)@event.getY();
            bool sendToDelegate = false;
            bool hit            = true;
            bool handled        = false;

            switch (@event.getAction())
            {
            case android.view.MotionEvent.ACTION_DOWN:
            {
                android.graphics.Rect bounds = mBounds;
                if (bounds.contains(x, y))
                {
                    mDelegateTargeted = true;
                    sendToDelegate    = true;
                }
                break;
            }

            case android.view.MotionEvent.ACTION_UP:
            case android.view.MotionEvent.ACTION_MOVE:
            {
                sendToDelegate = mDelegateTargeted;
                if (sendToDelegate)
                {
                    android.graphics.Rect slopBounds = mSlopBounds;
                    if (!slopBounds.contains(x, y))
                    {
                        hit = false;
                    }
                }
                break;
            }

            case android.view.MotionEvent.ACTION_CANCEL:
            {
                sendToDelegate    = mDelegateTargeted;
                mDelegateTargeted = false;
                break;
            }
            }
            if (sendToDelegate)
            {
                android.view.View delegateView = mDelegateView;
                if (hit)
                {
                    // Offset event coordinates to be inside the target view
                    @event.setLocation(delegateView.getWidth() / 2, delegateView.getHeight() / 2);
                }
                else
                {
                    // Offset event coordinates to be outside the target view (in case it does
                    // something like tracking pressed state)
                    int slop = mSlop;
                    @event.setLocation(-(slop * 2), -(slop * 2));
                }
                handled = delegateView.dispatchTouchEvent(@event);
            }
            return(handled);
        }