Java Code Examples for com.nineoldandroids.view.ViewHelper#setPivotX()

The following examples show how to use com.nineoldandroids.view.ViewHelper#setPivotX() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
protected void animateTablet(View left, View right, float positionOffset) {		
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = 30.0f * positionOffset;
			mTrans = getOffsetXForRotation(mRot, left.getMeasuredWidth(),
					left.getMeasuredHeight());
			ViewHelper.setPivotX(left, left.getMeasuredWidth()/2);
			ViewHelper.setPivotY(left, left.getMeasuredHeight()/2);
			ViewHelper.setTranslationX(left, mTrans);
			ViewHelper.setRotationY(left, mRot);
			logState(left, "Left");
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -30.0f * (1-positionOffset);
			mTrans = getOffsetXForRotation(mRot, right.getMeasuredWidth(), 
					right.getMeasuredHeight());
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setTranslationX(right, mTrans);
			ViewHelper.setRotationY(right, mRot);
			logState(right, "Right");
		}
	}
}
 
Example 2
Source Project: Social   File: CubeTransformer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void transformPage(View view, float position) {
	if (position <= 0) {

		ViewHelper.setPivotX(view, view.getMeasuredWidth());
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		

		ViewHelper.setRotationY(view, 90f * position);
	} else if (position <= 1) {

		ViewHelper.setPivotX(view, 0);
		ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
		ViewHelper.setRotationY(view, 90f * position);
	}
}
 
Example 3
Source Project: school_shop   File: JazzyViewPager.java    License: MIT License 6 votes vote down vote up
private void animateAccordion(View left, View right, float positionOffset) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, 0);
			ViewHelper.setScaleX(left, 1-positionOffset);
		}
		if (right != null) {
			manageLayer(right, true);
			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, 0);
			ViewHelper.setScaleX(right, positionOffset);
		}
	}
}
 
Example 4
private void animateZoom(View left, View right, float positionOffset, boolean in) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*(1-positionOffset) :
				1+ZOOM_MAX - ZOOM_MAX*(1-positionOffset);
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
			ViewHelper.setScaleX(left, mScale);
			ViewHelper.setScaleY(left, mScale);
		}
		if (right != null) {
			manageLayer(right, true);
			mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*positionOffset :
				1+ZOOM_MAX - ZOOM_MAX*positionOffset;
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
		}
	}
}
 
Example 5
Source Project: JazzyViewPager   File: JazzyViewPager.java    License: Apache License 2.0 6 votes vote down vote up
private void animateCube(View left, View right, float positionOffset, boolean in) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (in ? 90.0f : -90.0f) * positionOffset;
			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
			ViewHelper.setRotationY(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -(in ? 90.0f : -90.0f) * (1-positionOffset);
			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setRotationY(right, mRot);
		}
	}
}
 
Example 6
private void animateCube(View left, View right, float positionOffset, boolean in) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (in ? 90.0f : -90.0f) * positionOffset;
			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
			ViewHelper.setRotationY(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -(in ? 90.0f : -90.0f) * (1-positionOffset);
			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setRotationY(right, mRot);
		}
	}
}
 
Example 7
Source Project: school_shop   File: JazzyViewPager.java    License: MIT License 6 votes vote down vote up
protected void animateTablet(View left, View right, float positionOffset) {		
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = 30.0f * positionOffset;
			mTrans = getOffsetXForRotation(mRot, left.getMeasuredWidth(),
					left.getMeasuredHeight());
			ViewHelper.setPivotX(left, left.getMeasuredWidth()/2);
			ViewHelper.setPivotY(left, left.getMeasuredHeight()/2);
			ViewHelper.setTranslationX(left, mTrans);
			ViewHelper.setRotationY(left, mRot);
			logState(left, "Left");
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = -30.0f * (1-positionOffset);
			mTrans = getOffsetXForRotation(mRot, right.getMeasuredWidth(), 
					right.getMeasuredHeight());
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
			ViewHelper.setTranslationX(right, mTrans);
			ViewHelper.setRotationY(right, mRot);
			logState(right, "Right");
		}
	}
}
 
