List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:org.telegram.ui.Components.ChatAttachAlert.java
@TargetApi(16) public void closeCamera(boolean animated) { if (takingPhoto || cameraView == null) { return;//from w w w. j a v a2s . c om } animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX; animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY; if (animated) { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) cameraView.getLayoutParams(); animateCameraValues[0] = layoutParams.topMargin = (int) cameraView.getTranslationY(); cameraView.setLayoutParams(layoutParams); cameraView.setTranslationY(0); cameraAnimationInProgress = true; ArrayList<Animator> animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f)); animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 0.0f)); for (int a = 0; a < 2; a++) { if (flashModeButton[a].getVisibility() == View.VISIBLE) { animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 0.0f)); break; } } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animator) { cameraAnimationInProgress = false; cameraPanel.setVisibility(View.GONE); cameraOpened = false; if (Build.VERSION.SDK_INT >= 21) { cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } } }); animatorSet.start(); } else { animateCameraValues[0] = 0; setCameraOpenProgress(0); cameraPanel.setAlpha(0); cameraPanel.setVisibility(View.GONE); for (int a = 0; a < 2; a++) { if (flashModeButton[a].getVisibility() == View.VISIBLE) { flashModeButton[a].setAlpha(0.0f); break; } } cameraOpened = false; if (Build.VERSION.SDK_INT >= 21) { cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } } }
From source file:com.rbware.github.androidcouchpotato.app.GuidedStepFragment.java
void runImeAnimations(boolean entering) { ArrayList<Animator> animators = new ArrayList<Animator>(); if (entering) { mGuidanceStylist.onImeAppearing(animators); mActionsStylist.onImeAppearing(animators); mButtonActionsStylist.onImeAppearing(animators); } else {//from w w w . j av a 2 s . co m mGuidanceStylist.onImeDisappearing(animators); mActionsStylist.onImeDisappearing(animators); mButtonActionsStylist.onImeDisappearing(animators); } AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.start(); }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
Animator animateFABActions(final boolean dismiss) { fabBackground.setVisibility(View.VISIBLE); Animator backgroundAnimator;// w ww .j a v a 2s . com if (Build.VERSION.SDK_INT >= 21) { Rect fabRect = new Rect(); fabAdd.getGlobalVisibleRect(fabRect); final Point realScreenSize = UIUtils.getRealScreenSize(); int radius = Math.max(realScreenSize.x, realScreenSize.y); backgroundAnimator = ViewAnimationUtils.createCircularReveal(fabBackground, fabRect.centerX(), fabRect.centerY(), dismiss ? radius : 0, dismiss ? 0 : radius); } else { backgroundAnimator = ObjectAnimator.ofFloat(fabBackground, "alpha", dismiss ? 1f : 0f, dismiss ? 0f : 1f); } backgroundAnimator.setDuration(300).setInterpolator(new AccelerateDecelerateInterpolator()); backgroundAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (dismiss) { fabBackground.setVisibility(View.GONE); // Tell them to swipe again for settings! showTutorialTip(TutorialTooltips.SWIPE_AGAIN); } else { // Tell them about search! showTutorialTip(TutorialTooltips.SEARCH); } } }); final long shortDelay = 50; final long longDelay = 100; final Animator createAnimator = animateFAB(fabCreate, dismiss); final Animator searchAnimator = animateFAB(fabSearch, dismiss); createAnimator.setStartDelay(dismiss ? longDelay : shortDelay); searchAnimator.setStartDelay(dismiss ? shortDelay : longDelay); AnimatorSet allAnimations = new AnimatorSet(); allAnimations.playTogether(backgroundAnimator, createAnimator, searchAnimator); return allAnimations; }
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
public void showTopView(boolean animated, final boolean openKeyboard) { if (topView == null || topViewShowed || getVisibility() != VISIBLE) { return;/*from w ww.jav a 2s . c o m*/ } needShowTopView = true; topViewShowed = true; if (allowShowTopView) { topView.setVisibility(VISIBLE); if (currentTopViewAnimation != null) { currentTopViewAnimation.cancel(); currentTopViewAnimation = null; } resizeForTopView(true); if (animated) { if (keyboardVisible || isPopupShowing()) { currentTopViewAnimation = new AnimatorSet(); currentTopViewAnimation.playTogether(ObjectAnimator.ofFloat(topView, "translationY", 0)); currentTopViewAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { if (recordedAudioPanel.getVisibility() != VISIBLE && (!forceShowSendButton || openKeyboard)) { openKeyboard(); } currentTopViewAnimation = null; } } @Override public void onAnimationCancel(Animator animation) { if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { currentTopViewAnimation = null; } } }); currentTopViewAnimation.setDuration(200); currentTopViewAnimation.start(); } else { topView.setTranslationY(0); if (recordedAudioPanel.getVisibility() != VISIBLE && (!forceShowSendButton || openKeyboard)) { openKeyboard(); } } } else { topView.setTranslationY(0); if (recordedAudioPanel.getVisibility() != VISIBLE && (!forceShowSendButton || openKeyboard)) { openKeyboard(); } } } }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void transitionOutLeftSection(boolean withAnim) { switch (mLeftActionMode) { case LEFT_ACTION_MODE_SHOW_HAMBURGER: closeMenuDrawable(mMenuBtnDrawable, withAnim); break;//from w ww.ja v a2 s . c o m case LEFT_ACTION_MODE_SHOW_SEARCH: changeIcon(mLeftAction, mIconSearch, withAnim); break; case LEFT_ACTION_MODE_SHOW_HOME: //do nothing break; case LEFT_ACTION_MODE_NO_LEFT_ACTION: mLeftAction.setImageDrawable(mIconBackArrow); if (withAnim) { ObjectAnimator searchInputTransXAnim = ViewPropertyObjectAnimator.animate(mSearchInputParent) .translationX(-Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START_DP)).get(); ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(0.5f).get(); ObjectAnimator scaleYArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleY(0.5f).get(); ObjectAnimator fadeArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(0.5f).get(); scaleXArrowAnim.setDuration(300); scaleYArrowAnim.setDuration(300); fadeArrowAnim.setDuration(300); scaleXArrowAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //restore normal state mLeftAction.setScaleX(1.0f); mLeftAction.setScaleY(1.0f); mLeftAction.setAlpha(1.0f); mLeftAction.setVisibility(View.INVISIBLE); } }); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(350); animSet.playTogether(scaleXArrowAnim, scaleYArrowAnim, fadeArrowAnim, searchInputTransXAnim); animSet.start(); } else { mLeftAction.setVisibility(View.INVISIBLE); } break; } }
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
public void showEditDoneProgress(final boolean show, boolean animated) { if (doneButtonAnimation != null) { doneButtonAnimation.cancel();/*from ww w.j a va 2 s . co m*/ } if (!animated) { if (show) { doneButtonImage.setScaleX(0.1f); doneButtonImage.setScaleY(0.1f); doneButtonImage.setAlpha(0.0f); doneButtonProgress.setScaleX(1.0f); doneButtonProgress.setScaleY(1.0f); doneButtonProgress.setAlpha(1.0f); doneButtonImage.setVisibility(View.INVISIBLE); doneButtonProgress.setVisibility(View.VISIBLE); doneButtonContainer.setEnabled(false); } else { doneButtonProgress.setScaleX(0.1f); doneButtonProgress.setScaleY(0.1f); doneButtonProgress.setAlpha(0.0f); doneButtonImage.setScaleX(1.0f); doneButtonImage.setScaleY(1.0f); doneButtonImage.setAlpha(1.0f); doneButtonImage.setVisibility(View.VISIBLE); doneButtonProgress.setVisibility(View.INVISIBLE); doneButtonContainer.setEnabled(true); } } else { doneButtonAnimation = new AnimatorSet(); if (show) { doneButtonProgress.setVisibility(View.VISIBLE); doneButtonContainer.setEnabled(false); doneButtonAnimation.playTogether(ObjectAnimator.ofFloat(doneButtonImage, "scaleX", 0.1f), ObjectAnimator.ofFloat(doneButtonImage, "scaleY", 0.1f), ObjectAnimator.ofFloat(doneButtonImage, "alpha", 0.0f), ObjectAnimator.ofFloat(doneButtonProgress, "scaleX", 1.0f), ObjectAnimator.ofFloat(doneButtonProgress, "scaleY", 1.0f), ObjectAnimator.ofFloat(doneButtonProgress, "alpha", 1.0f)); } else { doneButtonImage.setVisibility(View.VISIBLE); doneButtonContainer.setEnabled(true); doneButtonAnimation.playTogether(ObjectAnimator.ofFloat(doneButtonProgress, "scaleX", 0.1f), ObjectAnimator.ofFloat(doneButtonProgress, "scaleY", 0.1f), ObjectAnimator.ofFloat(doneButtonProgress, "alpha", 0.0f), ObjectAnimator.ofFloat(doneButtonImage, "scaleX", 1.0f), ObjectAnimator.ofFloat(doneButtonImage, "scaleY", 1.0f), ObjectAnimator.ofFloat(doneButtonImage, "alpha", 1.0f)); } doneButtonAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (doneButtonAnimation != null && doneButtonAnimation.equals(animation)) { if (!show) { doneButtonProgress.setVisibility(View.INVISIBLE); } else { doneButtonImage.setVisibility(View.INVISIBLE); } } } @Override public void onAnimationCancel(Animator animation) { if (doneButtonAnimation != null && doneButtonAnimation.equals(animation)) { doneButtonAnimation = null; } } }); doneButtonAnimation.setDuration(150); doneButtonAnimation.start(); } }
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
public void hideTopView(final boolean animated) { if (topView == null || !topViewShowed) { return;// ww w . j a va 2 s . c o m } topViewShowed = false; needShowTopView = false; if (allowShowTopView) { if (currentTopViewAnimation != null) { currentTopViewAnimation.cancel(); currentTopViewAnimation = null; } if (animated) { currentTopViewAnimation = new AnimatorSet(); currentTopViewAnimation.playTogether( ObjectAnimator.ofFloat(topView, "translationY", topView.getLayoutParams().height)); currentTopViewAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { topView.setVisibility(GONE); resizeForTopView(false); currentTopViewAnimation = null; } } @Override public void onAnimationCancel(Animator animation) { if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { currentTopViewAnimation = null; } } }); currentTopViewAnimation.setDuration(200); currentTopViewAnimation.start(); } else { topView.setVisibility(GONE); resizeForTopView(false); topView.setTranslationY(topView.getLayoutParams().height); } } }
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); }/* ww w. j av a 2s .c o 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:se.oort.clockify.widget.sgv.StaggeredGridView.java
/** * Performs layout animation of child views. * @throws IllegalStateException Exception is thrown of currently set animation mode is * not recognized./*from w w w . j ava2 s. co m*/ */ private void handleLayoutAnimation() throws IllegalStateException { final List<Animator> animators = new ArrayList<Animator>(); // b/8422632 - Without this dummy first animator, startDelays of subsequent animators won't // be honored correctly; all animators will block regardless of startDelay until the first // animator in the AnimatorSet truly starts playing. final ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); anim.setDuration(0); animators.add(anim); addOutAnimatorsForStaleViews(animators, mAnimationOutMode); // Play the In animators at a slight delay after all Out animators have started. final int animationInStartDelay = animators.size() > 0 ? (SgvAnimationHelper.getDefaultAnimationDuration() / 2) : 0; addInAnimators(animators, mAnimationInMode, animationInStartDelay); if (animators != null && animators.size() > 0) { final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mIsCurrentAnimationCanceled = false; mCurrentRunningAnimatorSet = animatorSet; } @Override public void onAnimationCancel(Animator animation) { mIsCurrentAnimationCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCurrentAnimationCanceled) { // If this animation ended naturally, not because it was canceled, then // reset the animation mode back to ANIMATION_MODE_NONE. However, if // the animation was canceled by a data change, then keep the mode as is, // so that on a re-layout, we can resume animation from the views' current // positions. resetAnimationMode(); } mCurrentRunningAnimatorSet = null; } }); Log.v(LOG_TAG, "starting"); animatorSet.start(); } else { resetAnimationMode(); } mViewsToAnimateOut.clear(); mChildRectsForAnimation.clear(); }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Performs layout animation of child views. * @throws IllegalStateException Exception is thrown of currently set animation mode is * not recognized.//from w ww. jav a2 s. c om */ private void handleLayoutAnimation() throws IllegalStateException { final List<Animator> animators = new ArrayList<Animator>(); // b/8422632 - Without this dummy first animator, startDelays of subsequent animators won't // be honored correctly; all animators will block regardless of startDelay until the first // animator in the AnimatorSet truly starts playing. final ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); anim.setDuration(0); animators.add(anim); addOutAnimatorsForStaleViews(animators, mAnimationOutMode); // Play the In animators at a slight delay after all Out animators have started. final int animationInStartDelay = animators.size() > 0 ? (SgvAnimationHelper.getDefaultAnimationDuration() / 2) : 0; addInAnimators(animators, mAnimationInMode, animationInStartDelay); if (animators != null && animators.size() > 0) { final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mIsCurrentAnimationCanceled = false; mCurrentRunningAnimatorSet = animatorSet; } @Override public void onAnimationCancel(Animator animation) { mIsCurrentAnimationCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCurrentAnimationCanceled) { // If this animation ended naturally, not because it was canceled, then // reset the animation mode back to ANIMATION_MODE_NONE. However, if // the animation was canceled by a data change, then keep the mode as is, // so that on a re-layout, we can resume animation from the views' current // positions. resetAnimationMode(); } mCurrentRunningAnimatorSet = null; } }); Log.v(TAG, "starting"); animatorSet.start(); } else { resetAnimationMode(); } mViewsToAnimateOut.clear(); mChildRectsForAnimation.clear(); }