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

The following examples show how to use com.nineoldandroids.view.ViewHelper#setPivotX() . 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 check out the related API usage on the sidebar.
Example 1
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 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 2
Source File: JazzyViewPager.java    From android-kernel-tweaker with GNU General Public License v3.0 6 votes vote down vote up
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 3
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
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 5
Source File: JazzyViewPager.java    From UltimateAndroid with 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
Source File: JazzyViewPager.java    From school_shop with 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 7
Source File: JazzyViewPager.java    From JazzyViewPager with 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 8
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 6 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()*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 9
Source File: JazzyViewPager.java    From school_shop with 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 10
Source File: CubeTransformer.java    From Social with 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 11
Source File: JazzyViewPager.java    From android-kernel-tweaker with GNU General Public License v3.0 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 12
Source File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 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 13
Source File: JazzyViewPager.java    From ClockView with 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 14
Source File: JazzyViewPager.java    From JazzyViewPager with 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 File: CubeInTransformer.java    From AndroidImageSlider with 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 File: JazzyViewPager.java    From ClockView with 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 File: JazzyViewPager.java    From ClockView with 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 File: JazzyViewPager.java    From ClockView with 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 File: DetailActivity.java    From google-io-2014-compat with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: CurlEffect.java    From MiBandDecompiled with 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);
}