Java Code Examples for com.nineoldandroids.view.ViewHelper

The following are top voted examples for showing how to use com.nineoldandroids.view.ViewHelper. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: Instrument.java   Source Code and License 6 votes vote down vote up
public void slidingToY(View view ,float y){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setY(y);
    }else{
        ViewHelper.setY(view, y);
    }
}
 
Example 2
Project: OpenEyesReading-android   File: RotateDownPage.java   Source Code and License 6 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    if (position < -1) {
        ViewHelper.setRotation(page, 0);
    } else if (position <= 1) {
        if (position < 0) {
            mRot = (ROT_MAX * position);
            ViewHelper.setPivotX(page, page.getMeasuredWidth() * 0.5f);
            ViewHelper.setPivotY(page, page.getMeasuredHeight());
            ViewHelper.setRotation(page, mRot);
        } else {
            mRot = (ROT_MAX * position);
            ViewHelper.setPivotX(page, page.getMeasuredWidth() * 0.5f);
            ViewHelper.setPivotY(page, page.getMeasuredHeight());
            ViewHelper.setRotation(page, mRot);
        }
    } else {
        ViewHelper.setRotation(page, 0);
    }
}
 
Example 3
Project: GitHub   File: SlideLayout.java   Source Code and License 6 votes vote down vote up
@Override
	public void computeScroll() {
		if (mScroller.computeScrollOffset()) {
			scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
			scrollX=mScroller.getCurrX();
//			这里是判断打开菜单时即向右滑动菜单向右滑动 实现视觉差滑动效果,scrollX就是监听startScroll开始滚动程X的值,因为getScrollX()只是监听手在屏幕上滑动的过程,手离开后就要在这里监听,0.7是可以根据需求改动
			if(scrollX<oldX){
//			Log.d("gaolei", "scrollX2--------------------------------|"+scrollX);
			ViewHelper.setTranslationX(getChildAt(0), (menuWidth+scrollX)* 0.7f);
			}
//			这里是判断点击菜单按钮关闭时,对菜单做处理,已达到视觉差效果,不然的话没有
			if(clickMenuToClose){
				ViewHelper.setTranslationX(getChildAt(0), (menuWidth+scrollX)* 0.7f);
			}
			oldX=scrollX;
			postInvalidate();
			
		}
	}
 
Example 4
Project: GitHub   File: SlidingMenu.java   Source Code and License 6 votes vote down vote up
@Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        float scale = l * 1.0f / mMenuWidth;
        float leftScale = 1 - 0.3f * scale;
        float rightScale = 0.8f + scale * 0.2f;

//		ViewHelper.setScaleX(mMenu, leftScale);
//		ViewHelper.setScaleY(mMenu, leftScale);
//		ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale));
//		Log.d("gaolei","mMenuWidth----------------"+mMenuWidth);
//		Log.d("gaolei","l---------------"+l);
//		Log.d("gaolei","scale----------------"+l * 1.0f / mMenuWidth);
//		Log.d("gaolei"," mMenuWidth * scale * 0.7f----------------"+ mMenuWidth * scale * 0.7f);
        ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.7f);

//		ViewHelper.setPivotX(mContent, 0);
//		ViewHelper.setPivotY(mContent, mContent.getHeight() / 2);
//		ViewHelper.setScaleX(mContent, rightScale);
//		ViewHelper.setScaleY(mContent, rightScale);

    }
 
Example 5
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and 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 6
Project: DMAudioStreamer   File: Slider.java   Source Code and License 6 votes vote down vote up
public void setValue(final int value) {
    if (placedBall == false)
        post(new Runnable() {

            @Override
            public void run() {
                setValue(value);
            }
        });
    else {
        this.value = value;
        float division = (ball.xFin - ball.xIni) / max;
        ViewHelper.setX(ball, value * division + getHeight() / 2 - ball.getWidth() / 2);
        ball.changeBackground();
    }

}
 
