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

The following examples show how to use com.nineoldandroids.view.ViewHelper#getX() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: XERUNG   File: Switch.java    License: 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 2
Source Project: XERUNG   File: Slider.java    License: 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 3
Source Project: XERUNG   File: Switch.java    License: 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 4
Source Project: XERUNG   File: Slider.java    License: 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 Project: DMAudioStreamer   File: Slider.java    License: 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 6
Source Project: Social   File: Switch.java    License: 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 7
Source Project: MaterialCalendar   File: MemoFragment.java    License: 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 8
Source Project: MoeGallery   File: Switch.java    License: 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 9
Source Project: MoeGallery   File: Slider.java    License: 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 10
Source Project: meiShi   File: Switch.java    License: 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 11
Source Project: meiShi   File: Slider.java    License: 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 12
Source Project: MaterialDesignLibrary   File: Switch.java    License: 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 13
Source Project: MaterialDesignLibrary   File: Slider.java    License: 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
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 15
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 16
/**
 * 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 17
Source Project: MaterialCalendar   File: MemoFragment.java    License: Apache License 2.0 4 votes vote down vote up
public static float centerX(View view) {
    return ViewHelper.getX(view) + view.getWidth() / 2;
}
 
Example 18
Source Project: MousePaint   File: Utils.java    License: MIT License 4 votes vote down vote up
public static float centerX(View view){
    return ViewHelper.getX(view) + view.getWidth()/2;
}
 
Example 19
Source Project: PhoneTutorial   File: TutorialActivity.java    License: 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;
}