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

The following examples show how to use com.nineoldandroids.view.ViewHelper#getX() . 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: Switch.java    From MoeGallery with GNU General Public License v3.0 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 2
Source File: SwipeableLayout.java    From SwipeableLayout with GNU General Public License v2.0 5 votes vote down vote up
public void close(boolean animate) {
    int time = animate ? 300 : 0;

    int height = (getLayoutParams().height < 0) ? mFrontNaturalHeight : getLayoutParams().height;

    float x = ViewHelper.getX(mFrontContainer);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
        ObjectAnimator.ofFloat(mFrontContainer, "x", x, 0f),
        getHeightAnimator(height, mFrontNaturalHeight)
    );
    set.setDuration(time);
    set.setInterpolator(new SlamInterpolator());
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator aAnimator) {
            mIsAnimating = false;
            mIsOpen = false;
            updateOpenState();

            resetForContainer(mBackContainer, mBackChild);
            mBackContainer.setVisibility(View.GONE);
            if (mTabChild != null) {
                mTabChild.setVisibility(View.VISIBLE);
            }
            resetForContainer(mFrontContainer, mFrontChild);
            getLayoutParams().height = LayoutParams.WRAP_CONTENT;
        }
    });
    set.start();
}
 
Example 3
Source File: SwipeableLayout.java    From SwipeableLayout with GNU General Public License v2.0 5 votes vote down vote up
public void open(boolean animate) {
    mBackContainer.setVisibility(View.VISIBLE);

    int time = animate ? 300 : 0;

    float x = ViewHelper.getX(mFrontContainer);
    float margin = mPeekSize - mWidth;
    if (mDirection == Direction.RIGHT) {
        margin = -margin;
    }
    int height = (getLayoutParams().height < 0) ? mBackNaturalHeight : getLayoutParams().height;
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
        ObjectAnimator.ofFloat(mFrontContainer, "x", x, margin),
        getHeightAnimator(height, mBackNaturalHeight)
    );
    set.setDuration(time);
    set.setInterpolator(new OvershootInterpolator());
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator aAnimator) {
            mIsAnimating = false;
            mIsOpen = true;
            updateOpenState();
            getLayoutParams().height = LayoutParams.WRAP_CONTENT;
            resetForContainer(mBackContainer, mBackChild);
        }
    });
    set.start();
}
 
Example 4
Source File: Slider.java    From MaterialDesignLibrary with Apache License 2.0 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 5
Source File: Switch.java    From MaterialDesignLibrary with Apache License 2.0 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 6
Source File: Slider.java    From meiShi with Apache License 2.0 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 7
Source File: Switch.java    From meiShi with Apache License 2.0 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 8
Source File: Slider.java    From MoeGallery with GNU General Public License v3.0 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 9
Source File: Switch.java    From XERUNG with Apache License 2.0 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 10
Source File: MemoFragment.java    From MaterialCalendar with Apache License 2.0 5 votes vote down vote up
void upRed() {
    startRedX = ViewHelper.getX(mRed);
    startRedY = ViewHelper.getY(mRed);
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mRed, "y", ViewHelper.getY(mRed),
            mBluePair.getBottom() - mRed.getHeight() / 2);
    objectAnimator.addListener(new SimpleListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            disappearRed();
        }
    });
    objectAnimator.setDuration(650);
    objectAnimator.setInterpolator(ACCELERATE_DECELERATE);
    objectAnimator.start();
}
 
Example 11
Source File: Switch.java    From Social with Apache License 2.0 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 12
Source File: Slider.java    From DMAudioStreamer with Apache License 2.0 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 13
Source File: Slider.java    From XERUNG with Apache License 2.0 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 14
Source File: Switch.java    From XERUNG with Apache License 2.0 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 15
Source File: Slider.java    From XERUNG with Apache License 2.0 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 16
Source File: MemoFragment.java    From MaterialCalendar with Apache License 2.0 4 votes vote down vote up
public static float centerX(View view) {
    return ViewHelper.getX(view) + view.getWidth() / 2;
}
 