Example 8
Source Project: UltimateAndroid   File: JazzyViewPager.java    License: Apache License 2.0 6 votes vote down vote up
private void animateCube(View left, View right, float positionOffset, boolean in) {
    if (mState != State.IDLE) {
        if (left != null) {
            manageLayer(left, true);
            mRot = (in ? 90.0f : -90.0f) * positionOffset;
            ViewHelper.setPivotX(left, left.getMeasuredWidth());
            ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
            ViewHelper.setRotationY(left, mRot);
        }
        if (right != null) {
            manageLayer(right, true);
            mRot = -(in ? 90.0f : -90.0f) * (1 - positionOffset);
            ViewHelper.setPivotX(right, 0);
            ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
            ViewHelper.setRotationY(right, mRot);
        }
    }
}
 
Example 9
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example 10
private void setScaleDirection(int direction) {

		int screenWidth = getScreenWidth();
		float pivotX;
		float pivotY = getScreenHeight() * mScaleValue; // 0.5

		if (direction == DIRECTION_LEFT) {
			scrollViewMenu = scrollViewLeftMenu;
			pivotX = screenWidth * (mScaleValue + 1.0f);
		} else {
			scrollViewMenu = scrollViewRightMenu;
			pivotX = screenWidth * (mScaleValue - 1.0f);
		}

		ViewHelper.setPivotX(viewActivity, pivotX);
		ViewHelper.setPivotY(viewActivity, pivotY);
		ViewHelper.setPivotX(imageViewShadow, pivotX);
		ViewHelper.setPivotY(imageViewShadow, pivotY);
		scaleDirection = direction;
	}
 
Example 11
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example 12
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
private void animateZoom(View left, View right, float positionOffset,
		boolean in)
{
	if (mState != State.IDLE)
	{
		if (left != null)
		{
			manageLayer(left, true);
			mScale = in ? ZOOM_MAX + (1 - ZOOM_MAX) * (1 - positionOffset)
					: 1 + ZOOM_MAX - ZOOM_MAX * (1 - positionOffset);
			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(left, mScale);
			ViewHelper.setScaleY(left, mScale);
		}
		if (right != null)
		{
			manageLayer(right, true);
			mScale = in ? ZOOM_MAX + (1 - ZOOM_MAX) * positionOffset : 1
					+ ZOOM_MAX - ZOOM_MAX * positionOffset;
			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
		}
	}
}
 
Example 13
protected void animateScroll(int position, float positionOffset) {
	if (mState != State.IDLE) {
		mRot = (float)(1-Math.cos(2*Math.PI*positionOffset))/2*30.0f;
		ViewHelper.setRotationY(this, mState == State.GOING_RIGHT ? mRot : -mRot);
		ViewHelper.setPivotX(this, getMeasuredWidth()*0.5f);
		ViewHelper.setPivotY(this, getMeasuredHeight()*0.5f);
	}
}
 
Example 14
Source Project: JazzyViewPager   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
protected void animateScroll(int position, float positionOffset) {
	if (mState != State.IDLE) {
		mRot = (float)(1-Math.cos(2*Math.PI*positionOffset))/2*30.0f;
		ViewHelper.setRotationY(this, mState == State.GOING_RIGHT ? mRot : -mRot);
		ViewHelper.setPivotX(this, getMeasuredWidth()*0.5f);
		ViewHelper.setPivotY(this, getMeasuredHeight()*0.5f);
	}
}
 
Example 15
Source Project: AndroidImageSlider   File: CubeInTransformer.java    License: MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	// Rotate the fragment on the left or right edge
       ViewHelper.setPivotX(view,position > 0 ? 0 : view.getWidth());
       ViewHelper.setPivotY(view,0);
       ViewHelper.setRotation(view,-90f * position);
}
 
Example 16
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
protected void animateScroll(int position, float positionOffset)
{
	if (mState != State.IDLE)
	{
		mRot = (float) (1 - Math.cos(2 * Math.PI * positionOffset)) / 2 * 30.0f;
		ViewHelper.setRotationY(this, mState == State.GOING_RIGHT ? mRot
				: -mRot);
		ViewHelper.setPivotX(this, getMeasuredWidth() * 0.5f);
		ViewHelper.setPivotY(this, getMeasuredHeight() * 0.5f);
	}
}
 
