List of usage examples for android.support.v4.view ViewPropertyAnimatorListenerAdapter ViewPropertyAnimatorListenerAdapter
ViewPropertyAnimatorListenerAdapter
From source file:android.support.design.widget.BaseTransientBottomBar.java
void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.setTranslationY(mView, mView.getHeight()); ViewCompat.animate(mView).translationY(0f).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override/*from ww w. ja v a 2s .c om*/ public void onAnimationStart(View view) { mContentViewCallback.animateContentIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(View view) { onViewShown(); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in); anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:android.support.v7.widget.ToolbarWidgetWrapper.java
@Override public ViewPropertyAnimatorCompat setupAnimatorToVisibility(final int visibility, final long duration) { return ViewCompat.animate(mToolbar).alpha(visibility == View.VISIBLE ? 1f : 0f).setDuration(duration) .setListener(new ViewPropertyAnimatorListenerAdapter() { private boolean mCanceled = false; @Override/* w ww . ja v a2 s. com*/ public void onAnimationStart(View view) { mToolbar.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { if (!mCanceled) { mToolbar.setVisibility(visibility); } } @Override public void onAnimationCancel(View view) { mCanceled = true; } }); }
From source file:xyz.berial.textinputlayout.TextInputLayout.java
/** * Sets an error message that will be displayed below our {@link EditText}. If the * {@code error} is {@code null}, the error message will be cleared. * <p/>//www . j av a2s.c o m * If the error functionality has not been enabled via {@link #setErrorEnabled(boolean)}, then * it will be automatically enabled if {@code error} is not empty. * * @param error Error message to display, or null to clear * @see #getError() */ public void setError(@Nullable CharSequence error) { if (!mErrorEnabled) { if (TextUtils.isEmpty(error)) { // If error isn't enabled, and the error is empty, just return return; } // Else, we'll assume that they want to enable the error functionality setErrorEnabled(true); } if (!TextUtils.isEmpty(error)) { ViewCompat.setAlpha(mErrorView, 0f); mErrorView.setText(error); ViewCompat.animate(mErrorView).alpha(1f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { view.setVisibility(VISIBLE); } }).start(); // Set the EditText's background tint to the error color ViewCompat.setBackgroundTintList(mEditText, ColorStateList.valueOf(mErrorView.getCurrentTextColor())); } else { if (mErrorView.getVisibility() == VISIBLE) { ViewCompat.animate(mErrorView).alpha(0f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { view.setVisibility(INVISIBLE); } }).start(); /*custom*/ if (mEditText.length() > mCounterMaxLength) { return; } /*custom*/ // Restore the 'original' tint, using colorControlNormal and colorControlActivated final TintManager tintManager = TintManager.get(getContext()); ViewCompat.setBackgroundTintList(mEditText, tintManager.getTintList(R.drawable.abc_edit_text_material)); } } sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); }
From source file:snackbar.MultilineSnackbar.java
private void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.setTranslationY(mView, mView.getHeight()); ViewCompat.animate(mView).translationY(0f) .setInterpolator(MultilineAnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override//from w w w .j av a 2s.c om public void onAnimationStart(View view) { if (!mAccessibilityManager.isEnabled()) { // Animating the children in causes Talkback to think that they're // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired. // Fixed by skipping the animation when an accessibility manager // is enabled mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } } @Override public void onAnimationEnd(View view) { onViewShown(); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in); anim.setInterpolator(MultilineAnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.ingenia.fasttrack.SnackBar.MultilineSnackbar.java
private void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.setTranslationY(mView, mView.getHeight()); ViewCompat.animate(mView).translationY(0f) .setInterpolator(com.ingenia.fasttrack.SnackBar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override/* ww w.j a v a 2 s. c om*/ public void onAnimationStart(View view) { if (!mAccessibilityManager.isEnabled()) { // Animating the children in causes Talkback to think that they're // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired. // Fixed by skipping the animation when an accessibility manager // is enabled mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } } @Override public void onAnimationEnd(View view) { onViewShown(); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), android.support.design.R.anim.design_snackbar_in); anim.setInterpolator(com.ingenia.fasttrack.SnackBar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.iw.flirten.snackbar.Snackbar.MultilineSnackbar.java
private void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.setTranslationY(mView, mView.getHeight()); ViewCompat.animate(mView).translationY(0f) .setInterpolator(com.iw.flirten.snackbar.Snackbar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override/*from www . j av a 2 s . co m*/ public void onAnimationStart(View view) { if (!mAccessibilityManager.isEnabled()) { // Animating the children in causes Talkback to think that they're // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired. // Fixed by skipping the animation when an accessibility manager // is enabled mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } } @Override public void onAnimationEnd(View view) { onViewShown(); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), android.support.design.R.anim.design_snackbar_in); anim.setInterpolator(com.iw.flirten.snackbar.Snackbar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.oginotihiro.snackbar.Snackbar.java
private void animateViewOut(final int event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewPropertyAnimatorCompat vpac = ViewCompat.animate(mView); if (mDirection == LEFT_RIGHT) { vpac.translationX(-mView.getWidth()); } else if (mDirection == TOP_BOTTOM) { vpac.translationY(-mView.getHeight()); } else if (mDirection == RIGHT_LEFT) { vpac.translationX(mView.getWidth()); } else if (mDirection == BOTTOM_TOP) { vpac.translationY(mView.getHeight()); }/*from ww w .j a va2 s . co m*/ vpac.setInterpolator(new FastOutSlowInInterpolator()).setDuration(mAnimDuration) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { mView.animateChildrenOut(0, mAnimFadeDuration); } @Override public void onAnimationEnd(View view) { onViewHidden(event); } }).start(); } else { Animation anim = null; if (mDirection == LEFT_RIGHT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_left_out); } else if (mDirection == TOP_BOTTOM) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_top_out); } else if (mDirection == RIGHT_LEFT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_right_out); } else if (mDirection == BOTTOM_TOP) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_bottom_out); } if (anim == null) return; anim.setInterpolator(new FastOutSlowInInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { onViewHidden(event); } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java
private void removeFabMenuItems() { if (touchGuard != null) touchGuard.setVisibility(GONE);//from w ww.j a v a2 s. co m ViewCompat.animate(menuItemsLayout) .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)).alpha(0f) .setInterpolator(new FastOutLinearInInterpolator()) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { super.onAnimationStart(view); isAnimating = true; } @Override public void onAnimationEnd(View view) { super.onAnimationEnd(view); menuItemsLayout.removeAllViews(); isAnimating = false; } }).start(); }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
@Override public void animateToVisibility(int visibility) { if (visibility == View.GONE) { ViewCompat.animate(mToolbar).alpha(0).setListener(new ViewPropertyAnimatorListenerAdapter() { private boolean mCanceled = false; @Override/*from w w w .j av a 2s . c o m*/ public void onAnimationEnd(View view) { if (!mCanceled) { mToolbar.setVisibility(View.GONE); } } @Override public void onAnimationCancel(View view) { mCanceled = true; } }); } else if (visibility == View.VISIBLE) { ViewCompat.animate(mToolbar).alpha(1).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { mToolbar.setVisibility(View.VISIBLE); } }); } }
From source file:com.linute.linute.UtilsAndHelpers.CustomSnackbar.java
private void animateViewIn() { ViewCompat.setTranslationY(mView, -mView.getHeight()); ViewCompat.animate(mView).translationY(0).setInterpolator(FAST_OUT_SLOW_IN).setDuration(ANIMATION_DURATION) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override/* ww w . j av a 2 s. c om*/ public void onAnimationStart(View view) { mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(View view) { if (mCallback != null) { mCallback.onShown(CustomSnackbar.this); } CustomSnackbarManager.getInstance().onShown(mManagerCallback); } }).start(); }