Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator.

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*******************************************
 * /*ww  w  .j a v  a  2 s.  co  m*/
 * initializeAnimations
 * 
 *******************************************/
private void initializeAnimations() {
    /*
     * Puts the left panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                30, 30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                15, 15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveLeft.setDuration(1);
    perspectiveLeft.setFillAfter(true);

    /*
     * Puts the right panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -30, -30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -15, -15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveRight.setDuration(1);
    perspectiveRight.setFillAfter(true);
    //perspectiveLeftAnim.setDuration(500);
    //perspectiveLeftAnim.setInterpolator(new AccelerateInterpolator());

    /*
     * Hides a panel left
     */
    hideLeft = new Rotate3dAnimationY(30, 90, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    hideLeft.setDuration(300);
    hideLeft.setFillAfter(true);
    hideLeft.setInterpolator(new DecelerateInterpolator());
    hideLeft.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Shows a panel hidden to the left
     */
    showLeft = new Rotate3dAnimationY(270, 390, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    showLeft.setDuration(600); // double of the angle
    showLeft.setFillAfter(true);
    showLeft.setInterpolator(new AccelerateInterpolator());
    showLeft.setAnimationListener(this.showAlbumAnimationListener);

    /*
     * Fades an Album out
     */
    /*fadeAlbumOut = new AlphaAnimation((float) 1.0, 0);
    fadeAlbumOut.setDuration(250);
    fadeAlbumOut.setFillAfter(true);
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);       
    */
    //      fadeAlbumOut = new TranslateAnimation(-display.getWidth(),-display.getWidth(), 0, 0);
    fadeAlbumOut = new AlphaAnimation(1.0f, 0.0f);
    fadeAlbumOut.setDuration(200);
    fadeAlbumOut.setFillAfter(true);
    //fadeAlbumOut.setInterpolator(new AccelerateInterpolator());
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Fades an Album in
     */
    /*fadeAlbumIn = new AlphaAnimation(0, 1);
    fadeAlbumIn.setDuration(250);
    fadeAlbumIn.setFillAfter(true);
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
    */
    //      fadeAlbumIn = new TranslateAnimation(-display.getWidth(),0, 0, 0);
    fadeAlbumIn = new AlphaAnimation(0.0f, 1.0f);
    fadeAlbumIn.setDuration(200);
    fadeAlbumIn.setFillAfter(true);
    //fadeAlbumIn.setInterpolator(new AccelerateInterpolator());
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
}

From source file:fr.paug.droidcon.ui.BaseActivity.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }//from   w w  w . ja va2s .c  om
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt(mLPreviewUtils, "statusBarColor", shown ? mThemedStatusBarColor : Color.BLACK)
            .setDuration(250);
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();

    updateSwipeRefreshProgressBarTop();

    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java

private void performAnimation() {
    if (!mViewCacheForAnim.isEmpty()) {
        isAnimating = true;//from w w  w . jav  a 2s . com
        int count = mViewCacheForAnim.size();
        final View view = mViewCacheForAnim.remove(0);
        Rect rect = new Rect();
        this.getGlobalVisibleRect(rect);
        int fly_distance = (int) (rect.height());
        float top = view.getY();
        float bottom = view.getY() + view.getMeasuredHeight();
        float startTop = top + fly_distance;
        float startBottom = bottom + fly_distance;
        int bufferDis = rect.height() / 4;

        if (startBottom < 0) {
            Log.d(TAG, "No animation as the view is passed!!");
            view.setVisibility(View.VISIBLE);
            performAnimation();
            return;
        } else if (startTop < rect.height()) {
            fly_distance += (rect.height() - startTop + bufferDis);
        }
        if (fly_distance > rect.height() * 2) {
            Log.d(TAG, "No animation as the fly distance is too long!");
            view.setVisibility(View.VISIBLE);
            performAnimation();
            return;
        } else if (fly_distance < rect.height()) {
            fly_distance = rect.height();
        }

        view.setTranslationY(fly_distance);
        long delay = FLY_IN_DELAY / count;
        long duration = delay > FLY_IN_DURATION ? FLY_IN_DURATION : delay;
        view.animate().setDuration(duration).setInterpolator(new DecelerateInterpolator())
                .setListener(new AnimatorListenerAdapter() {

                    public void onAnimationStart(Animator anim) {
                        view.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationEnd(Animator anim) {
                        view.clearAnimation();
                        view.setTranslationY(0f);
                        performAnimation();
                    }
                }).translationY(0);
    } else {
        isAnimating = false;
    }
}

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

private void setRecordVideoButtonVisible(boolean visible, boolean animated) {
    if (!hasRecordVideo) {
        return;//w ww  .  j  a  v a 2  s .c om
    }
    videoSendButton.setTag(visible ? 1 : null);
    if (audioVideoButtonAnimation != null) {
        audioVideoButtonAnimation.cancel();
        audioVideoButtonAnimation = null;
    }
    if (animated) {
        audioVideoButtonAnimation = new AnimatorSet();
        audioVideoButtonAnimation.playTogether(
                ObjectAnimator.ofFloat(videoSendButton, "scaleX", visible ? 1.0f : 0.1f),
                ObjectAnimator.ofFloat(videoSendButton, "scaleY", visible ? 1.0f : 0.1f),
                ObjectAnimator.ofFloat(videoSendButton, "alpha", visible ? 1.0f : 0.0f),
                ObjectAnimator.ofFloat(audioSendButton, "scaleX", visible ? 0.1f : 1.0f),
                ObjectAnimator.ofFloat(audioSendButton, "scaleY", visible ? 0.1f : 1.0f),
                ObjectAnimator.ofFloat(audioSendButton, "alpha", visible ? 0.0f : 1.0f));
        audioVideoButtonAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (animation.equals(audioVideoButtonAnimation)) {
                    audioVideoButtonAnimation = null;
                }
            }
        });
        audioVideoButtonAnimation.setInterpolator(new DecelerateInterpolator());
        audioVideoButtonAnimation.setDuration(150);
        audioVideoButtonAnimation.start();
    } else {
        videoSendButton.setScaleX(visible ? 1.0f : 0.1f);
        videoSendButton.setScaleY(visible ? 1.0f : 0.1f);
        videoSendButton.setAlpha(visible ? 1.0f : 0.0f);
        audioSendButton.setScaleX(visible ? 0.1f : 1.0f);
        audioSendButton.setScaleY(visible ? 0.1f : 1.0f);
        audioSendButton.setAlpha(visible ? 0.0f : 1.0f);
    }
}

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

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }//from w  ww  . j a  va2  s. co  m
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils,
                    (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor",
                    shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK)
            .setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();

    updateSwipeRefreshProgressBarTop();

    for (final View view : mHideableHeaderViews) {
        if (shown) {
            ViewCompat.animate(view).translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator())
                    // Setting Alpha animations should be done using the
                    // layer_type set to layer_type_hardware for the duration of the animation.
                    .withLayer();
        } else {
            ViewCompat.animate(view).translationY(-view.getBottom()).alpha(0)
                    .setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator())
                    // Setting Alpha animations should be done using the
                    // layer_type set to layer_type_hardware for the duration of the animation.
                    .withLayer();
        }
    }
}

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

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }//w w w .ja  va 2s  .co  m
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils,
                    (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor",
                    shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK)
            .setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();

    updateSwipeRefreshProgressBarTop();

    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:org.telegram.ui.ProfileActivity.java