Example 7
Project: DMAudioStreamer   File: Slider.java   Source Code and License 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (!placedBall) {
        placeBall();
    }

    Paint paint = new Paint();
    paint.setColor(backgroundColorLine);
    paint.setStrokeWidth(dpToPx(3, getResources()));
    canvas.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint);
    paint.setColor(backgroundColor);
    float division = (ball.xFin - ball.xIni) / (max - min);
    int value = this.value - min;
    canvas.drawLine(getHeight() / 2, getHeight() / 2, value * division + getHeight() / 2, getHeight() / 2, paint);

    if (press) {
        paint.setColor(backgroundColor);
        paint.setAntiAlias(true);
        canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 4, paint);
    }
    invalidate();
}
 
Example 8
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 9
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 10
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 11
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 12
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 13
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License 6 votes vote down vote up
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {		
	if (mState != State.IDLE) {
		if (right != null) {
			manageLayer(right, true);
			mScale = (1-SCALE_MAX) * positionOffset + SCALE_MAX;
			mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
			ViewHelper.setTranslationX(right, mTrans);
		}
		if (left != null) {
			left.bringToFront();
		}
	}
}
 
Example 14
Project: JewelryUI   File: ViewAnimationUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param fromY        initial Y position of view
 * @param duration     aniamtion duration
 * @param startDelay   start delay before animation begin
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, fromY);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .setStartDelay(startDelay)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 15
Project: JewelryUI   File: ViewAnimationUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param duration     aniamtion duration
 * @param startDelay   start delay before animation begin
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, view.getHeight() / 3);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .setStartDelay(startDelay)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 16
Project: Sega   File: FadeTransformer.java   Source Code and License 6 votes vote down vote up
@Override
protected void onTransform(View view, float position) {

    // Page is not an immediate sibling, just make transparent
    if(position < -1 || position > 1) {
        ViewHelper.setAlpha(view,0.6f);
    }
    // Page is sibling to left or right
    else if (position <= 0 || position <= 1) {

        // Calculate alpha.  Position is decimal in [-1,0] or [0,1]
        float alpha = (position <= 0) ? position + 1 : 1 - position;
        ViewHelper.setAlpha(view,alpha);

    }
    // Page is active, make fully visible
    else if (position == 0) {
        ViewHelper.setAlpha(view,1);
    }
}
 
Example 17
Project: HutHelper   File: DragLayout.java   Source Code and License 6 votes vote down vote up
private void animateView(float percent) {
    float f1 = 1 - percent * 0.3f;
    ViewHelper.setScaleX(vg_main, f1);   //主布局逐渐变大
    ViewHelper.setScaleY(vg_main, f1);
    ViewHelper.setTranslationX(vg_left, -vg_left.getWidth() / 2.3f
            + vg_left.getWidth() / 2.3f * percent);
    ViewHelper.setScaleX(vg_left, 0.5f + 0.5f * percent);//左边的布局逐渐变小
    ViewHelper.setScaleY(vg_left, 0.5f + 0.5f * percent);
    ViewHelper.setAlpha(vg_left, percent);
    if (isShowShadow) {
        ViewHelper.setScaleX(iv_shadow, f1 * 1.4f * (1 - percent * 0.12f));
        ViewHelper.setScaleY(iv_shadow, f1 * 1.85f * (1 - percent * 0.12f));
    }
    getBackground().setColorFilter(
            evaluate(percent, Color.BLACK, Color.TRANSPARENT),
            Mode.SRC_OVER);
}
 
Example 18
Project: NeteaseCloudMusic   File: ScanMusicActivity.java   Source Code and License 6 votes vote down vote up
private void initAnimations() {
    searchAnimation = ValueAnimator.ofFloat(0f, 1f);
    searchAnimation.setDuration(50000);
    searchAnimation.setRepeatCount(ValueAnimator.INFINITE);
    searchAnimation.setRepeatMode(ValueAnimator.RESTART);
    searchAnimation.setInterpolator(new LinearInterpolator());
    searchAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float angle = (valueAnimator.getAnimatedFraction() * 360);
            ViewHelper.setTranslationX(ivSearch, (float) Math.sin(angle) * radius);
            ViewHelper.setTranslationY(ivSearch, (float) Math.cos(angle) * radius);
        }
    });


    scanAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.61f);
    scanAnimation.setDuration(2000);
    scanAnimation.setRepeatCount(TranslateAnimation.INFINITE);
    scanAnimation.setRepeatMode(TranslateAnimation.RESTART);
}
 
