Example usage for android.view ViewPropertyAnimator start

List of usage examples for android.view ViewPropertyAnimator start

Introduction

In this page you can find the example usage for android.view ViewPropertyAnimator start.

Prototype

public void start() 

Source Link

Document

Starts the currently pending property animations immediately.

Usage

From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java

private void backToConversation(boolean afterFling) {
    if (isClosing) {
        return;/*from ww  w. jav a  2  s  . com*/
    }
    isClosing = true;
    loadClickedImageSizeAndPosition();
    initAnimatingImageView(afterFling);

    restoreRotation();
    getControllerFactory().getSingleImageController().hideSingleImage();
    fadeControls(false);

    PointF currentFocusPoint = messageTouchImageView.getScrollPosition();
    if (currentFocusPoint == null) {
        getControllerFactory().getSingleImageController().clearReferences();
        getFragmentManager().popBackStack();
        return;
    }
    TouchImageView.FocusAndScale startFocusAndScale = new TouchImageView.FocusAndScale(currentFocusPoint.x,
            currentFocusPoint.y, messageTouchImageView.getCurrentZoom());
    TouchImageView.FocusAndScale finishFocusAndScale = new TouchImageView.FocusAndScale(0.5f, 0.5f, 1f);
    if ((MathUtils.floatEqual(currentFocusPoint.x, 0.5f) || MathUtils.floatEqual(currentFocusPoint.y, 0.5f))
            && MathUtils.floatEqual(messageTouchImageView.getCurrentZoom(), 1f)) {
        zoomOutAndRotateBackOnCloseDuration = 1;
    }
    ObjectAnimator
            .ofObject(messageTouchImageView, "focusAndScale", new TouchImageView.FocusAndScaleEvaluator(),
                    startFocusAndScale, finishFocusAndScale)
            .setDuration(zoomOutAndRotateBackOnCloseDuration).start();

    final boolean imageOffScreenInList = getControllerFactory().getSingleImageController()
            .isContainerOutOfScreen();
    ViewPropertyAnimator exitAnimation = animatingImageView.animate();
    if (imageOffScreenInList) {
        exitAnimation.alpha(0);
    } else {
        exitAnimation.x(clickedImageLocation.x).y(clickedImageLocation.y).rotation(0f).scaleX(1f).scaleY(1f);
    }
    exitAnimation.setDuration(openAnimationDuration).setStartDelay(zoomOutAndRotateBackOnCloseDuration)
            .setInterpolator(new Expo.EaseOut()).withStartAction(new Runnable() {
                @Override
                public void run() {
                    animatingImageView.setVisibility(View.VISIBLE);
                    messageTouchImageView.setVisibility(View.GONE);
                    if (imageOffScreenInList) {
                        getControllerFactory().getSingleImageController().getImageContainer()
                                .setVisibility(View.VISIBLE);
                    } else {
                        getControllerFactory().getSingleImageController().getImageContainer()
                                .setVisibility(View.INVISIBLE);
                    }
                    ViewUtils.fadeInView(
                            getControllerFactory().getSingleImageController().getLoadingIndicator(),
                            getResources().getInteger(R.integer.framework_animation_duration_short));
                }
            }).withEndAction(new Runnable() {
                @Override
                public void run() {
                    getControllerFactory().getSingleImageController().getImageContainer()
                            .setVisibility(View.VISIBLE);
                    getControllerFactory().getSingleImageController().clearReferences();
                    getFragmentManager().popBackStack();
                }
            });

    exitAnimation.start();

    background.animate().alpha(0f)
            .setStartDelay(zoomOutAndRotateBackOnCloseDuration + closeAnimationBackgroundDelay)
            .setDuration(openAnimationBackgroundDuration).setInterpolator(new Quart.EaseOut()).start();
}