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

The following examples show how to use com.nineoldandroids.view.ViewHelper#setRotation() . 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 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 2
Source File: JazzyViewPager.java    From JazzyViewPager with Apache License 2.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: JazzyViewPager.java    From school_shop 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 4
Source File: JellyViewPager.java    From Conquer with Apache License 2.0 6 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {
	ensureCorrectView();
	float value = (float) spring.getCurrentValue();
	String springId = spring.getId();
	if (springId.equals(tranSpring.getId())) {
		ViewHelper.setTranslationY(currentView, value);
		if (spring.isAtRest()) {
			if (value >= mHeight) {
				nextPage();
			} else if (value <= -mHeight) {
				prePage();
			}
		}
	} else if (springId.equals(mScaleSpring.getId())) {
		ViewHelper.setScaleX(currentView, value);
		ViewHelper.setScaleY(currentView, value);
	} else if (springId.equals(rotateSpring.getId())) {
		ViewHelper.setRotation(currentView, value);
	}
}
 
Example 5
Source File: LockFooterView.java    From PullRefreshView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onScroll(float y) {
    boolean intercept = super.onScroll(y);
    ViewHelper.setTranslationY(loadBox, 400 + 0.97f * y);
    if (!isLockState()) {
        ViewHelper.setRotation(progress, y * y * 48 / 31250);
    }
    path.reset();// 重置path
    if (y == 0) {
        invalidate();
        return intercept;
    }
    // 贝赛尔曲线的起始点
    path.moveTo(0, 400);
    // 设置贝赛尔曲线的操作点以及终止点
    path.quadTo(width / 2, 400 + 1.94f * y, width, 400);
    invalidate();
    return intercept;
}
 
Example 6
Source File: Util.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public static void reset(View target) {
    ViewHelper.setAlpha(target, 1);
    ViewHelper.setScaleX(target, 1);
    ViewHelper.setScaleY(target, 1);
    ViewHelper.setTranslationX(target, 0);
    ViewHelper.setTranslationY(target, 0);
    ViewHelper.setRotation(target, 0);
    ViewHelper.setRotationY(target, 0);
    ViewHelper.setRotationX(target, 0);
    ViewHelper.setPivotX(target, target.getMeasuredWidth() / 2.0f);
    ViewHelper.setPivotY(target, target.getMeasuredHeight() / 2.0f);
}
 
Example 7
Source File: TwirlEffect.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void initView(View view, int i, int j)
{
    ViewHelper.setPivotX(view, view.getWidth() / 2);
    ViewHelper.setPivotY(view, view.getWidth() / 2);
    ViewHelper.setRotationX(view, 80F);
    ViewHelper.setRotationY(view, j * 70);
    ViewHelper.setRotation(view, 10F);
}
 
Example 8
Source File: LoadingView.java    From android-shapeLoadingView with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    ViewHelper.setRotation(mShapeLoadingView, 180f);
    ViewHelper.setTranslationY(mShapeLoadingView, 0f);
    ViewHelper.setScaleX(mIndicationIm, 0.2f);
    mStopped = false;
    freeFall();
}
 
Example 9
Source File: CubeInTransformer.java    From UltimateAndroid with Apache License 2.0 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 10
Source File: RotateUpTransformer.java    From FlycoBanner_Master with MIT License 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {
	final float width = page.getWidth();
	final float rotation = ROT_MOD * position;

	ViewHelper.setPivotX(page,width * 0.5f);
       ViewHelper.setPivotY(page,0f);
       ViewHelper.setTranslationX(page,0f);
       ViewHelper.setRotation(page,rotation);
}
 
Example 11
Source File: JellyViewPager.java    From Conquer with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
	if (pageChangeListener != null) {
		pageChangeListener.onPageSelected(position);
	}
	if (currentView != null) {
		ViewHelper.setTranslationY(currentView, 0);
		ViewHelper.setRotation(currentView, 0);
	}
	mScaleSpring.setCurrentValue(MIN_SCALE);
	mScaleSpring.setEndValue(MAX_SCALE);
}
 
Example 12
Source File: JazzyViewPager.java    From ClockView with Apache License 2.0 5 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 13
Source File: RotateUpTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float rotation = ROT_MOD * position;

	ViewHelper.setPivotX(view,width * 0.5f);
       ViewHelper.setPivotY(view,0f);
       ViewHelper.setTranslationX(view,0f);
       ViewHelper.setRotation(view,rotation);
}
 
Example 14
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 15
Source File: RotateTransformer.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View view, float position) {
	if (position < -1) {
	} else if (position <= 0) {
		ViewHelper.setScaleX(view, 1 + position);
		ViewHelper.setScaleY(view, 1 + position);
		ViewHelper.setRotation(view, 360 * position);
	} else if (position <= 1) {
		ViewHelper.setScaleX(view, 1 - position);
		ViewHelper.setScaleY(view, 1 - position);
		ViewHelper.setRotation(view, 360 * position);
	} else {
	}
}
 
Example 16
Source File: RotateAnimater.java    From JPTabBar with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageAnimate(View v, float offset) {
    ViewHelper.setRotation(v, offset * 360);
}
 
Example 17
Source File: BaseTransformer.java    From AndroidImageSlider with MIT License 4 votes vote down vote up
/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(h.containsKey(view) == false || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}
 
Example 18
Source File: BaseTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 4 votes vote down vote up
/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(h.containsKey(view) == false || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}
 
Example 19
Source File: FanEffect.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, 0.0F);
    ViewHelper.setRotation(view, j * 70);
}
 
Example 20
Source File: BaseTransformer.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(h.containsKey(view) == false || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}