Example 19
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and 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 20
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and 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 21
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and 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 22
Project: ClouldReader   File: Instrument.java   Source Code and License 5 votes vote down vote up
public float getTranslationY(View view){
    if(view == null){
        return 0;
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        return view.getTranslationY();
    }else{
        return ViewHelper.getTranslationY(view);
    }
}
 
Example 23
Project: ClouldReader   File: Instrument.java   Source Code and License 5 votes vote down vote up
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
        ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 24
Project: ClouldReader   File: Instrument.java   Source Code and License 5 votes vote down vote up
public void slidingToY(View view ,float y){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setY(y);
    }else{
        ViewHelper.setY(view, y);
    }
}
 
Example 25
Project: GitHub   File: Instrument.java   Source Code and License 5 votes vote down vote up
public float getTranslationY(View view){
    if(view == null){
        return 0;
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        return view.getTranslationY();
    }else{
        return ViewHelper.getTranslationY(view);
    }
}
 
Example 26
Project: GitHub   File: Instrument.java   Source Code and License 5 votes vote down vote up
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
        ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 27
Project: pius1   File: SlideBottomPanel.java   Source Code and License 5 votes vote down vote up
private void handleActionUp(MotionEvent event) {
    if (!isPanelOnTouch) {
        return;
    }
    long pressDuration = System.currentTimeMillis() - mPressStartTime;
    computeVelocity();
    if (!isPanelShowing && ((event.getY() - firstDownY) < 0 && (Math.abs(event.getY() - firstDownY) > mMoveDistanceToTrigger))
                || (yVelocity < 0 && Math.abs(yVelocity) > Math.abs(xVelocity) && Math.abs(yVelocity) > mMinVelocity)) {
        displayPanel();
    } else if (!isPanelShowing && pressDuration < MAX_CLICK_TIME &&
            distance(firstDownX, firstDownY, event.getX(), event.getY()) < MAX_CLICK_DISTANCE) {
        displayPanel();
    } else if (!isPanelShowing && isDragging && ((event.getY() - firstDownY > 0) ||
            Math.abs(event.getY() - firstDownY) < mMoveDistanceToTrigger)){
        hidePanel();
    }

    if (isPanelShowing) {
        View mPanel = findViewWithTag(TAG_PANEL);
        float currentY = ViewHelper.getY(mPanel);
        if (currentY < (mMeasureHeight - mPanelHeight) ||
                currentY < (mMeasureHeight - mPanelHeight + mMoveDistanceToTrigger)) {
            ObjectAnimator.ofFloat(mPanel, "y", currentY, mMeasureHeight - mPanelHeight)
                    .setDuration(mAnimationDuration).start();
        } else if (currentY > mMeasureHeight - mPanelHeight + mMoveDistanceToTrigger){
            hidePanel();
        }
    }

    isPanelOnTouch = false;
    isDragging = false;
    deltaY = 0;
}
 
Example 28
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and License 5 votes vote down vote up
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {		
	if (mState != State.IDLE) {
		if (right != null) {
			manageLayer(right, true);
			mScale = (1-SCALE_MAX) * positionOffset + SCALE_MAX;
			mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
			ViewHelper.setTranslationX(right, mTrans);
		}
		if (left != null) {
			left.bringToFront();
		}
	}
}
 
