Java Code Examples for android.view.View#setCameraDistance()

The following examples show how to use android.view.View#setCameraDistance() . 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: CoolViewPager   File: RotateTransformer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    page.setCameraDistance(10000F);
    if(position < -1){
        /*page.setPivotX(page.getWidth());
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(-MAX_ROTATE);*/
    }else if(position <= 0){
        page.setPivotX(page.getWidth());
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE * position);
    }else if(position <= 1){
        page.setPivotX(0F);
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE * position);
    }else {
        /*page.setPivotX(0F);
        page.setPivotY(page.getHeight()/2);
        page.setRotationY(MAX_ROTATE);*/
    }
}
 
Example 2
@Override
public void transformPage(View page, float position) {
    page.setTranslationX(page.getWidth() * -position);
    page.setTranslationY(page.getHeight() * position);
    page.setCameraDistance(10000F);
    if(position < -1){
        page.setRotationX(0F);
    }else if(position <= 0){
        page.setPivotX(page.getWidth()/2);
        page.setPivotY(page.getHeight());
        page.setRotationX(MAX_ROTATE * -position);
    }else if(position <= 1){
        page.setPivotX(page.getWidth()/2);
        page.setPivotY(0F);
        page.setRotationX(MAX_ROTATE * -position);
    }else {
        page.setRotationX(0F);
    }
}
 
Example 3
/**
 * Tilts the tabs, when overshooting at the start.
 *
 * @param angle
 *         The angle, the tabs should be rotated by, in degrees as a {@link Float} value
 */
private void tiltOnStartOvershoot(final float angle) {
    ItemIterator iterator =
            new ItemIterator.Builder(getTabSwitcher(), tabViewRecycler).create();
    AbstractItem item;

    while ((item = iterator.next()) != null) {
        View view = item.getView();

        if (item.getIndex() == 0) {
            view.setCameraDistance(maxCameraDistance);
            getArithmetics().setPivot(Axis.DRAGGING_AXIS, item, getArithmetics()
                    .getPivot(Axis.DRAGGING_AXIS, item, DragState.OVERSHOOT_START));
            getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item, getArithmetics()
                    .getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.OVERSHOOT_START));
            getArithmetics().setRotation(Axis.ORTHOGONAL_AXIS, item, angle);
        } else if (item.isInflated()) {
            item.getView().setVisibility(View.INVISIBLE);
        }
    }
}
 
Example 4
Source Project: Trebuchet   File: Flip.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void screenScrolled(View v, float progress) {
    float rotation = -180.0f * Math.max(-1f, Math.min(1f, progress));

    v.setCameraDistance(mPagedView.mDensity * CAMERA_DISTANCE);
    v.setPivotX(v.getMeasuredWidth() * 0.5f);
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);

    if (progress >= -0.5f && progress <= 0.5f) {
        v.setTranslationX(v.getMeasuredWidth() * progress);
        if (v.getVisibility() != View.VISIBLE) {
            v.setVisibility(View.VISIBLE);
        }
    } else {
        v.setTranslationX(v.getMeasuredWidth() * -10f);
    }
}
 
