List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:com.josecalles.porridge.widget.BottomSheet.java
@Override public void onStopNestedScroll(View child) { final int dragDisplacement = dragView.getTop() - dragViewTop; if (dragDisplacement == 0) return;// w w w. java 2s. c o m // check if we should perform a dismiss or settle back into place final boolean dismiss = lastNestedScrollWasDownward && dragDisplacement >= dragDismissDistance; // animate either back into place or to bottom ObjectAnimator settleAnim = ObjectAnimator.ofInt(dragViewOffsetHelper, ViewOffsetHelper.OFFSET_Y, dragView.getTop(), dismiss ? dragViewBottom : dragViewTop); settleAnim.setDuration(200L); settleAnim.setInterpolator( AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in)); if (dismiss) { settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchDismissCallback(); } }); } settleAnim.start(); }
From source file:uk.org.crimetalk.fragments.ArticleContentFragment.java
/** * Private method./*from w w w . j ava2s . com*/ * Returns an {@link android.animation.ObjectAnimator} that is used to * hide the {@link android.support.v7.widget.Toolbar}. * * @param view The {@link android.support.v7.widget.Toolbar} View * @return {@link android.animation.ObjectAnimator} */ private ObjectAnimator getHideAnimator(final View view) { final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", 0f, -view.getHeight()); objectAnimator.setDuration(ANIMATION_DURATION); objectAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { // Do nothing } @Override public void onAnimationEnd(Animator animator) { view.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animator) { // Do nothing } @Override public void onAnimationRepeat(Animator animator) { // Do nothing } }); return objectAnimator; }
From source file:uk.org.crimetalk.fragments.ArticleContentFragment.java
/** * Private method./*w w w .j a va2 s . co m*/ * Returns an {@link android.animation.ObjectAnimator} that is used to * show the {@link android.support.v7.widget.Toolbar}. * * @param view The {@link android.support.v7.widget.Toolbar} View * @return {@link android.animation.ObjectAnimator} */ private ObjectAnimator getShowAnimator(final View view) { final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", -view.getHeight(), 0f); objectAnimator.setDuration(ANIMATION_DURATION); objectAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { // Do nothing } @Override public void onAnimationCancel(Animator animator) { // Do nothing } @Override public void onAnimationRepeat(Animator animator) { // Do nothing } }); return objectAnimator; }
From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;//from w w w . jav a2s . c o m if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.lovejjfg.blogdemo.ui.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, long duration) { if (settling) return;/* w ww. jav a 2 s . c om*/ if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) return; settling = true; final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(getContext())); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (targetOffset == dismissOffset) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
private void closePhotoAndFinish() { mAnimationListener = new AnimatorListenerAdapter() { @Override/* w w w. j ava 2 s. c o m*/ public void onAnimationEnd(Animator animation) { // After the photo animates down, fade it away and finish. ObjectAnimator anim = ObjectAnimator.ofFloat(mPhotoView, "alpha", 0f) .setDuration(PHOTO_CONTRACT_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finishImmediatelyWithNoAnimation(); } }); anim.start(); } }; animatePhoto(mPhotoStartParams); animateAwayBackground(); }
From source file:com.example.tt.pullrefresh.widget.CurveLayout.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;//from w ww . ja v a2s .c o m Log.e(TAG, "animateSettle:TopAndBottom :::" + sheetOffsetHelper.getTopAndBottomOffset()); if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:io.plaidapp.ui.FilterAdapter.java
@Override public FilterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { final FilterViewHolder holder = new FilterViewHolder( LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.filter_item, viewGroup, false)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override/* w w w. ja v a2 s . co m*/ public void onClick(View v) { final int position = holder.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) return; final Source filter = filters.get(position); if (isAuthorisedDribbbleSource(filter) && !DribbblePrefs.get(holder.itemView.getContext()).isLoggedIn()) { authoriser.requestDribbbleAuthorisation(holder.filterIcon, filter); } else { holder.itemView.setHasTransientState(true); ObjectAnimator fade = ObjectAnimator.ofInt(holder.filterIcon, ViewUtils.IMAGE_ALPHA, filter.active ? FILTER_ICON_DISABLED_ALPHA : FILTER_ICON_ENABLED_ALPHA); fade.setDuration(300); fade.setInterpolator(AnimationUtils.loadInterpolator(holder.itemView.getContext(), android.R.interpolator.fast_out_slow_in)); fade.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.itemView.setHasTransientState(false); } }); fade.start(); filter.active = !filter.active; holder.filterName.setEnabled(filter.active); notifyItemChanged(position); SourceManager.updateSource(filter, holder.itemView.getContext()); dispatchFiltersChanged(filter); } } }); return holder; }
From source file:com.test.slidebutton.SlideButton.java
/** * max_leftmin_left// w ww . j a va 2s . co m * @param toRight */ private void moveTo(final boolean toRight) { ObjectAnimator anim = ObjectAnimator.ofInt(this, "sliderCurrentLeft", sliderCurrentLeft, toRight ? max_left : min_left); anim.setInterpolator(new OvershootInterpolator()); anim.setDuration(200); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) { listener.open(); } sliderCurrentLeft = sliderMoveStartLeft = max_left; } else { isOpen = false; if (listener != null) { listener.close(); } sliderCurrentLeft = sliderMoveStartLeft = min_left; } invalidateView(); } }); anim.start(); }
From source file:com.telenav.expandablepager.SlidingContainer.java
/** * Animate translationY to the next stopValue * @param amount translationY amount//from w w w . j a v a2 s . com * @param duration animation duration * @param interpolator animation interpolator */ private void animate(final float amount, int duration, Interpolator interpolator) { ObjectAnimator oa = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, amount).setDuration(duration); oa.setInterpolator(interpolator); oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { notifySlideEvent(Math.round(((Float) animation.getAnimatedValue()))); } }); oa.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { onSettled(stopValueIndex); } }); oa.start(); }