Example 29
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	if (isEnabled()) {
		isLastTouch = true;
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			press = true;
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			requestDisallowInterceptTouchEvent(true);
			float x = event.getX();
			x = (x < ball.xIni) ? ball.xIni : x;
			x = (x > ball.xFin) ? ball.xFin : x;
			if (x > ball.xCen) {
				iSchecked = true;
			} else {
				iSchecked = false;
			}
			ViewHelper.setX(ball, x);
			ball.changeBackground();
			if (event.getX() <= getWidth() && event.getX() >= 0) {
				isLastTouch = false;
				press = false;
			}
		} else if (event.getAction() == MotionEvent.ACTION_UP 
				|| event.getAction() == MotionEvent.ACTION_CANCEL) {
			requestDisallowInterceptTouchEvent(false);
			press = false;
			isLastTouch = false;
			if (eventCheck != iSchecked) {
				eventCheck = iSchecked;
				if (onCheckListener != null)
					onCheckListener.onCheck(iSchecked);
			}
			if (event.getX() <= getWidth() && event.getX() >= 0) {
				ball.animateCheck();
			} 
		}
	}
	return true;
}
 
Example 30
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	if (!placedBall)
		placeBall();

	// Crop line to transparent effect
	Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(),
			canvas.getHeight(), Bitmap.Config.ARGB_8888);
	Canvas temp = new Canvas(bitmap);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor((iSchecked) ? backgroundColor : Color.parseColor("#B0B0B0"));
	paint.setStrokeWidth(Utils.dpToPx(2, getResources()));
	temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint);
	Paint transparentPaint = new Paint();
	transparentPaint.setAntiAlias(true);
	transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
	transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
	temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,
			ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint);
	canvas.drawBitmap(bitmap, 0, 0, new Paint());

	if (press) {
		paint.setColor((iSchecked) ? makePressColor(70) : Color.parseColor("#446D6D6D"));
		canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 2, paint);
	}
	invalidate();
}
 
Example 31
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
private void placeBall() {
	ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
	ball.xIni = ViewHelper.getX(ball);
	ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
	ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
	placedBall = true;
	ball.animateCheck();
}
 
Example 32
Project: XERUNG   File: Slider.java   Source Code and License 5 votes vote down vote up
private void placeBall() {
	ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
	ball.xIni = ViewHelper.getX(ball);
	ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
	ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
	placedBall = true;
}
 
Example 33
Project: XERUNG   File: Slider.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);

	if (numberIndicatorResize == false) {
		RelativeLayout.LayoutParams params = (LayoutParams) numberIndicator.
				numberIndicator.getLayoutParams();
		params.height = (int) finalSize * 2;
		params.width = (int) finalSize * 2;
		numberIndicator.numberIndicator.setLayoutParams(params);
	}

	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor(backgroundColor);
	if (animate) {
		if (y == 0)
			y = finalY + finalSize * 2;
		y -= Utils.dpToPx(6, getResources());
		size += Utils.dpToPx(2, getResources());
	}
	canvas.drawCircle(
			ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent())
					+ ball.getWidth() / 2, y, size, paint);
	if (animate && size >= finalSize)
		animate = false;
	if (animate == false) {
		ViewHelper.setX(numberIndicator.numberIndicator, 
				(ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2) - size);
		ViewHelper.setY(numberIndicator.numberIndicator, y - size);
		numberIndicator.numberIndicator.setText(value + "");
	}
	invalidate();
}
 
Example 34
Project: XERUNG   File: ButtonFloat.java   Source Code and License 5 votes vote down vote up
/**
 * float的动画 
 */
private void playAnimation() {
	post(new Runnable() {
		@Override
		public void run() {
			float originalY = ViewHelper.getY(ButtonFloat.this) - Utils.dpToPx(24, getResources());
			ViewHelper.setY(ButtonFloat.this, 
					ViewHelper.getY(ButtonFloat.this) + getHeight() * 3);
			ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", originalY);
			animator.setInterpolator(new BounceInterpolator());
			animator.setDuration(1500);// 动画持续时间
			animator.start();
		}
	});
}
 