private void needLayout() {
    FrameLayout.LayoutParams layoutParams;
    int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
            + ActionBar.getCurrentActionBarHeight();
    if (listView != null && !openAnimationInProgress) {
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        if (layoutParams.topMargin != newTop) {
            layoutParams.topMargin = newTop;
            listView.setLayoutParams(layoutParams);
        }/*from   www.  j  a v a2  s.  co m*/
    }

    if (avatarImage != null) {
        float diff = extraHeight / (float) AndroidUtilities.dp(88);
        listView.setTopGlowOffset(extraHeight);

        if (writeButton != null) {
            writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                    + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f));

            if (!openAnimationInProgress) {
                final boolean setVisible = diff > 0.2f;
                boolean currentVisible = writeButton.getTag() == null;
                if (setVisible != currentVisible) {
                    if (setVisible) {
                        writeButton.setTag(null);
                    } else {
                        writeButton.setTag(0);
                    }
                    if (writeButtonAnimation != null) {
                        AnimatorSet old = writeButtonAnimation;
                        writeButtonAnimation = null;
                        old.cancel();
                    }
                    writeButtonAnimation = new AnimatorSet();
                    if (setVisible) {
                        writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
                        writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f),
                                ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f),
                                ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
                    } else {
                        writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
                        writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f),
                                ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f),
                                ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
                    }
                    writeButtonAnimation.setDuration(150);
                    writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
                                writeButtonAnimation = null;
                            }
                        }
                    });
                    writeButtonAnimation.start();
                }
            }
        }

        float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density
                + 27 * AndroidUtilities.density * diff;
        avatarImage.setScaleX((42 + 18 * diff) / 42.0f);
        avatarImage.setScaleY((42 + 18 * diff) / 42.0f);
        avatarImage.setTranslationX(-AndroidUtilities.dp(47) * diff);
        avatarImage.setTranslationY((float) Math.ceil(avatarY));
        for (int a = 0; a < 2; a++) {
            if (nameTextView[a] == null) {
                continue;
            }
            nameTextView[a].setTranslationX(-21 * AndroidUtilities.density * diff);
            nameTextView[a].setTranslationY(
                    (float) Math.floor(avatarY) + AndroidUtilities.dp(1.3f) + AndroidUtilities.dp(7) * diff);
            onlineTextView[a].setTranslationX(-21 * AndroidUtilities.density * diff);
            onlineTextView[a].setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(24)
                    + (float) Math.floor(11 * AndroidUtilities.density) * diff);
            nameTextView[a].setScaleX(1.0f + 0.12f * diff);
            nameTextView[a].setScaleY(1.0f + 0.12f * diff);
            if (a == 1 && !openAnimationInProgress) {
                int width;
                if (AndroidUtilities.isTablet()) {
                    width = AndroidUtilities.dp(490);
                } else {
                    width = AndroidUtilities.displaySize.x;
                }
                width = (int) (width - AndroidUtilities.dp(118 + 8 + 40 * (1.0f - diff))
                        - nameTextView[a].getTranslationX());
                float width2 = nameTextView[a].getPaint().measureText(nameTextView[a].getText().toString())
                        * nameTextView[a].getScaleX() + getSideDrawablesSize(nameTextView[a]);
                layoutParams = (FrameLayout.LayoutParams) nameTextView[a].getLayoutParams();
                if (width < width2) {
                    layoutParams.width = (int) Math.ceil(width / nameTextView[a].getScaleX());
                } else {
                    layoutParams.width = LayoutHelper.WRAP_CONTENT;
                }
                nameTextView[a].setLayoutParams(layoutParams);

                layoutParams = (FrameLayout.LayoutParams) onlineTextView[a].getLayoutParams();
                layoutParams.rightMargin = (int) Math.ceil(onlineTextView[a].getTranslationX()
                        + AndroidUtilities.dp(8) + AndroidUtilities.dp(40) * (1.0f - diff));
                onlineTextView[a].setLayoutParams(layoutParams);
            }
        }
    }
}

