Exemplo n.º 1
0
        public ExpandHelper(Context context, Callback callback, int small, int large)
        {
            this.smallSize      = small;
            this.maximumStretch = Math.Max(smallSize, 1) * StretchInterval;
            this.largeSize      = large;
            this.context        = context;
            this.callback       = callback;
            this.scaler         = new ViewScaler();
            this.gravity        = GravityFlags.Top;

            //this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f);
            this.scaleAnimation         = ValueAnimator.OfFloat(0f);
            this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue;
            this.scaleAnimation.SetDuration(ExpandDuration);

            AnimatorListenerAdapter glowVisibilityController = new AnimatorListener();

            glowTopAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f);
            glowTopAnimation.AddListener(glowVisibilityController);
            glowBottomAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f);
            glowBottomAnimation.AddListener(glowVisibilityController);
            glowAnimationSet = new AnimatorSet();
            glowAnimationSet.Play(glowTopAnimation).With(glowBottomAnimation);
            glowAnimationSet.SetDuration(GlowDuration);

            detector = new DoubleSwipeDetector(context, new GestureDetector(this));
        }
Exemplo n.º 2
0
            public bool OnScale(DoubleSwipeDetector detector)
            {
                // are we scaling or dragging?
                float span = Math.Abs(detector.CurrentSpan) - parent.initialTouchSpan;

                span *= UseSpan ? 1f : 0f;
                float drag = detector.FocusY - parent.initialTouchFocusY;

                drag *= UseDrag ? 1f : 0f;
                drag *= parent.gravity == GravityFlags.Bottom ? -1f : 1f;
                float pull = Math.Abs(drag) + Math.Abs(span) + 1f;
                float hand = drag * Math.Abs(drag) / pull + span * Math.Abs(span) / pull;

                hand = hand + parent.oldHeight;
                float target = hand;

                hand = hand < parent.smallSize ? parent.smallSize : (hand > parent.largeSize ? parent.largeSize : hand);
                hand = hand > parent.naturalHeight ? parent.naturalHeight : hand;

                parent.scaler.Height = hand;

                // glow if overscale
                float stretch  = (float)Math.Abs((target - hand) / parent.maximumStretch);
                float strength = 1f / (1f + (float)Math.Pow(Math.E, -1 * ((8f * stretch) - 5f)));

                parent.SetGlow(GlowBase + strength * (1f - GlowBase));
                return(true);
            }
Exemplo n.º 3
0
            public bool OnScaleBegin(DoubleSwipeDetector detector)
            {
                float x = detector.FocusX;
                float y = detector.FocusY;

                View v = null;

                if (parent.eventSource != null)
                {
                    int[] location = new int[2];
                    parent.eventSource.GetLocationOnScreen(location);
                    x += (float)location[0];
                    y += (float)location[1];
                    v  = parent.callback.GetChildAtRawPosition(x, y);
                }
                else
                {
                    v = parent.callback.GetChildAtPosition(x, y);
                }

                // your fingers have to be somewhat close to the bounds of the view in question
                parent.initialTouchFocusY = detector.FocusY;
                parent.initialTouchSpan   = Math.Abs(detector.CurrentSpan);

                parent.stretching = parent.InitScale(v);
                return(parent.stretching);
            }
Exemplo n.º 4
0
 public void OnScaleEnd(DoubleSwipeDetector detector)
 {
     // Intentionally empty
 }
Exemplo n.º 5
0
 public bool OnScaleBegin(DoubleSwipeDetector detector)
 {
     return(true);
 }
Exemplo n.º 6
0
 public bool OnScale(DoubleSwipeDetector detector)
 {
     return(false);
 }
Exemplo n.º 7
0
		public ExpandHelper(Context context, Callback callback, int small, int large) {
			this.smallSize = small;
			this.maximumStretch = Math.Max (smallSize, 1) * StretchInterval;
			this.largeSize = large;
			this.context = context;
			this.callback = callback;
			this.scaler = new ViewScaler();
			this.gravity = GravityFlags.Top;

			//this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f);
			this.scaleAnimation = ValueAnimator.OfFloat (0f);
			this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue;
			this.scaleAnimation.SetDuration (ExpandDuration);

			AnimatorListenerAdapter glowVisibilityController = new AnimatorListener ();
			glowTopAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f);
			glowTopAnimation.AddListener (glowVisibilityController);
			glowBottomAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f);
			glowBottomAnimation.AddListener (glowVisibilityController);
			glowAnimationSet = new AnimatorSet();
			glowAnimationSet.Play (glowTopAnimation).With(glowBottomAnimation);
			glowAnimationSet.SetDuration(GlowDuration);

			detector = new DoubleSwipeDetector(context, new GestureDetector (this));
		}
Exemplo n.º 8
0
			public void OnScaleEnd(DoubleSwipeDetector detector)
			{
				parent.FinishScale(false);
			}
Exemplo n.º 9
0
			public bool OnScale (DoubleSwipeDetector detector)
			{
				// are we scaling or dragging?
				float span = Math.Abs(detector.CurrentSpan) - parent.initialTouchSpan;
				span *= UseSpan ? 1f : 0f;
				float drag = detector.FocusY - parent.initialTouchFocusY;
				drag *= UseDrag ? 1f : 0f;
				drag *= parent.gravity == GravityFlags.Bottom ? -1f : 1f;
				float pull = Math.Abs(drag) + Math.Abs(span) + 1f;
				float hand = drag * Math.Abs(drag) / pull + span * Math.Abs(span) / pull;

				hand = hand + parent.oldHeight;
				float target = hand;

				hand = hand < parent.smallSize ? parent.smallSize : (hand > parent.largeSize ? parent.largeSize : hand);
				hand = hand > parent.naturalHeight ? parent.naturalHeight : hand;

				parent.scaler.Height = hand;

				// glow if overscale
				float stretch = (float) Math.Abs((target - hand) / parent.maximumStretch);
				float strength = 1f / (1f + (float) Math.Pow(Math.E, -1 * ((8f * stretch) - 5f)));
				parent.SetGlow(GlowBase + strength * (1f - GlowBase));
				return true;
			}
Exemplo n.º 10
0
			public bool OnScaleBegin (DoubleSwipeDetector detector)
			{
				float x = detector.FocusX;
				float y = detector.FocusY;

				View v = null;
				if (parent.eventSource != null) {
					int[] location = new int[2];
					parent.eventSource.GetLocationOnScreen(location);
					x += (float) location[0];
					y += (float) location[1];
					v = parent.callback.GetChildAtRawPosition(x, y);
				} else {
					v = parent.callback.GetChildAtPosition(x, y);
				}

				// your fingers have to be somewhat close to the bounds of the view in question
				parent.initialTouchFocusY = detector.FocusY;
				parent.initialTouchSpan = Math.Abs(detector.CurrentSpan);

				parent.stretching = parent.InitScale(v);
				return parent.stretching;
			}
Exemplo n.º 11
0
			public void OnScaleEnd(DoubleSwipeDetector detector) {
				// Intentionally empty
			}
Exemplo n.º 12
0
			public bool OnScaleBegin(DoubleSwipeDetector detector) {
				return true;
			}
Exemplo n.º 13
0
			public bool OnScale(DoubleSwipeDetector detector) {
				return false;
			}
Exemplo n.º 14
0
 public void OnScaleEnd(DoubleSwipeDetector detector)
 {
     parent.FinishScale(false);
 }