Example 35
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	if (isEnabled()) {
		isLastTouch = true;
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			press = true;
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			requestDisallowInterceptTouchEvent(true);
			float x = event.getX();
			x = (x < ball.xIni) ? ball.xIni : x;
			x = (x > ball.xFin) ? ball.xFin : x;
			if (x > ball.xCen) {
				iSchecked = true;
			} else {
				iSchecked = false;
			}
			ViewHelper.setX(ball, x);
			ball.changeBackground();
			if (event.getX() <= getWidth() && event.getX() >= 0) {
				isLastTouch = false;
				press = false;
			}
		} else if (event.getAction() == MotionEvent.ACTION_UP 
				|| event.getAction() == MotionEvent.ACTION_CANCEL) {
			requestDisallowInterceptTouchEvent(false);
			press = false;
			isLastTouch = false;
			if (eventCheck != iSchecked) {
				eventCheck = iSchecked;
				if (onCheckListener != null)
					onCheckListener.onCheck(iSchecked);
			}
			if (event.getX() <= getWidth() && event.getX() >= 0) {
				ball.animateCheck();
			} 
		}
	}
	return true;
}
 
Example 36
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	if (!placedBall)
		placeBall();

	// Crop line to transparent effect
	Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(),
			canvas.getHeight(), Bitmap.Config.ARGB_8888);
	Canvas temp = new Canvas(bitmap);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor((iSchecked) ? backgroundColor : Color.parseColor("#B0B0B0"));
	paint.setStrokeWidth(Utils.dpToPx(2, getResources()));
	temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint);
	Paint transparentPaint = new Paint();
	transparentPaint.setAntiAlias(true);
	transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
	transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
	temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,
			ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint);
	canvas.drawBitmap(bitmap, 0, 0, new Paint());

	if (press) {
		paint.setColor((iSchecked) ? makePressColor(70) : Color.parseColor("#446D6D6D"));
		canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 2, paint);
	}
	invalidate();
}
 
Example 37
Project: XERUNG   File: Switch.java   Source Code and License 5 votes vote down vote up
private void placeBall() {
	ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
	ball.xIni = ViewHelper.getX(ball);
	ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
	ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
	placedBall = true;
	ball.animateCheck();
}
 
Example 38
Project: XERUNG   File: Slider.java   Source Code and License 5 votes vote down vote up
private void placeBall() {
	ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
	ball.xIni = ViewHelper.getX(ball);
	ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
	ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
	placedBall = true;
}
 
Example 39
Project: XERUNG   File: Slider.java   Source Code and License 5 votes vote down vote up
private void setValueInRunnable(final int value,final boolean inRunnable) {
	if(placedBall == false && inRunnable == true)
		post(new Runnable() {
			@Override
			public void run() {
				setValue(value,inRunnable);
			}
		});
	else{
		this.value = value;
		float division = (ball.xFin - ball.xIni) / max;
		ViewHelper.setX(ball,value*division + getHeight()/2 - ball.getWidth()/2);
		ball.changeBackground();
	}
}
 
Example 40
Project: XERUNG   File: Slider.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);

	if (numberIndicatorResize == false) {
		RelativeLayout.LayoutParams params = (LayoutParams) numberIndicator.
				numberIndicator.getLayoutParams();
		params.height = (int) finalSize * 2;
		params.width = (int) finalSize * 2;
		numberIndicator.numberIndicator.setLayoutParams(params);
	}

	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor(backgroundColor);
	if (animate) {
		if (y == 0)
			y = finalY + finalSize * 2;
		y -= Utils.dpToPx(6, getResources());
		size += Utils.dpToPx(2, getResources());
	}
	canvas.drawCircle(
			ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent())
					+ ball.getWidth() / 2, y, size, paint);
	if (animate && size >= finalSize)
		animate = false;
	if (animate == false) {
		ViewHelper.setX(numberIndicator.numberIndicator, 
				(ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2) - size);
		ViewHelper.setY(numberIndicator.numberIndicator, y - size);
		numberIndicator.numberIndicator.setText(value + "");
	}
	invalidate();
}
 
Example 41
Project: XERUNG   File: ButtonFloat.java   Source Code and License 5 votes vote down vote up
/**
 * float的动画 
 */