Example 17
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
protected void animateTablet(View left, View right, float positionOffset)
{
	if (mState != State.IDLE)
	{
		if (left != null)
		{
			manageLayer(left, true);
			mRot = 30.0f * positionOffset;
			mTrans = getOffsetXForRotation(mRot, left.getMeasuredWidth(),
					left.getMeasuredHeight());
			ViewHelper.setPivotX(left, left.getMeasuredWidth() / 2);
			ViewHelper.setPivotY(left, left.getMeasuredHeight() / 2);
			ViewHelper.setTranslationX(left, mTrans);
			ViewHelper.setRotationY(left, mRot);
			logState(left, "Left");
		}
		if (right != null)
		{
			manageLayer(right, true);
			mRot = -30.0f * (1 - positionOffset);
			mTrans = getOffsetXForRotation(mRot, right.getMeasuredWidth(),
					right.getMeasuredHeight());
			ViewHelper.setPivotX(right, right.getMeasuredWidth() * 0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
			ViewHelper.setTranslationX(right, mTrans);
			ViewHelper.setRotationY(right, mRot);
			logState(right, "Right");
		}
	}
}
 
Example 18
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 4 votes vote down vote up
private void animateFlipHorizontal(View left, View right,
		float positionOffset, int positionOffsetPixels)
{
	if (mState != State.IDLE)
	{
		if (left != null)
		{
			manageLayer(left, true);
			mRot = 180.0f * positionOffset;
			if (mRot > 90.0f)
			{
				left.setVisibility(View.INVISIBLE);
			} else
			{
				if (left.getVisibility() == View.INVISIBLE)
					left.setVisibility(View.VISIBLE);
				mTrans = positionOffsetPixels;
				ViewHelper.setPivotX(left, left.getMeasuredWidth() * 0.5f);
				ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
				ViewHelper.setTranslationX(left, mTrans);
				ViewHelper.setRotationY(left, mRot);
			}
		}
		if (right != null)
		{
			manageLayer(right, true);
			mRot = -180.0f * (1 - positionOffset);
			if (mRot < -90.0f)
			{
				right.setVisibility(View.INVISIBLE);
			} else
			{
				if (right.getVisibility() == View.INVISIBLE)
					right.setVisibility(View.VISIBLE);
				mTrans = -getWidth() - getPageMargin()
						+ positionOffsetPixels;
				ViewHelper
						.setPivotX(right, right.getMeasuredWidth() * 0.5f);
				ViewHelper.setPivotY(right,
						right.getMeasuredHeight() * 0.5f);
				ViewHelper.setTranslationX(right, mTrans);
				ViewHelper.setRotationY(right, mRot);
			}
		}
	}
}
 
Example 19
Source Project: MiBandDecompiled   File: CurlEffect.java    License: Apache License 2.0 4 votes vote down vote up
public void initView(View view, int i, int j)
{
    ViewHelper.setPivotX(view, 0.0F);
    ViewHelper.setPivotY(view, view.getHeight() / 2);
    ViewHelper.setRotationY(view, 90F);
}
 
Example 20
/**
 * The enter animation scales the hero in from its previous thumbnail
 * size/location. In parallel, the container of the activity is fading in.
 * When the picture is in place, we crossfade in the actual hero image.
 */
public void runEnterAnimation() {
    // Retrieve the data we need for the picture to display and
    // the thumbnail to animate it from
    Bundle bundle = getIntent().getExtras();
    final int thumbnailTop = bundle.getInt("top");
    final int thumbnailLeft = bundle.getInt("left");
    final int thumbnailWidth = bundle.getInt("width");
    final int thumbnailHeight = bundle.getInt("height");

    // Scale factors to make the large version the same size as the thumbnail
    float mWidthScale = (float) thumbnailWidth / animatedHero.getWidth();
    float mHeightScale = (float) thumbnailHeight / animatedHero.getHeight();

    // Set starting values for properties we're going to animate. These
    // values scale and position the full size version down to the thumbnail
    // size/location, from which we'll animate it back up
    ViewHelper.setPivotX(animatedHero, 0);
    ViewHelper.setPivotY(animatedHero, 0);
    ViewHelper.setScaleX(animatedHero, mWidthScale);
    ViewHelper.setScaleY(animatedHero, mHeightScale);
    ViewHelper.setTranslationX(animatedHero, thumbnailLeft);
    ViewHelper.setTranslationY(animatedHero, thumbnailTop);

    // Animate scale and translation to go from thumbnail to full size
    ViewPropertyAnimator.animate(animatedHero).
            scaleX(1).scaleY(1).
            translationX(0).translationY(0).
            setInterpolator(sDecelerator).
            setListener(new AnimatorListener() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ViewPropertyAnimator.animate(animatedHero).alpha(0);
                    ViewPropertyAnimator.animate(infoContainer).alpha(1);

                    // The back button can be shown
                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                }
            });
    // Animate in the container with the background and text
    ViewPropertyAnimator.animate(container).alpha(1);
}