Example usage for android.animation AnimatorSet start

List of usage examples for android.animation AnimatorSet start

Introduction

In this page you can find the example usage for android.animation AnimatorSet start.

Prototype

@SuppressWarnings("unchecked")
@Override
public void start() 

Source Link

Document

Starting this AnimatorSet will, in turn, start the animations for which it is responsible.

Usage

From source file:com.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java

public void updateAlert(final Alert alert) {
    mAlert = alert;/*www. j  a va 2  s. c o  m*/
    mDisplayedRoutes.clear();
    mRouteIconsLayout.removeAllViews();

    // Updating views
    displayAlert(alert);

    // View animations
    // For some reason, ObjectAnimator doesn't work here (skips animation states, just shows the
    // last frame), we need to use ValueAnimators.
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(new FastOutSlowInInterpolator());

    // We can't measure the TextView's height before a layout happens because of the setText() call
    // Note: even though displayAlert() was called earlier, the TextView's height is still 0.
    int heightEstimate = mDescriptionTextView.getLineHeight() * mDescriptionTextView.getLineCount() + 10;

    ValueAnimator descriptionHeight = ValueAnimator.ofInt(mDescriptionTextView.getHeight(), heightEstimate);
    descriptionHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.getLayoutParams().height = (int) animation.getAnimatedValue();
            mDescriptionTextView.requestLayout();
        }
    });
    descriptionHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDescriptionTextView.setAlpha(1.0f);
            mDescriptionTextView.setVisibility(View.VISIBLE);
        }
    });

    ValueAnimator descriptionAlpha = ValueAnimator.ofFloat(0, 1.0f);
    descriptionAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.setAlpha((float) animation.getAnimatedValue());
        }
    });

    ValueAnimator progressHeight = ValueAnimator.ofInt(mProgressBar.getHeight(), 0);
    progressHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mProgressBar.getLayoutParams().height = (int) animation.getAnimatedValue();
            mProgressBar.requestLayout();
        }
    });
    progressHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mProgressBar.hide();
        }
    });

    animatorSet.playTogether(progressHeight, descriptionHeight, descriptionAlpha);
    animatorSet.start();
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

@TargetApi(16)
private void openCamera() {
    if (cameraView == null) {
        return;/*www .java2  s.  co m*/
    }
    animateCameraValues[0] = 0;
    animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX;
    animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY;
    cameraAnimationInProgress = true;
    cameraPanel.setVisibility(View.VISIBLE);
    cameraPanel.setTag(null);
    ArrayList<Animator> animators = new ArrayList<>();
    animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f, 1.0f));
    animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f));
    for (int a = 0; a < 2; a++) {
        if (flashModeButton[a].getVisibility() == View.VISIBLE) {
            animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 1.0f));
            break;
        }
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    animatorSet.setDuration(200);
    animatorSet.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animator) {
            cameraAnimationInProgress = false;
        }
    });
    animatorSet.start();
    if (Build.VERSION.SDK_INT >= 21) {
        cameraView
                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);
    }
    cameraOpened = true;
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

private boolean processTouchEvent(MotionEvent event) {
    if (!pressed && event.getActionMasked() == MotionEvent.ACTION_DOWN
            || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
        if (!takingPhoto) {
            pressed = true;/*w  w w  .  j a va  2 s  . com*/
            maybeStartDraging = true;
            lastY = event.getY();
        }
    } else if (pressed) {
        if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
            float newY = event.getY();
            float dy = (newY - lastY);
            if (maybeStartDraging) {
                if (Math.abs(dy) > AndroidUtilities.getPixelsInCM(0.4f, false)) {
                    maybeStartDraging = false;
                }
            } else {
                cameraView.setTranslationY(cameraView.getTranslationY() + dy);
                lastY = newY;
                if (cameraPanel.getTag() == null) {
                    cameraPanel.setTag(1);
                    AnimatorSet animatorSet = new AnimatorSet();
                    animatorSet.playTogether(ObjectAnimator.ofFloat(cameraPanel, "alpha", 0.0f),
                            ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 0.0f),
                            ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 0.0f));
                    animatorSet.setDuration(200);
                    animatorSet.start();
                }
            }
        } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL
                || event.getActionMasked() == MotionEvent.ACTION_UP
                || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
            pressed = false;
            if (Math.abs(cameraView.getTranslationY()) > cameraView.getMeasuredHeight() / 6.0f) {
                closeCamera(true);
            } else {
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(ObjectAnimator.ofFloat(cameraView, "translationY", 0.0f),
                        ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f),
                        ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 1.0f),
                        ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 1.0f));
                animatorSet.setDuration(250);
                animatorSet.setInterpolator(interpolator);
                animatorSet.start();
                cameraPanel.setTag(null);
            }
        }
    }
    return true;
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