private void playAnimation() {
	post(new Runnable() {
		@Override
		public void run() {
			float originalY = ViewHelper.getY(ButtonFloat.this) - Utils.dpToPx(24, getResources());
			ViewHelper.setY(ButtonFloat.this, 
					ViewHelper.getY(ButtonFloat.this) + getHeight() * 3);
			ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", originalY);
			animator.setInterpolator(new BounceInterpolator());
			animator.setDuration(1500);// 动画持续时间
			animator.start();
		}
	});
}
 
Example 42
Project: TestChat   File: DragLayout.java   Source Code and License 5 votes vote down vote up
/**
                 * 子view拖拽过程中位置改变的回调
                 *
                 * @param changedView 被拖拽的子view
                 * @param left        距离父布局左边的距离
                 * @param top         距离父布局上面的距离
                 * @param dx          x方向的偏移量
                 * @param dy          y方向的偏移量
                 */
                @Override
                public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
                        if (dx == 0) {
                                return;
                        }
                        if (changedView.equals(menu)) {
//                                如果拖拽的是menu,布局不变
                                menu.layout(0, 0, width, height);
//                                content.layout(marginLeft, 0, marginLeft + width, height);
//                                这里如果在屏幕上手指按定,就会出现dx=0,dy=1的情况
                                content.layout(left, 0, left + width, height);
                        }
//                                如果是内容布局,就随拖拽位移而变化,因为在smoothSlideViewTo中会进行控件边缘和内容边缘之间的移动,所以这里content要随时改变布局
//                                content.layout(marginLeft, 0, marginLeft + width, height);
//                        0~~1之间
                        float percent = left / (float) range;
                        float desWidth = (float) (width / 4.0 * (percent - 1));
//                        进行内容移动,本身控件位置不变
                        ViewHelper.setTranslationX(menu, desWidth);
                        if (SHADOW) {
//                                ivShadow.layout(marginLeft, 0, marginLeft + width, height);
                                ivShadow.layout(left, 0, left + width, height);
//                                ivShadow.setAlpha(percent * 225);
//                                ViewHelper.setAlpha(ivShadow, percent * 255);
//                                阴影效果
                                float f1 = 1 - percent * 0.5f;
                                ViewHelper.setScaleX(ivShadow, f1 * 1.2f * (1 - percent * 0.10f));
                                ViewHelper.setScaleY(ivShadow, f1 * 1.85f * (1 - percent * 0.10f));
                        }
                        int dragState = getCurrentState();
                        if (dragState == DRAG_STATE_OPEN) {
                                if (mListener != null) {
                                        mListener.onOpenMenu();
                                }
                        } else if (dragState == DRAG_STATE_CLOSE) {
                                if (mListener != null) {
                                        mListener.onCloseMenu();
                                }
                        } else {
                                if (mListener != null) {
                                        mListener.onDrag(changedView, percent);
                                }
                        }
                }
 
Example 43
Project: TestChat   File: FloatingActionsMenu.java   Source Code and License 5 votes vote down vote up
private void toggle(final boolean visible, final boolean animate, boolean force) {
        if (mVisible != visible || force) {
                mVisible = visible;
                int height = getHeight();
                if (height == 0 && !force) {
                        ViewTreeObserver vto = getViewTreeObserver();
                        if (vto.isAlive()) {
                                vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                                        @Override
                                        public boolean onPreDraw() {
                                                ViewTreeObserver currentVto = getViewTreeObserver();
                                                if (currentVto.isAlive()) {
                                                        currentVto.removeOnPreDrawListener(this);
                                                }
                                                toggle(visible, animate, true);
                                                return true;
                                        }
                                });
                                return;
                        }
                }
                int translationY = visible ? 0 : height + mAddButton.getMarginBottom();
                if (animate) {
                        ViewPropertyAnimator.animate(this).setInterpolator(mInterpolator)
                                .setDuration(TRANSLATE_DURATION_MILLIS)
                                .translationY(translationY);
                } else {
                        ViewHelper.setTranslationY(this, translationY);
                }

                // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
                if (!hasHoneycombApi()) {
                        setClickable(visible);
                }
        }
}
 
Example 44
Project: MenuSet   File: MenuAdapter.java   Source Code and License 5 votes vote down vote up
/**
 * Set starting params to side animations
 */