From source file:com.ruesga.timelinechart.TimelineChartView.java

private void setupAnimators() {
    // A zoom-in/zoom-out animator
    mZoomAnimator = ValueAnimator.ofFloat(1.f);
    mZoomAnimator.setDuration(350L);/*  w  w  w.j  a v  a 2 s .  c  o m*/
    mZoomAnimator.setInterpolator(new DecelerateInterpolator());
    mZoomAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mCurrentZoom = (Float) animation.getAnimatedValue();
            ViewCompat.postInvalidateOnAnimation(TimelineChartView.this);
        }
    });
    mZoomAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mInZoomOut) {
                // Swap temporary refs
                swapRefs();

                // Update the view, notify and end the animation
                Message.obtain(mUiHandler, MSG_UPDATE_COMPUTED_DATA, 1, 0).sendToTarget();
            } else {
                mState = STATE_IDLE;
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mState = STATE_IDLE;
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:org.telegram.ui.ProfileActivity.java

@Override
protected AnimatorSet onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) {
    if (playProfileAnimation && allowProfileAnimation) {
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(180);//  w ww .  j a v a2s. co  m
        if (Build.VERSION.SDK_INT > 15) {
            listView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
        ActionBarMenu menu = actionBar.createMenu();
        if (menu.getItem(10) == null) {
            if (animatingItem == null) {
                animatingItem = menu.addItem(10, R.drawable.ic_ab_other);
            }
        }
        if (isOpen) {
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) onlineTextView[1]
                    .getLayoutParams();
            layoutParams.rightMargin = (int) (-21 * AndroidUtilities.density + AndroidUtilities.dp(8));
            onlineTextView[1].setLayoutParams(layoutParams);

            int width = (int) Math.ceil(AndroidUtilities.displaySize.x - AndroidUtilities.dp(118 + 8)
                    + 21 * AndroidUtilities.density);
            float width2 = nameTextView[1].getPaint().measureText(nameTextView[1].getText().toString()) * 1.12f
                    + getSideDrawablesSize(nameTextView[1]);
            layoutParams = (FrameLayout.LayoutParams) nameTextView[1].getLayoutParams();
            if (width < width2) {
                layoutParams.width = (int) Math.ceil(width / 1.12f);
            } else {
                layoutParams.width = LayoutHelper.WRAP_CONTENT;
            }
            nameTextView[1].setLayoutParams(layoutParams);

            initialAnimationExtraHeight = AndroidUtilities.dp(88);
            fragmentView.setBackgroundColor(0);
            setAnimationProgress(0);
            ArrayList<Animator> animators = new ArrayList<>();
            animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 0.0f, 1.0f));
            if (writeButton != null) {
                writeButton.setScaleX(0.2f);
                writeButton.setScaleY(0.2f);
                writeButton.setAlpha(0.0f);
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
            }
            for (int a = 0; a < 2; a++) {
                onlineTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
                nameTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
                animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
                animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
            }
            if (animatingItem != null) {
                animatingItem.setAlpha(1.0f);
                animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 0.0f));
            }
            animatorSet.playTogether(animators);
        } else {
            initialAnimationExtraHeight = extraHeight;
            ArrayList<Animator> animators = new ArrayList<>();
            animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 1.0f, 0.0f));
            if (writeButton != null) {
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
            }
            for (int a = 0; a < 2; a++) {
                animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
                animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
            }
            if (animatingItem != null) {
                animatingItem.setAlpha(0.0f);
                animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 1.0f));
            }
            animatorSet.playTogether(animators);
        }
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (Build.VERSION.SDK_INT > 15) {
                    listView.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                if (animatingItem != null) {
                    ActionBarMenu menu = actionBar.createMenu();
                    menu.clearItems();
                    animatingItem = null;
                }
                callback.run();
            }
        });
        animatorSet.setInterpolator(new DecelerateInterpolator());

        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                animatorSet.start();
            }
        }, 50);
        return animatorSet;
    }
    return null;
}

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