Example 17
Source File: Utils.java    From MousePaint with MIT License 4 votes vote down vote up
public static float centerX(View view){
    return ViewHelper.getX(view) + view.getWidth()/2;
}
 
Example 18
Source File: SwipeListViewTouchListener.java    From browser with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Moves the view
 *
 * @param deltaX delta
 */
public void move(float deltaX) {
    swipeListView.onMove(downPosition, deltaX);
    float posX = ViewHelper.getX(frontView);
    if (opened.get(downPosition)) {
        posX += openedRight.get(downPosition) ? -viewWidth + rightOffset : viewWidth - leftOffset;
    }
    if (posX > 0 && !swipingRight) {
        Log.d("SwipeListView", "change to right");
        swipingRight = !swipingRight;
        swipeCurrentAction = swipeActionRight;
        if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_CHOICE) {
            backView.setVisibility(View.GONE);
        } else {
            backView.setVisibility(View.VISIBLE);
        }
    }
    if (posX < 0 && swipingRight) {
        Log.d("SwipeListView", "change to left");
        swipingRight = !swipingRight;
        swipeCurrentAction = swipeActionLeft;
        if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_CHOICE) {
            backView.setVisibility(View.GONE);
        } else {
            backView.setVisibility(View.VISIBLE);
        }
    }
    if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_DISMISS) {
        setTranslationX(parentView, deltaX);
        setAlpha(parentView, Math.max(0f, Math.min(1f,
                1f - 2f * Math.abs(deltaX) / viewWidth)));
    } else if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_CHOICE) {
        if ((swipingRight && deltaX > 0 && posX < DISPLACE_CHOICE)
                || (!swipingRight && deltaX < 0 && posX > -DISPLACE_CHOICE)
                || (swipingRight && deltaX < DISPLACE_CHOICE)
                || (!swipingRight && deltaX > -DISPLACE_CHOICE)) {
            setTranslationX(frontView, deltaX);
        }
    } else {
        setTranslationX(frontView, deltaX);
    }
}
 
Example 19
Source File: TutorialActivity.java    From PhoneTutorial with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
	if(fromViewPosition == -1){
		fromViewPosition = ViewHelper.getX(imageContainer);
		fromViewTitlePosition = ViewHelper.getX(titleContainer);
	}
	switch (arg1.getAction()) {
	case MotionEvent.ACTION_DOWN:
		fromTouchPosition = arg1.getX();
		break;
	case MotionEvent.ACTION_MOVE:
		newPosition = fromViewPosition-(fromTouchPosition-arg1.getX());
		newPosition = (newPosition>0)? 0 : newPosition;
		newPosition = (newPosition< -width*(images.length-1))? -width*(images.length-1) : newPosition;
		ViewHelper.setX(imageContainer,newPosition);
		ViewHelper.setX(titleContainer,fromViewTitlePosition+(newPosition-fromViewPosition)*(widthTitle/width));
		
		break;
	case MotionEvent.ACTION_UP:
		if(newPosition<=(fromViewPosition-width/3)){
			setSmallBackground(positionIndicator.getChildAt(position));
			position++;
			animate();
			fromViewPosition = -position * width;
			fromViewTitlePosition = -position * widthTitle;
			setBigBackground(positionIndicator.getChildAt(position));
		}else if(newPosition>=(fromViewPosition+width/3)){
			setSmallBackground(positionIndicator.getChildAt(position));
			position--;
			animate();
			fromViewPosition = -position * width;
			fromViewTitlePosition = -position * widthTitle;
			setBigBackground(positionIndicator.getChildAt(position));
		}else{
			animate();
			fromViewPosition = -position * width;
			fromViewTitlePosition = -position * widthTitle;
		}
		
		if(position == images.length-1 && !nextButton.isShow)
			nextButton.show();
		else if(nextButton.isShow && position != images.length-1)
			nextButton.hide();
		
		break;

	}
	return true;
}