private void resetSideAnimation(View view) {
    if (!mIsMenuOpen) {
        ViewHelper.setRotation(view, 0);
        ViewHelper.setRotationY(view, -90);
        ViewHelper.setRotationX(view, 0);
    }
    ViewHelper.setPivotX(view, mMenuItemSize);
    ViewHelper.setPivotY(view, mMenuItemSize / 2);
}
 
Example 45
Project: TestChat   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
    public void onCloseMenu() {
//                当侧滑完全关闭的时候调用
        if (ViewHelper.getAlpha(bg) != 0) {
            ViewHelper.setAlpha(bg, 0);
        }
        if (ViewHelper.getAlpha(icon_1) != 1) {
            ViewHelper.setAlpha(icon_1, 1);
        }
    }
 
Example 46
Project: TestChat   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onOpenMenu() {
    if (ViewHelper.getAlpha(bg) != 1) {
        ViewHelper.setAlpha(bg, 1);
    }
    if (ViewHelper.getAlpha(icon_1) != 0) {
        ViewHelper.setAlpha(icon_1, 0);
    }
    //                当侧滑完全打开的时候调用
}
 
Example 47
Project: Hitalk   File: FloatingActionButton.java   Source Code and License 5 votes vote down vote up
private void toggle(final boolean visible, final boolean animate, boolean force) {
    if (mVisible != visible || force) {
        mVisible = visible;
        int height = getHeight();
        if (height == 0 && !force) {
            ViewTreeObserver vto = getViewTreeObserver();
            if (vto.isAlive()) {
                vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                    @Override
                    public boolean onPreDraw() {
                        ViewTreeObserver currentVto = getViewTreeObserver();
                        if (currentVto.isAlive()) {
                            currentVto.removeOnPreDrawListener(this);
                        }
                        toggle(visible, animate, true);
                        return true;
                    }
                });
                return;
            }
        }
        int translationY = visible ? 0 : height + getMarginBottom();
        if (animate) {
            ViewPropertyAnimator.animate(this).setInterpolator(mInterpolator)
                    .setDuration(TRANSLATE_DURATION_MILLIS)
                    .translationY(translationY);
        } else {
            ViewHelper.setTranslationY(this, translationY);
        }

        // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
        if (!hasHoneycombApi()) {
            setClickable(visible);
        }
    }
}
 
Example 48
Project: Views   File: CoverFlowView.java   Source Code and License 5 votes vote down vote up
private static void getViewRect(View v, Rect rect) {
//        rect.left = (int) (v.getLeft() + v.getTranslationX());
//        rect.top = (int) (v.getTop() + v.getTranslationY());
//        rect.right = rect.left + v.getWidth();
//        rect.bottom = rect.top + v.getHeight();
        rect.left = (int) com.nineoldandroids.view.ViewHelper.getX(v);
        rect.top = (int) com.nineoldandroids.view.ViewHelper.getY(v);
        rect.right = rect.left + v.getWidth();
        rect.bottom = rect.top + v.getHeight();
    }
 
Example 49
Project: Shared-Route   File: BaseAnimatorSet.java   Source Code and License 5 votes vote down vote up
public static void reset(View view) {
	ViewHelper.setAlpha(view, 1);
	ViewHelper.setScaleX(view, 1);
	ViewHelper.setScaleY(view, 1);
	ViewHelper.setTranslationX(view, 0);
	ViewHelper.setTranslationY(view, 0);
	ViewHelper.setRotation(view, 0);
	ViewHelper.setRotationY(view, 0);
	ViewHelper.setRotationX(view, 0);
}
 
Example 50
Project: DMAudioStreamer   File: Slider.java   Source Code and License 5 votes vote down vote up
private void placeBall() {
    ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
    ball.xIni = ViewHelper.getX(ball);
    ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
    ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
    placedBall = true;
}
 
