Esempio n. 1
0
        public void SetCardStreamAnimator(CardStreamAnimator animators)
        {
            if (animators == null)
            {
                mAnimators = new CardStreamAnimator.EmptyAnimator();
            }
            else
            {
                mAnimators = animators;
            }

            LayoutTransition layoutTransition = LayoutTransition;

            if (layoutTransition != null)
            {
                layoutTransition.SetAnimator(LayoutTransitionType.Appearing, mAnimators.GetAppearingAnimator(Context));
                layoutTransition.SetAnimator(LayoutTransitionType.Disappearing, mAnimators.GetDisappearingAnimator(Context));
            }
        }
Esempio n. 2
0
        void Initialize(IAttributeSet attrs, int defStyle)
        {
            mTouchListener             = new OnTouchListener(this);
            mOnHieratchyChangeListener = new OnHierarchyChangeListener()
            {
                OnChildViewAddedAction = (View parent, View child) =>
                {
                    Log.Debug(TAG, "Child is added: " + child);
                    IViewParent scrollView = parent.Parent;
                    if (scrollView != null && scrollView is ScrollView)
                    {
                        ((ScrollView)scrollView).FullScroll(FocusSearchDirection.Down);
                    }
                    if (this.LayoutTransition != null)
                    {
                        View view = child.FindViewById(Resource.Id.card_actionarea);
                        if (view != null)
                        {
                            view.Alpha = 0;
                        }
                    }
                },
                OnChildViewRemovedAction = (View parent, View child) =>
                {
                    Log.Debug(TAG, "Child is removed: " + child);
                    mFixedViewList.Remove(child);
                }
            };

            mTransitionListener = new TransitionListener()
            {
                StartTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) =>
                {
                    Log.Debug(TAG, "Start LayoutTransition animation: " + transitionType);
                },
                EndTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) =>
                {
                    Log.Debug(TAG, "End LayoutTransition animation: " + transitionType);
                    if (transitionType == LayoutTransitionType.Appearing)
                    {
                        View area = view.FindViewById(Resource.Id.card_actionarea);
                        if (area != null)
                        {
                            RunShowActionAreaAnimation(container, area);
                        }
                    }
                }
            };

            float speedFactor = 1f;

            if (attrs != null)
            {
                TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.CardStream, defStyle, 0);

                if (a != null)
                {
                    int speedType = a.GetInt(Resource.Styleable.CardStream_animationDuration, 1001);
                    switch (speedType)
                    {
                    case ANIMATION_SPEED_FAST:
                        speedFactor = 0.5f;
                        break;

                    case ANIMATION_SPEED_NORMAL:
                        speedFactor = 1f;
                        break;

                    case ANIMATION_SPEED_SLOW:
                        speedFactor = 2f;
                        break;
                    }

                    string animatorName = a.GetString(Resource.Styleable.CardStream_animators);

                    try {
                        if (animatorName != null)
                        {
                            mAnimators = Class.ClassLoader.LoadClass(animatorName).NewInstance() as CardStreamAnimator;
                        }
                    }
                    catch (Exception e) {
                        Log.Error(TAG, "Failed to load animator: " + animatorName, e);
                    }
                    finally {
                        if (mAnimators == null)
                        {
                            mAnimators = new DefaultCardStreamAnimator();
                        }
                    }
                    a.Recycle();
                }
            }

            mAnimators.SpeedFactor = speedFactor;
            mSwipeSlop             = ViewConfiguration.Get(Context).ScaledTouchSlop;
            SetOnHierarchyChangeListener(mOnHieratchyChangeListener);
        }
		void Initialize (IAttributeSet attrs, int defStyle)
		{
			mTouchListener = new OnTouchListener (this);
			mOnHieratchyChangeListener = new OnHierarchyChangeListener()
			{
				OnChildViewAddedAction = (View parent, View child) =>
				{
					Log.Debug(TAG, "Child is added: " + child);
					IViewParent scrollView = parent.Parent;
					if (scrollView != null && scrollView is ScrollView)
					{
						((ScrollView)scrollView).FullScroll(FocusSearchDirection.Down);
					}
					if (this.LayoutTransition != null)
					{
						View view = child.FindViewById(Resource.Id.card_actionarea);
						if (view != null)
							view.Alpha = 0;
					}
				},
				OnChildViewRemovedAction = (View parent, View child) =>
				{
					Log.Debug(TAG, "Child is removed: " + child);
					mFixedViewList.Remove(child);
				}
			};

			mTransitionListener = new TransitionListener()
			{
				StartTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) =>
				{
					Log.Debug(TAG, "Start LayoutTransition animation: " + transitionType);
				},
				EndTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) =>
				{
					Log.Debug(TAG, "End LayoutTransition animation: " + transitionType);
					if (transitionType == LayoutTransitionType.Appearing)
					{
						View area = view.FindViewById(Resource.Id.card_actionarea);
						if (area != null)
						{
							RunShowActionAreaAnimation(container, area);
						}
					}
				}
			};

			float speedFactor = 1f;

			if (attrs != null) {

				TypedArray a = Context.ObtainStyledAttributes (attrs, Resource.Styleable.CardStream, defStyle, 0);

				if (a != null) {
					int speedType = a.GetInt (Resource.Styleable.CardStream_animationDuration, 1001);
					switch (speedType) {
					case ANIMATION_SPEED_FAST:
						speedFactor = 0.5f;
						break;
					case ANIMATION_SPEED_NORMAL:
						speedFactor = 1f;
						break;
					case ANIMATION_SPEED_SLOW:
						speedFactor = 2f;
						break;
					}

					string animatorName = a.GetString (Resource.Styleable.CardStream_animators);

					try {
						if (animatorName != null)
							mAnimators = Class.ClassLoader.LoadClass(animatorName).NewInstance() as CardStreamAnimator;
					}
					catch (Exception e) {
						Log.Error (TAG, "Failed to load animator: " + animatorName, e);
					}
					finally {
						if (mAnimators == null)
							mAnimators = new DefaultCardStreamAnimator ();
					}
					a.Recycle ();
				}
			}

			mAnimators.SpeedFactor = speedFactor;
			mSwipeSlop = ViewConfiguration.Get (Context).ScaledTouchSlop;
			SetOnHierarchyChangeListener (mOnHieratchyChangeListener);
		}
		public void SetCardStreamAnimator (CardStreamAnimator animators)
		{
			if (animators == null)
				mAnimators = new CardStreamAnimator.EmptyAnimator ();
			else
				mAnimators = animators;

			LayoutTransition layoutTransition = LayoutTransition;

			if (layoutTransition != null) {
				layoutTransition.SetAnimator (LayoutTransitionType.Appearing, mAnimators.GetAppearingAnimator (Context));
				layoutTransition.SetAnimator (LayoutTransitionType.Disappearing, mAnimators.GetDisappearingAnimator (Context));
			}
		}