Example 5
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position * page.getWidth());
    page.setCameraDistance(12000);

    if (position < 0.5 && position > -0.5) {
        page.setVisibility(View.VISIBLE);
    } else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0) {    // [-1,0]
        page.setAlpha(1);
        page.setRotationY(900 *(1-Math.abs(position)+1));

    }
    else if (position <= 1) {    // (0,1]
        page.setAlpha(1);
        page.setRotationY(-900 *(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 6
Source Project: TurboLauncher   File: PagedView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, int i, float scrollProgress) {
    float rotation = 90.0f * scrollProgress;

    v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
    v.setTranslationX(v.getMeasuredWidth() * scrollProgress);
    v.setPivotX(!mPagedView.isLayoutRtl() ? 0f : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() / 2);
    v.setRotationY(-rotation);
}
 
Example 7
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position*page.getWidth());
    page.setCameraDistance(999999999);

    if (position < 0.5 && position > -0.5){
        page.setVisibility(View.VISIBLE);
    }
    else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0 ){    // [-1,0]
        page.setAlpha(1);
        page.setRotationX(180*(1-Math.abs(position)+1));

    }
    else if (position <= 1){    // (0,1]
        page.setAlpha(1);
        page.setRotationX(-180*(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 8
@Override
public void transformPage(View page, float position) {

    page.setCameraDistance(20000);


    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0){    // [-1,0]
        page.setAlpha(1);
        page.setPivotX(page.getWidth());
        page.setRotationY(90*Math.abs(position));

    }
    else if (position <= 1){    // (0,1]
        page.setAlpha(1);
        page.setPivotX(0);
        page.setRotationY(-90*Math.abs(position));

    }
    else{    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 9
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 10
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 11
@Override
public void transformPage(View page, float position) {
    page.setCameraDistance(20000);


    if (position < -1){
        page.setAlpha(0);
    }
    else if (position <= 0){
        page.setAlpha(1);
        page.setPivotX(page.getWidth());
        page.setRotationY(90*Math.abs(position));
    }
    else if (position <= 1){
        page.setAlpha(1);
        page.setPivotX(0);
        page.setRotationY(-90*Math.abs(position));
    }
    else{
        page.setAlpha(0);
    }



    if (Math.abs(position) <= 0.5){
        page.setScaleY(Math.max(.4f,1-Math.abs(position)));
    }
    else if (Math.abs(position) <= 1){
        page.setScaleY(Math.max(.4f,1-Math.abs(position)));

    }


}
 
Example 12
Source Project: TurboLauncher   File: PagedView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, int i, float scrollProgress) {
    float rotation = (mIn ? 90.0f : -90.0f) * scrollProgress;

    if (mIn) {
        v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
    }

    v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);
}
 
Example 13
@Override
public void transformPage(View page, float position) {

    page.setTranslationX(-position * page.getWidth());
    page.setCameraDistance(12000);

    if (position < 0.5 && position > -0.5) {
        page.setVisibility(View.VISIBLE);
    } else {
        page.setVisibility(View.INVISIBLE);
    }



    if (position < -1){     // [-Infinity,-1)
        // This page is way off-screen to the left.
        page.setAlpha(0);

    }
    else if (position <= 0) {    // [-1,0]
        page.setAlpha(1);
        page.setRotationY(180 *(1-Math.abs(position)+1));

    }
    else if (position <= 1) {    // (0,1]
        page.setAlpha(1);
        page.setRotationY(-180 *(1-Math.abs(position)+1));

    }
    else {    // (1,+Infinity]
        // This page is way off-screen to the right.
        page.setAlpha(0);

    }


}
 
Example 14
@Override
protected void onTransform(View page, float position) {
    if (position < -1) {
        /* [-Infinity,-1)*/
        /*页面已经在屏幕左侧第一个*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(15);
    } else if (position <= 0) {
        /* [-1,0]*/
        /*页面从左侧进入或者向左侧滑出的状态*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15 + (1 - position) * 15);
    } else if (position <= 1) {
        /* (0,1]*/
        /*页面从右侧进入或者向右侧滑出的状态*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15 + (1 - position) * 15);
    } else if (position <= 2) {
        /*页面已经在屏幕右侧第一个*/
        page.setCameraDistance(10000);
        page.setPivotX(page.getWidth() / 2);
        page.setPivotY(page.getWidth());
        page.setRotationY(-15);
    }
}
 
Example 15
Source Project: react-native-GPay   File: BaseViewManager.java    License: MIT License 5 votes vote down vote up
private static void resetTransformProperty(View view) {
  view.setTranslationX(PixelUtil.toPixelFromDIP(0));
  view.setTranslationY(PixelUtil.toPixelFromDIP(0));
  view.setRotation(0);
  view.setRotationX(0);
  view.setRotationY(0);
  view.setScaleX(1);
  view.setScaleY(1);
  view.setCameraDistance(0);
}
 
Example 16
private void transformPageFlip(View view, float position) {
    float percentage = 1 - Math.abs(position);
    view.setCameraDistance(12000);
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 17
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 18
@Override
protected void onTransform(View view, float position) {
    float percentage = 1 - Math.abs(position);
    if(Build.VERSION.SDK_INT >= 13){
        view.setCameraDistance(12000);
    }
    setVisibility(view, position);
    setTranslation(view);
    setSize(view, position, percentage);
    setRotation(view, position, percentage);
}
 
Example 19
Source Project: Trebuchet   File: Cube.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void screenScrolled(View v, float progress) {
    float rotation = (cubIn ? 90.0f : -90.0f) * progress;

    if (cubIn) {
        v.setCameraDistance(mPagedView.mDensity * CAMERA_DISTANCE);
    }

    v.setPivotX(progress < 0 ? 0 : v.getMeasuredWidth());
    v.setPivotY(v.getMeasuredHeight() * 0.5f);
    v.setRotationY(rotation);
}
 
Example 20
@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();

    mUseTransitionEffect = !isInOverviewMode() && !mIsSwitchingState;

    updatePageAlphaValues(screenCenter);

    super.screenScrolled(screenCenter);

    enableHwLayersOnVisiblePages();

    boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;

    if (isInOverscroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.35f;
        final float rightBiasedPivot = 0.65f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        View v = getPageAt(index);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            v.setCameraDistance(mDensity * mCameraDistance);
            v.setPivotX(v.getMeasuredWidth() * pivotX);
        }

        float scrollProgress = getScrollProgress(screenCenter, v, index);
        float rotation = -TRANSITION_MAX_ROTATION * scrollProgress;
        v.setRotationY(rotation);
    } else {
        if (mOverscrollTransformsSet) {
            mOverscrollTransformsSet = false;
            View v0 = getPageAt(mCurrentPage);
            v0.setRotationY(0);
            v0.setCameraDistance(mDensity * mCameraDistance);
            v0.setPivotX(v0.getMeasuredWidth() / 2);
            v0.setPivotY(v0.getMeasuredHeight() / 2);
        }
    }
}