private void onResult(final String result) {
    // Calculate the values needed to perform the scale and translation animations,
    // accounting for how the scale will affect the final position of the text.
    final float resultScale = mInputEditText.getVariableTextSize(result) / mResultEditText.getTextSize();
    final float resultTranslationX = (1.0f - resultScale)
            * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd());
    final float resultTranslationY = (1.0f - resultScale) * //TODO delete unnecessary lines for animation
            (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom())
            + (mInputEditText.getBottom() - mResultEditText.getBottom())
            + (mResultEditText.getPaddingBottom() - mInputEditText.getPaddingBottom());
    final float inputTranslationY = -mInputEditText.getBottom();

    // Use a value animator to fade to the final text color over the course of the animation.
    final int resultTextColor = mResultEditText.getCurrentTextColor();
    final int inputEditText = mInputEditText.getCurrentTextColor();
    final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor,
            inputEditText);/*from w w  w  . j  a va2s.c  om*/
    textColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mResultEditText.setTextColor((int) valueAnimator.getAnimatedValue());
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(textColorAnimator,
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY),
            ObjectAnimator.ofFloat(mInputEditText, View.TRANSLATION_Y, inputTranslationY));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mResultEditText.setText(result);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // Reset all of the values modified during the animation.
            mResultEditText.setTextColor(resultTextColor);
            mResultEditText.setScaleX(1.0f);
            mResultEditText.setScaleY(1.0f);
            mResultEditText.setTranslationX(0.0f);
            mResultEditText.setTranslationY(0.0f);
            mInputEditText.setTranslationY(0.0f);

            // Finally update the input to use the current result.
            mInputEditText.setText(result); //TODO figure out how to reset after equal sign without changing input text
            mResultEditText.getEditableText().clear();
            setState(CalculatorState.RESULT);

            mCurrentAnimator = null;
        }

    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:ch.gianulli.flashcards.ui.Flashcard.java

public void turnCard() {
    if (mPreviousAnimation != null) {
        mPreviousAnimation.cancel();/*from  www .j  a  v a 2s  .  c om*/
        mPreviousAnimation = null;
    }

    AnimatorSet set = new AnimatorSet();

    mQuestion.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mAnswer.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    if (mQuestionShowing) {
        mQuestionShowing = false;

        mQuestion.setVisibility(View.VISIBLE);
        mQuestion.setAlpha(1.0f);
        mAnswer.setVisibility(View.VISIBLE);
        mAnswer.setAlpha(0.0f);

        ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 1.0f, 0.0f);
        questionAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mQuestion.setVisibility(View.GONE);
            }
        });

        ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 0.0f, 1.0f);

        set.playTogether(questionAnim, answerAnim);

        // Show button bar if necessary
        if (!mButtonBarShowing) {
            expandButtonBar();
        }
    } else {
        mQuestionShowing = true;

        mQuestion.setVisibility(View.VISIBLE);
        mQuestion.setAlpha(0.0f);
        mAnswer.setVisibility(View.VISIBLE);
        mAnswer.setAlpha(1.0f);

        ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 0.0f, 1.0f);

        ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 1.0f, 0.0f);
        answerAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mAnswer.setVisibility(View.GONE);
            }
        });

        set.playTogether(questionAnim, answerAnim);
    }

    set.setDuration(400);

    mPreviousAnimation = set;

    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mQuestion.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            mAnswer.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            mPreviousAnimation = null;
        }
    });

    set.start();
}

From source file:com.google.samples.apps.sergio.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;//w  ww.j  av  a 2  s  .c o m
    }
    mExpandAccountBoxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_drawer_accounts_collapse
            : R.drawable.ic_drawer_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}

From source file:org.michaelbel.bottomsheet.BottomSheet.java

private void dismissWithButtonClick(final int viewId) {
    if (dismissed) {
        return;//from   w  w  w .  j  a  va  2s. c om
    }

    dismissed = true;
    cancelSheetAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(containerView, "translationY",
                    containerView.getMeasuredHeight() + Utils.dp(getContext(), 10)),
            ObjectAnimator.ofInt(backDrawable, "alpha", 0));
    animatorSet.setDuration(180);
    animatorSet.setInterpolator(new AccelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
                if (onClickListener != null) {
                    onClickListener.onClick(BottomSheet.this, viewId);
                }

                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            BottomSheet.super.dismiss();
                        } catch (Exception e) {
                            Log.e(TAG, e.getMessage());
                        }
                    }
                });
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
            }
        }
    });

    animatorSet.start();
    currentSheetAnimation = animatorSet;

    if (bottomSheetCallBack != null) {
        bottomSheetCallBack.onClose();
    }
}

From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;/*from  w w w.java  2s. com*/
    }
    mExpandAccountBoxIndicator.setImageResource(
            mAccountBoxExpanded ? com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_collapse
                    : com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}

From source file:com.google.samples.apps.iosched.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;/* www  .j  ava  2s  . c o  m*/
    }
    mExpandAccountBoxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_navview_accounts_collapse
            : R.drawable.ic_navview_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}

From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java

@Override
public void dismiss() {
    if (dismissed) {
        return;//  w  ww  . j av  a2 s. c om
    }
    dismissed = true;
    cancelSheetAnimation();
    if (!allowCustomAnimation || !onCustomCloseAnimation()) {
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(containerView, "translationY",
                        containerView.getMeasuredHeight() + AndroidUtilities.dp(10)),
                ObjectAnimator.ofInt(backDrawable, "alpha", 0));
        if (useFastDismiss) {
            int height = containerView.getMeasuredHeight();
            animatorSet.setDuration(
                    Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height)));
            useFastDismiss = false;
        } else {
            animatorSet.setDuration(180);
        }
        animatorSet.setInterpolator(new AccelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                dismissInternal();
                            } catch (Exception e) {
                                FileLog.e("tmessages", e);
                            }
                        }
                    });
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}