Java Code Examples for com.nineoldandroids.view.ViewHelper.getY()

The following are Jave code examples for showing how to use getY() of the com.nineoldandroids.view.ViewHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pius1   File: SlideBottomPanel.java   View Source Code Vote up 5 votes
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 2
Project: Sega   File: DescriptionAnimation.java   View Source Code Vote up 5 votes
/**
 * 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 3
Project: CodeCompilerApp   File: FloatingActionButton.java   View Source Code Vote up 5 votes
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    // Perform the default behavior
    super.onLayout(changed, left, top, right, bottom);

    // Store the FAB button's displayed Y position if we are not already aware of it
    if (mYDisplayed == -1) {

        mYDisplayed = ViewHelper.getY(this);
    }
}
 
Example 4
Project: pius1   File: SlideBottomPanel.java   View Source Code Vote up 4 votes
private void handleActionMove(MotionEvent event) {
    if (!isPanelOnTouch) {
        return;
    }
    if (isPanelShowing && supportScrollInView((int) (firstDownY - event.getY()))) {
        return;
    }
    computeVelocity();
    if (Math.abs(xVelocity) > Math.abs(yVelocity)) {
        return;
    }
    if (!isDragging && Math.abs(event.getY() - firstDownY) > mTouchSlop
            && Math.abs(event.getX() - firstDownX) < mTouchSlop) {
        isDragging = true;
        downY = event.getY();
    }
    if (isDragging) {
        deltaY = event.getY() - downY;
        downY = event.getY();

        View touchingView = findViewWithTag(TAG_PANEL);

        if (mHidePanelTitle && isPanelShowing) {
            hidePanelTitle(touchingView);
        }

        if (mDarkFrameLayout != null && mIsFade) {
            float currentY = ViewHelper.getY(touchingView);
            if (currentY > mMeasureHeight - mPanelHeight &&
                    currentY < mMeasureHeight - mTitleHeightNoDisplay) {
                mDarkFrameLayout.fade(
                        (int) ((1 - currentY / (mMeasureHeight - mTitleHeightNoDisplay)) * DarkFrameLayout.MAX_ALPHA));
            }
        }
        if (!mBoundary) {
            touchingView.offsetTopAndBottom((int) deltaY);
        } else {
            float touchingViewY = ViewHelper.getY(touchingView);
            if (touchingViewY + deltaY <= mMeasureHeight - mPanelHeight) {
                touchingView.offsetTopAndBottom((int) (mMeasureHeight - mPanelHeight - touchingViewY));
            } else if (touchingViewY + deltaY >= mMeasureHeight - mTitleHeightNoDisplay) {
                touchingView.offsetTopAndBottom((int) (mMeasureHeight - mTitleHeightNoDisplay - touchingViewY));
            } else {
                touchingView.offsetTopAndBottom((int) deltaY);
            }
        }
    }
}