Java 类android.view.animation.Transformation 实例源码

项目:Hamburger-Button    文件:HBButton.java   
private Animation generateLineLTRAnimation(final RectF rectF, long offset) {

        final float currentLeft = rectF.left;
        final float currentRight = rectF.right;

        Animation animation = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                super.applyTransformation(interpolatedTime, t);
                if (getCurrentState() == HBButtonState.NORMAL) {
                    rectF.set(rectF.left, rectF.top, currentRight - (currentRight - currentLeft) / 2 * interpolatedTime, rectF.bottom);
                } else {
                    rectF.set(rectF.left, rectF.top, currentRight + (currentRight - currentLeft) * interpolatedTime, rectF.bottom);
                }
                invalidate();
            }
        };
        animation.setDuration(getAnimationDuration());
        animation.setStartOffset(offset);
        return animation;
    }
项目:Hamburger-Button    文件:HBButton.java   
private Animation generateLineRTLAnimation(final RectF rectF, long offset) {

        final float currentLeft = rectF.left;
        final float currentRight = rectF.right;

        Animation animation = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                super.applyTransformation(interpolatedTime, t);
                if (getCurrentState() == HBButtonState.NORMAL) {
                    rectF.set(currentLeft + (currentRight - currentLeft) / 2 * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
                } else {
                    rectF.set(currentLeft - (currentRight - currentLeft) * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
                }
                invalidate();
            }
        };
        animation.setDuration(getAnimationDuration());
        animation.setStartOffset(offset);
        return animation;
    }
项目:GeekZone    文件:SwipeRefreshLayout.java   
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
    int targetTop = 0;
    int endTarget = 0;
    if (!mUsingCustomStart) {
        switch (mDirection) {
            case BOTTOM:
                endTarget = getMeasuredHeight() - (int) (mSpinnerFinalOffset);
                break;
            case TOP:
            default:
                endTarget = (int) (mSpinnerFinalOffset - Math.abs(mOriginalOffsetTop));
                break;
        }
    } else {
        endTarget = (int) mSpinnerFinalOffset;
    }
    targetTop = (mFrom + (int) ((endTarget - mFrom) * interpolatedTime));
    int offset = targetTop - mCircleView.getTop();
    setTargetOffsetTopAndBottom(offset, false /* requires update */);
}
项目:HutHelper    文件:CourseInfoGallery.java   
private void transformImageBitmap(View child, Transformation t,
                                  int rotationAngle) {
    mCamera.save();
    final Matrix imageMatrix = t.getMatrix();
    final int imageHeight = child.getLayoutParams().height;
    final int imageWidth = child.getLayoutParams().width;
    final int rotation = Math.abs(rotationAngle);

    mCamera.translate(0.0f, 0.0f, 100.0f);

    // As the angle of the view gets less, zoom in
    if (rotation < mMaxRotationAngle) {
        float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
        mCamera.translate(0.0f, 0.0f, zoomAmount);
    }

    mCamera.rotateY(rotationAngle);
    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
    mCamera.restore();
}
项目:shareNote    文件:Rotate3dAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final Matrix matrix = t.getMatrix();

    mCamera.save();
    switch (mRollType) {
        case ROLL_BY_X:
            mCamera.rotateX(degrees);
            break;
        case ROLL_BY_Y:
            mCamera.rotateY(degrees);
            break;
        case ROLL_BY_Z:
            mCamera.rotateZ(degrees);
            break;
    }
    mCamera.getMatrix(matrix);
    mCamera.restore();

    matrix.preTranslate(-mPivotX, -mPivotY);
    matrix.postTranslate(mPivotX, mPivotY);
}
项目:AndroidUiKit    文件:ISwipeRefreshLayout.java   
@SuppressLint("NewApi")
private void startScaleDownReturnToStartAnimation(Animation.AnimationListener listener) {
    mStartingScale = mRefreshView.getScaleX();
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mScaleDownToStartAnimation.setAnimationListener(listener);
    }
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(mScaleDownToStartAnimation);
}
项目:android-source-codes    文件:SwipeRefreshLayout.java   
private void startScaleDownReturnToStartAnimation(int from,
        Animation.AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = mProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(mCircleView);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale  * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownToStartAnimation);
}
项目:BookReader-master    文件:SwipeRefreshLayout.java   
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
    // Pre API 11, alpha is used in place of scale. Don't also use it to
    // show the trigger point.
    if (mScale && isAlphaUsedForScale()) {
        return null;
    }
    Animation alpha = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            mProgress
                    .setAlpha((int) (startingAlpha+ ((endingAlpha - startingAlpha)
                            * interpolatedTime)));
        }
    };
    alpha.setDuration(ALPHA_ANIMATION_DURATION);
    // Clear out the previous animation listeners.
    mCircleView.setAnimationListener(null);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(alpha);
    return alpha;
}
项目:SwipeToRefresh    文件:SwipeToRefreshLayout.java   
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
    // Pre API 11, alpha is used in place of scale. Don't also use it to
    // show the trigger point.
    if (mScale && isAlphaUsedForScale()) {
        return null;
    }
    Animation alpha = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            mProgress
                    .setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha)
                            * interpolatedTime)));
        }
    };
    alpha.setDuration(ALPHA_ANIMATION_DURATION);
    // Clear out the previous animation listeners.
    mCircleView.setAnimationListener(null);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(alpha);
    return alpha;
}
项目:FLFloatingButton    文件:RotateAndTranslateAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * interpolatedTime);
    if (mPivotX == 0.0f && mPivotY == 0.0f) {
        t.getMatrix().setRotate(degrees);
    } else {
        t.getMatrix().setRotate(degrees, mPivotX, mPivotY);
    }

    float dx = mFromXDelta;
    float dy = mFromYDelta;
    if (mFromXDelta != mToXDelta) {
        dx = mFromXDelta + ((mToXDelta - mFromXDelta) * interpolatedTime);
    }
    if (mFromYDelta != mToYDelta) {
        dy = mFromYDelta + ((mToYDelta - mFromYDelta) * interpolatedTime);
    }

    t.getMatrix().postTranslate(dx, dy);
}
项目:Flashcards-Demo    文件:FlipAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final double radians = Math.PI * interpolatedTime;
    float degrees = (float) (180.0 * radians / Math.PI);

    if (interpolatedTime >= 0.5f) { // Alternate the visibility of views at the exact half of animation duration.
        degrees -= 180.f;
        fromView.setVisibility(View.GONE);
        toView.setVisibility(View.VISIBLE);
    }

    if (forward)
        degrees = -degrees;

    final Matrix matrix = t.getMatrix();
    camera.save();
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:MultiSelecter    文件:SuperSwipeRefreshLayout.java   
private void startScaleUpAnimation(AnimationListener listener) {
    mHeadViewContainer.setVisibility(View.VISIBLE);
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
项目:Aurora    文件:ExpandTextView.java   
public void expand() {
    if (!isExpand) {
        isExpand = true;
        mText.setTextColor(Color.TRANSPARENT);
        mExpandText.setTextColor(mTextColor);
        Animation animation = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                ViewGroup.LayoutParams params = ExpandTextView.this.getLayoutParams();
                params.height = mStart + (int) ((mEnd - mStart) * interpolatedTime);
                setLayoutParams(params);
            }
        };
        animation.setDuration(500);
        startAnimation(animation);
    }

}
项目:FragmentRigger    文件:Rotate3d.java   
@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    Camera camera = new Camera();
    camera.save();

    // 设置camera动作为绕Y轴旋转
    // 总共旋转180度,因此计算在每个补间时间点interpolatedTime的角度即为两着相乘
