Пример #1
0
		internal override void transformViewForTransition(int fromIndex, int toIndex, android.view.View
			 view, bool animate_1)
		{
			if (!animate_1)
			{
				((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
				view.setRotationX(0f);
				android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
					)view.getLayoutParams();
				lp.setVerticalOffset(0);
				lp.setHorizontalOffset(0);
			}
			if (fromIndex == -1 && toIndex == getNumActiveViews() - 1)
			{
				transformViewAtIndex(toIndex, view, false);
				view.setVisibility(VISIBLE);
				view.setAlpha(1.0f);
			}
			else
			{
				if (fromIndex == 0 && toIndex == 1)
				{
					((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
					view.setVisibility(VISIBLE);
					int duration = Sharpen.Util.Round(mStackSlider.getDurationForNeutralPosition(mYVelocity
						));
					android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
						.StackSlider(this, mStackSlider);
					animationSlider.setView(view);
					if (animate_1)
					{
						android.animation.PropertyValuesHolder slideInY = android.animation.PropertyValuesHolder
							.ofFloat("YProgress", 0.0f);
						android.animation.PropertyValuesHolder slideInX = android.animation.PropertyValuesHolder
							.ofFloat("XProgress", 0.0f);
						android.animation.ObjectAnimator slideIn = android.animation.ObjectAnimator.ofPropertyValuesHolder
							(animationSlider, slideInX, slideInY);
						slideIn.setDuration(duration);
						slideIn.setInterpolator(new android.view.animation.LinearInterpolator());
						((android.widget.StackView.StackFrame)view).setSliderAnimator(slideIn);
						slideIn.start();
					}
					else
					{
						animationSlider.setYProgress(0f);
						animationSlider.setXProgress(0f);
					}
				}
				else
				{
					if (fromIndex == 1 && toIndex == 0)
					{
						((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
						int duration = Sharpen.Util.Round(mStackSlider.getDurationForOffscreenPosition(mYVelocity
							));
						android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
							.StackSlider(this, mStackSlider);
						animationSlider.setView(view);
						if (animate_1)
						{
							android.animation.PropertyValuesHolder slideOutY = android.animation.PropertyValuesHolder
								.ofFloat("YProgress", 1.0f);
							android.animation.PropertyValuesHolder slideOutX = android.animation.PropertyValuesHolder
								.ofFloat("XProgress", 0.0f);
							android.animation.ObjectAnimator slideOut = android.animation.ObjectAnimator.ofPropertyValuesHolder
								(animationSlider, slideOutX, slideOutY);
							slideOut.setDuration(duration);
							slideOut.setInterpolator(new android.view.animation.LinearInterpolator());
							((android.widget.StackView.StackFrame)view).setSliderAnimator(slideOut);
							slideOut.start();
						}
						else
						{
							animationSlider.setYProgress(1.0f);
							animationSlider.setXProgress(0f);
						}
					}
					else
					{
						if (toIndex == 0)
						{
							view.setAlpha(0.0f);
							view.setVisibility(INVISIBLE);
						}
						else
						{
							if ((fromIndex == 0 || fromIndex == 1) && toIndex > 1)
							{
								view.setVisibility(VISIBLE);
								view.setAlpha(1.0f);
								view.setRotationX(0f);
								android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
									)view.getLayoutParams();
								lp.setVerticalOffset(0);
								lp.setHorizontalOffset(0);
							}
							else
							{
								if (fromIndex == -1)
								{
									view.setAlpha(1.0f);
									view.setVisibility(VISIBLE);
								}
								else
								{
									if (toIndex == -1)
									{
										if (animate_1)
										{
											postDelayed(new _Runnable_294(view), STACK_RELAYOUT_DURATION);
										}
										else
										{
											view.setAlpha(0f);
										}
									}
								}
							}
						}
					}
				}
			}
			// Implement the faked perspective
			if (toIndex != -1)
			{
				transformViewAtIndex(toIndex, view, animate_1);
			}
		}
Пример #2
0
		private void handlePointerUp(android.view.MotionEvent ev)
		{
			int pointerIndex = ev.findPointerIndex(mActivePointerId);
			float newY = ev.getY(pointerIndex);
			int deltaY = (int)(newY - mInitialY);
			mLastInteractionTime = Sharpen.Util.CurrentTimeMillis;
			if (mVelocityTracker != null)
			{
				mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
				mYVelocity = (int)mVelocityTracker.getYVelocity(mActivePointerId);
			}
			if (mVelocityTracker != null)
			{
				mVelocityTracker.recycle();
				mVelocityTracker = null;
			}
			if (deltaY > mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_DOWN && mStackSlider
				.mMode == android.widget.StackView.StackSlider.NORMAL_MODE)
			{
				// We reset the gesture variable, because otherwise we will ignore showPrevious() /
				// showNext();
				mSwipeGestureType = GESTURE_NONE;
				// Swipe threshold exceeded, swipe down
				if (mStackMode == ITEMS_SLIDE_UP)
				{
					showPrevious();
				}
				else
				{
					showNext();
				}
				mHighlight.bringToFront();
			}
			else
			{
				if (deltaY < -mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_UP && mStackSlider
					.mMode == android.widget.StackView.StackSlider.NORMAL_MODE)
				{
					// We reset the gesture variable, because otherwise we will ignore showPrevious() /
					// showNext();
					mSwipeGestureType = GESTURE_NONE;
					// Swipe threshold exceeded, swipe up
					if (mStackMode == ITEMS_SLIDE_UP)
					{
						showNext();
					}
					else
					{
						showPrevious();
					}
					mHighlight.bringToFront();
				}
				else
				{
					if (mSwipeGestureType == GESTURE_SLIDE_UP)
					{
						// Didn't swipe up far enough, snap back down
						int duration;
						float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 1 : 0;
						if (mStackMode == ITEMS_SLIDE_UP || mStackSlider.mMode != android.widget.StackView
							.StackSlider.NORMAL_MODE)
						{
							duration = Sharpen.Util.Round(mStackSlider.getDurationForNeutralPosition());
						}
						else
						{
							duration = Sharpen.Util.Round(mStackSlider.getDurationForOffscreenPosition());
						}
						android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
							.StackSlider(this, mStackSlider);
						android.animation.PropertyValuesHolder snapBackY = android.animation.PropertyValuesHolder
							.ofFloat("YProgress", finalYProgress);
						android.animation.PropertyValuesHolder snapBackX = android.animation.PropertyValuesHolder
							.ofFloat("XProgress", 0.0f);
						android.animation.ObjectAnimator pa = android.animation.ObjectAnimator.ofPropertyValuesHolder
							(animationSlider, snapBackX, snapBackY);
						pa.setDuration(duration);
						pa.setInterpolator(new android.view.animation.LinearInterpolator());
						pa.start();
					}
					else
					{
						if (mSwipeGestureType == GESTURE_SLIDE_DOWN)
						{
							// Didn't swipe down far enough, snap back up
							float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 0 : 1;
							int duration;
							if (mStackMode == ITEMS_SLIDE_DOWN || mStackSlider.mMode != android.widget.StackView
								.StackSlider.NORMAL_MODE)
							{
								duration = Sharpen.Util.Round(mStackSlider.getDurationForNeutralPosition());
							}
							else
							{
								duration = Sharpen.Util.Round(mStackSlider.getDurationForOffscreenPosition());
							}
							android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
								.StackSlider(this, mStackSlider);
							android.animation.PropertyValuesHolder snapBackY = android.animation.PropertyValuesHolder
								.ofFloat("YProgress", finalYProgress);
							android.animation.PropertyValuesHolder snapBackX = android.animation.PropertyValuesHolder
								.ofFloat("XProgress", 0.0f);
							android.animation.ObjectAnimator pa = android.animation.ObjectAnimator.ofPropertyValuesHolder
								(animationSlider, snapBackX, snapBackY);
							pa.setDuration(duration);
							pa.start();
						}
					}
				}
			}
			mActivePointerId = INVALID_POINTER;
			mSwipeGestureType = GESTURE_NONE;
		}
Пример #3
0
		private void initStackView()
		{
			configureViewAnimator(NUM_ACTIVE_VIEWS, 1);
			setStaticTransformationsEnabled(true);
			android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get
				(getContext());
			mTouchSlop = configuration.getScaledTouchSlop();
			mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
			mActivePointerId = INVALID_POINTER;
			mHighlight = new android.widget.ImageView(getContext());
			mHighlight.setLayoutParams(new android.widget.StackView.LayoutParams(this, mHighlight
				));
			addViewInLayout(mHighlight, -1, new android.widget.StackView.LayoutParams(this, mHighlight
				));
			mClickFeedback = new android.widget.ImageView(getContext());
			mClickFeedback.setLayoutParams(new android.widget.StackView.LayoutParams(this, mClickFeedback
				));
			addViewInLayout(mClickFeedback, -1, new android.widget.StackView.LayoutParams(this
				, mClickFeedback));
			mClickFeedback.setVisibility(INVISIBLE);
			mStackSlider = new android.widget.StackView.StackSlider(this);
			if (sHolographicHelper == null)
			{
				sHolographicHelper = new android.widget.StackView.HolographicHelper(mContext);
			}
			setClipChildren(false);
			setClipToPadding(false);
			// This sets the form of the StackView, which is currently to have the perspective-shifted
			// views above the active view, and have items slide down when sliding out. The opposite is
			// available by using ITEMS_SLIDE_UP.
			mStackMode = ITEMS_SLIDE_DOWN;
			// This is a flag to indicate the the stack is loading for the first time
			mWhichChild = -1;
			// Adjust the frame padding based on the density, since the highlight changes based
			// on the density
			float density = mContext.getResources().getDisplayMetrics().density;
			mFramePadding = (int)System.Math.Ceiling(density * FRAME_PADDING);
		}