private void updateRecordIntefrace() {
    if (recordingAudioVideo) {
        if (recordInterfaceState == 1) {
            return;
        }/*w w w  .  java 2s  . c  om*/
        recordInterfaceState = 1;
        try {
            if (wakeLock == null) {
                PowerManager pm = (PowerManager) ApplicationLoader.applicationContext
                        .getSystemService(Context.POWER_SERVICE);
                wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,
                        "audio record lock");
                wakeLock.acquire();
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        AndroidUtilities.lockOrientation(parentActivity);

        recordPanel.setVisibility(VISIBLE);
        recordCircle.setVisibility(VISIBLE);
        recordCircle.setAmplitude(0);
        recordTimeText.setText("00:00");
        recordDot.resetAlpha();
        lastTimeString = null;

        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
        params.leftMargin = AndroidUtilities.dp(30);
        slideText.setLayoutParams(params);
        slideText.setAlpha(1);
        recordPanel.setX(AndroidUtilities.displaySize.x);
        recordCircle.setTranslationX(0);
        if (runningAnimationAudio != null) {
            runningAnimationAudio.cancel();
        }
        runningAnimationAudio = new AnimatorSet();
        runningAnimationAudio.playTogether(ObjectAnimator.ofFloat(recordPanel, "translationX", 0),
                ObjectAnimator.ofFloat(recordCircle, "scale", 1),
                ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 0));
        runningAnimationAudio.setDuration(300);
        runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
                    recordPanel.setX(0);
                    runningAnimationAudio = null;
                }
            }
        });
        runningAnimationAudio.setInterpolator(new DecelerateInterpolator());
        runningAnimationAudio.start();
    } else {
        if (wakeLock != null) {
            try {
                wakeLock.release();
                wakeLock = null;
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        AndroidUtilities.unlockOrientation(parentActivity);
        if (recordInterfaceState == 0) {
            return;
        }
        recordInterfaceState = 0;

        if (runningAnimationAudio != null) {
            runningAnimationAudio.cancel();
        }
        runningAnimationAudio = new AnimatorSet();
        runningAnimationAudio.playTogether(
                ObjectAnimator.ofFloat(recordPanel, "translationX", AndroidUtilities.displaySize.x),
                ObjectAnimator.ofFloat(recordCircle, "scale", 0.0f),
                ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 1.0f));
        runningAnimationAudio.setDuration(300);
        runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
                    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
                    params.leftMargin = AndroidUtilities.dp(30);
                    slideText.setLayoutParams(params);
                    slideText.setAlpha(1);
                    recordPanel.setVisibility(GONE);
                    recordCircle.setVisibility(GONE);
                    runningAnimationAudio = null;
                }
            }
        });
        runningAnimationAudio.setInterpolator(new AccelerateInterpolator());
        runningAnimationAudio.start();
    }
}