//    camera.rotateX(deg * interpolatedTime);
    camera.rotateY(180 * interpolatedTime);
//    camera.rotateZ(180 * interpolatedTime);
//
    // 根据camera动作产生一个matrix,赋给Transformation的matrix,以用来设置动画效果
    Matrix matrix = t.getMatrix();
    camera.getMatrix(matrix);

    camera.restore();
    //经过以下平移,才能以view的中心点进行翻转
    matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2);
    matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2);
  }
项目:Android-Demo_ImageCroper    文件:CropImageAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {

    mAnimRect.left = mStartCropWindowRect.left + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
    mAnimRect.top = mStartCropWindowRect.top + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
    mAnimRect.right = mStartCropWindowRect.right + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
    mAnimRect.bottom = mStartCropWindowRect.bottom + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
    mCropOverlayView.setCropWindowRect(mAnimRect);

    for (int i = 0; i < mAnimPoints.length; i++) {
        mAnimPoints[i] = mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
    }
    mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());

    for (int i = 0; i < mAnimMatrix.length; i++) {
        mAnimMatrix[i] = mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
    }
    Matrix m = mImageView.getImageMatrix();
    m.setValues(mAnimMatrix);
    mImageView.setImageMatrix(m);

    mImageView.invalidate();
    mCropOverlayView.invalidate();
}
项目:Amazing    文件:SuperSwipeRefreshLayout.java   
private void startScaleDownReturnToStartAnimation(int from,
                                                  AnimationListener listener) {
    mFrom = from;
    mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
项目:letv    文件:SwipeRefreshLayout.java   
private void startScaleUpAnimation(AnimationListener listener) {
    this.mCircleView.setVisibility(0);
    if (VERSION.SDK_INT >= 11) {
        this.mProgress.setAlpha(255);
    }
    this.mScaleAnimation = new Animation() {
        public void applyTransformation(float interpolatedTime, Transformation t) {
            SwipeRefreshLayout.this.setAnimationProgress(interpolatedTime);
        }
    };
    this.mScaleAnimation.setDuration((long) this.mMediumAnimationDuration);
    if (listener != null) {
        this.mCircleView.setAnimationListener(listener);
    }
    this.mCircleView.clearAnimation();
    this.mCircleView.startAnimation(this.mScaleAnimation);
}
项目:gesture-refresh-layout    文件:GestureRefreshLayout.java   
private void startScaleUpAnimation(Animation.AnimationListener listener) {
    mRefreshView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        //mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    mScaleAnimation.setAnimationListener(listener);
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(mScaleAnimation);
}
项目:BuddyBook    文件:AnimationUtils.java   
public static void expand(final View v) {
    v.measure(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? ActionBar.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
项目:FreeStreams-TVLauncher    文件:Rotate3dAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:javaide    文件:AndroidTreeView.java   
private static void expand(final View v) {
    v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LinearLayout.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
项目:SRPrgressDialog    文件:SRProgressDialog.java   
@SuppressLint("NewApi")
private void startScaleUpAnimation(Animation.AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
项目:HiBangClient    文件:RotateAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float deg = 0.0F + 360.0F * interpolatedTime;
    Matrix matrix = t.getMatrix();
    mCamera.save();
    if (mMode == Mode.X)
        mCamera.rotateX(deg);
    if (mMode == Mode.Y)
        mCamera.rotateY(deg);
    if (mMode == Mode.Z)
        mCamera.rotateZ(deg);

    mCamera.getMatrix(matrix);
    mCamera.restore();
    matrix.preTranslate(-mCenterX, -mCenterY);
    matrix.postTranslate(mCenterX, mCenterY);

}
项目:AssistantBySDK    文件:LingjuSwipeRefreshLayout.java   
private void startScaleUpAnimation(final CircleImageView view, Animation.AnimationListener listener) {
    view.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        if (view == tCircleView)
            tProgress.setAlpha(MAX_ALPHA);
        else
            bProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(view, interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        view.setAnimationListener(listener);
    }
    view.clearAnimation();
    view.startAnimation(mScaleAnimation);
}
项目:AssistantBySDK    文件:LingjuSwipeUpLoadRefreshLayout.java   
private void startScaleUpAnimation(final CircleImageView view, Animation.AnimationListener listener) {
    view.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
            bProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(view, interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        view.setAnimationListener(listener);
    }
    view.clearAnimation();
    view.startAnimation(mScaleAnimation);
}
项目:AssistantBySDK    文件:LingjuSwipeUpLoadRefreshLayout.java   
private void startScaleDownReturnToStartAnimation(final CircleImageView view, int from,
                                                  Animation.AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = bProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(view);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(view, targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        view.setAnimationListener(listener);
    }
    view.clearAnimation();
    view.startAnimation(mScaleDownToStartAnimation);
}
项目:BookLoadingView    文件:Rotate3dAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:MyFlightbookAndroid    文件:ActMFBForm.java   
private void collapseView(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
项目:react-native-udesk    文件:UdeskExpandableLayout.java   
@Override
protected void applyTransformation(float interpolatedTime,
        Transformation t) {
    try {
        int newHeight;
        if (down) {
                  newHeight = (int) (targetHeight * interpolatedTime);
              } else {
                  newHeight = (int) (targetHeight * (1 - interpolatedTime));
              }
        view.getLayoutParams().height = newHeight;
        view.requestLayout();
        if (view.getVisibility() == View.GONE) {
                  view.setVisibility(View.VISIBLE);
              }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Hillffair17    文件:GalleryView.java   
public  void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if(interpolatedTime == 1){
                v.setVisibility(View.GONE);
            }else{
                v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
项目:boohee_v5.6    文件:ExpandableLayout.java   
private void expand(final View v) {
    v.measure(-1, -2);
    final int targetHeight = v.getMeasuredHeight();
    v.getLayoutParams().height = 0;
    v.setVisibility(0);
    this.animation = new Animation() {
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1.0f) {
                ExpandableLayout.this.isOpened = Boolean.valueOf(true);
            }
            v.getLayoutParams().height = interpolatedTime == 1.0f ? -2 : (int) (((float)
                    targetHeight) * interpolatedTime);
            v.requestLayout();
        }

        public boolean willChangeBounds() {
            return true;
        }
    };
    this.animation.setDuration((long) this.duration.intValue());
    v.startAnimation(this.animation);
}
项目:Rotate3d    文件:Rotate3dAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;
    final Matrix matrix = t.getMatrix();
    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:AndroidOpen    文件:SwipeToRefreshLayout.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    int targetTop;
    int endTarget;
    switch (mType) {
        case BOTTOM:
            endTarget = getMeasuredHeight() - (int) (mSpinnerFinalOffset);
            break;
        case TOP:
        default:
            endTarget = (int) (mSpinnerFinalOffset - Math.abs(mOriginalOffsetTop));
            break;
    }
    targetTop = (mFrom + (int) ((endTarget - mFrom) * interpolatedTime));
    int offset = targetTop - mLoadingView.getTop();
    setTargetOffsetTopAndBottom(offset, false);
}
项目:Android-MorphAnimation    文件:MorphAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    try {
        if (mTargetView != null && mAnimationStep == ANIMATION_STEP_PLAY) {
            LayoutParams l = mTargetView.getLayoutParams();

            if (mAnimationMode == ANIMATION_MODE_WIDTH || mAnimationMode == ANIMATION_MODE)
                l.width = (int) (startX + (toX - startX) * interpolatedTime);

            if (mAnimationMode == ANIMATION_MODE_HEIGHT || mAnimationMode == ANIMATION_MODE)
                l.height = (int) (startY + (toY - startY) * interpolatedTime);

            mTargetView.requestLayout();
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception applyTransformation", e);
    }
}
项目:letv    文件:SwipeRefreshLayout.java   
private void startScaleDownAnimation(AnimationListener listener) {
    this.mScaleDownAnimation = new Animation() {
        public void applyTransformation(float interpolatedTime, Transformation t) {
            SwipeRefreshLayout.this.setAnimationProgress(1.0f - interpolatedTime);
        }
    };
    this.mScaleDownAnimation.setDuration(150);
    this.mCircleView.setAnimationListener(listener);
    this.mCircleView.clearAnimation();
    this.mCircleView.startAnimation(this.mScaleDownAnimation);
}
项目:Hamburger-Button    文件:HBButton.java   
private Animation generateLineBackRTLStep1(final RectF rectF) {
    final float currentLeft = rectF.left;
    final float currentRight = rectF.right;

    Animation animation = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            super.applyTransformation(interpolatedTime, t);
            rectF.set(currentLeft - (currentRight - currentLeft) * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
            invalidate();
        }
    };
    animation.setDuration(getAnimationDuration() / 4);
    return animation;
}
项目:Hamburger-Button    文件:HBButton.java   
private Animation generateLineBackRTLStep2(final RectF rectF) {
    final float currentLeft = rectF.left;
    final float currentRight = rectF.right;

    Animation animation = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            super.applyTransformation(interpolatedTime, t);
            rectF.set(rectF.left, rectF.top, currentRight - (currentRight - currentLeft) * interpolatedTime, rectF.bottom);
            invalidate();
        }
    };
    animation.setDuration(getAnimationDuration() / 4);
    return animation;
}
项目:ZhaZhaShop    文件:SuperSwipeRefreshLayout.java   
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
    int targetTop = 0;
    int endTarget = 0;
    if (!mUsingCustomStart) {
        endTarget = (int) (mSpinnerFinalOffset - Math
                .abs(mOriginalOffsetTop));
    } else {
        endTarget = (int) mSpinnerFinalOffset;
    }
    targetTop = (mFrom + (int) ((endTarget - mFrom) * interpolatedTime));
    int offset = targetTop - mHeadViewContainer.getTop();
    setTargetOffsetTopAndBottom(offset, false /* requires update */);
}
项目:GitHub    文件:TaurusHeader.java   
private void setupAnimations() {
    mAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, @NonNull Transformation t) {
            setLoadingAnimationTime(interpolatedTime);
        }
    };
    mAnimation.setRepeatCount(Animation.INFINITE);
    mAnimation.setRepeatMode(Animation.REVERSE);
    mAnimation.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);
    mAnimation.setDuration(ANIMATION_DURATION);
}
项目:QRCodeScanner    文件:DefaultScanCursorView.java   
@Override
public boolean getTransformation(long currentTime, Transformation outTransformation) {
    if (mPaused && mElapsedAtPause == 0) {
        mElapsedAtPause = currentTime - getStartTime();
    }
    if (mPaused)
        setStartTime(currentTime - mElapsedAtPause);
    return super.getTransformation(currentTime, outTransformation);
}