Example 51
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License 5 votes vote down vote up
private void logState(View v, String title) {
	Log.v(TAG, title + ": ROT (" + ViewHelper.getRotation(v) + ", " +
			ViewHelper.getRotationX(v) + ", " +
			ViewHelper.getRotationY(v) + "), TRANS (" +
			ViewHelper.getTranslationX(v) + ", " +
			ViewHelper.getTranslationY(v) + "), SCALE (" +
			ViewHelper.getScaleX(v) + ", " + 
			ViewHelper.getScaleY(v) + "), ALPHA " +
			ViewHelper.getAlpha(v));
}
 
Example 52
Project: JewelryUI   File: JazzyViewPager.java   Source Code and 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 53
Project: androidgithub   File: PTSlidingMenu.java   Source Code and License 5 votes vote down vote up
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);
    float scale = l * 1.0f / mMenuWidth;

    ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale));
    ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.7f);

}
 
Example 54
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License 5 votes vote down vote up
private void animateFlipVertical(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.setRotationX(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.setRotationX(right, mRot);
			}
		}
	}
}
 
Example 55
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License 5 votes vote down vote up
protected void animateFade(View left, View right, float positionOffset) {
		//Log.e(TAG, "positionOffset: " + String.valueOf(positionOffset));
//		if (left != null) {
//			ViewHelper.setAlpha(left, 1-positionOffset);
//		}
		if (right != null) {
			ViewHelper.setAlpha(right, positionOffset);
		}
	}
 
Example 56
Project: JewelryUI   File: ViewAnimationUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param duration     aniamtion duration
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, int duration) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, view.getHeight() / 3);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 57
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and License 5 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 58
Project: Widgets   File: SlideLayout.java   Source Code and License 5 votes vote down vote up
/**
     * 伴随动画
     *
     * @return 当前滑动的比例
     */
    private float animViews() {
        float percent = mSlideDx * 1.0f / mSlideRang;

        // 左面板: 缩放动画, 平移动画, 透明度动画
//        ViewHelper.setScaleX(mLeftView, 0.4f + 0.4f * percent);
//        ViewHelper.setScaleY(mLeftView, 0.4f + 0.4f * percent);
        ViewHelper.setScaleX(mLeftView, evaluate(percent, 0.4f, 1.0f));
        ViewHelper.setScaleY(mLeftView, evaluate(percent, 0.4f, 1.0f));
        // 平移动画: -mWidth / 2.0f -> 0.0f
        ViewHelper.setTranslationX(mLeftView, evaluate(percent, -mWidth / 2.0f, 0));
        // 透明度: 0.4 -> 1.0f
        ViewHelper.setAlpha(mLeftView, evaluate(percent, 0.4f, 1.0f));

        // 主面板: 缩放动画  1.0f -> 0.8f
        ViewHelper.setScaleX(mMainView, evaluate(percent, 1.0f, 0.8f));
        ViewHelper.setScaleY(mMainView, evaluate(percent, 1.0f, 0.8f));

        // 透明度: 1.0 -> 0.6f
        if (mMainAlphaEnable) {
            ViewHelper.setAlpha(mMainView, evaluate(percent, 1.0f, 0.6f));
        }

        // 整个控件的背景动画: 亮度变化 (颜色变化)
        if (null != getBackground()) {
            getBackground().setColorFilter((Integer) evaluateColor(percent, mAlphaColor, Color.TRANSPARENT), PorterDuff.Mode.SRC_OVER);
        }

        return percent;
    }
 
Example 59
Project: Sega   File: DescriptionAnimation.java   Source Code and License 5 votes vote down vote up
/**
 * When next item show in ViewPagerEx, let's make an animation to show the
 * description layout.
 * @param view
 */
@Override
public void onNextItemAppear(View view) {

    View descriptionLayout = view.findViewById(R.id.description_layout);
    if(descriptionLayout!=null){
        float layoutY = ViewHelper.getY(descriptionLayout);
        view.findViewById(R.id.description_layout).setVisibility(View.VISIBLE);
        ValueAnimator animator = ObjectAnimator.ofFloat(
                descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
                layoutY).setDuration(500);
        animator.start();
    }

}
 
Example 60
Project: Sega   File: CubeInTransformer.java   Source Code and 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);
}