List of usage examples for android.animation AnimatorSet addListener
public void addListener(AnimatorListener listener)
From source file:com.flexible.flexibleadapter.AnimatorAdapter.java
/** * Performs checks to scroll animate the itemView and in case, it animates the view. * <p><b>Note:</b> If you have to change at runtime the LayoutManager <i>and</i> add * Scrollable Headers too, consider to add them in post, using a {@code delay >= 0}, * otherwise scroll animations on all items will not start correctly.</p> * * @param holder the ViewHolder just bound * @param position the current item position *//* w w w . j a v a 2 s . c om*/ @SuppressWarnings("ConstantConditions") protected final void animateView(final RecyclerView.ViewHolder holder, final int position) { if (mRecyclerView == null) return; // Use always the max child count reached if (mMaxChildViews < mRecyclerView.getChildCount()) { mMaxChildViews = mRecyclerView.getChildCount(); } // Animate only during initial loading? if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) { shouldAnimate = false; } int lastVisiblePosition = Utils.findLastVisibleItemPosition(mRecyclerView.getLayoutManager()); // if (DEBUG) { // Log.v(TAG, "shouldAnimate=" + shouldAnimate // + " isFastScroll=" + isFastScroll // + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified() // + " isReverseEnabled=" + isReverseEnabled // + " mLastAnimatedPosition=" + mLastAnimatedPosition // + (!isReverseEnabled ? " Pos>LasVisPos=" + (position > lastVisiblePosition) : "") // + " mMaxChildViews=" + mMaxChildViews // ); // } if (holder instanceof FlexibleViewHolder && shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (position > lastVisiblePosition || isReverseEnabled || isScrollableHeaderOrFooter(position) || (position == 0 && mMaxChildViews == 0))) { // Cancel animation is necessary when fling int hashCode = holder.itemView.hashCode(); cancelExistingAnimation(hashCode); // User animators List<Animator> animators = new ArrayList<>(); FlexibleViewHolder flexibleViewHolder = (FlexibleViewHolder) holder; flexibleViewHolder.scrollAnimators(animators, position, position >= lastVisiblePosition); // Execute the animations together AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setInterpolator(mInterpolator); // Single view duration long duration = mDuration; for (Animator animator : animators) { if (animator.getDuration() != DEFAULT_DURATION) { duration = animator.getDuration(); } } //Log.v(TAG, "duration=" + duration); set.setDuration(duration); set.addListener(new HelperAnimatorListener(hashCode)); if (mEntryStep) { // Stop stepDelay when screen is filled set.setStartDelay(calculateAnimationDelay(position)); } set.start(); mAnimators.put(hashCode, set); if (DEBUG) Log.v(TAG, "animateView Scroll animation on position " + position); } mAnimatorNotifierObserver.clearNotified(); // Update last animated position mLastAnimatedPosition = position; }
From source file:babbq.com.searchplace.SearchActivity.java
@OnClick(R.id.results_scrim) protected void hideSaveConfimation() { if (confirmSaveContainer.getVisibility() == View.VISIBLE) { // contract the bubble & hide the scrim AnimatorSet hideConfirmation = new AnimatorSet(); hideConfirmation.playTogether(/* www .j a va 2s .c om*/ ViewAnimationUtils.createCircularReveal(confirmSaveContainer, confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2, confirmSaveContainer.getWidth() / 2, fab.getWidth() / 2), ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT)); hideConfirmation.setDuration(150L); hideConfirmation.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); hideConfirmation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { confirmSaveContainer.setVisibility(View.GONE); resultsScrim.setVisibility(View.GONE); // fab.setVisibility(results.getVisibility()); } }); hideConfirmation.start(); } }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
private void startOpenAnimation() { containerView.setVisibility(View.VISIBLE); if (!onCustomOpenAnimation()) { if (Build.VERSION.SDK_INT >= 20) { container.setLayerType(View.LAYER_TYPE_HARDWARE, null); }/* w ww .ja va 2s . c o m*/ containerView.setTranslationY(containerView.getMeasuredHeight()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0), ObjectAnimator.ofInt(backDrawable, "alpha", 51)); animatorSet.setDuration(200); animatorSet.setStartDelay(20); animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (delegate != null) { delegate.onOpenAnimationEnd(); } container.setLayerType(View.LAYER_TYPE_NONE, null); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; } }
From source file:kr.wdream.ui.ActionBar.BottomSheet.java
private void startOpenAnimation() { if (dismissed) { return;/*from ww w . ja v a2 s. c o m*/ } containerView.setVisibility(View.VISIBLE); if (!onCustomOpenAnimation()) { if (Build.VERSION.SDK_INT >= 20) { container.setLayerType(View.LAYER_TYPE_HARDWARE, null); } containerView.setTranslationY(containerView.getMeasuredHeight()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0), ObjectAnimator.ofInt(backDrawable, "alpha", 51)); animatorSet.setDuration(200); animatorSet.setStartDelay(20); animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (delegate != null) { delegate.onOpenAnimationEnd(); } container.setLayerType(View.LAYER_TYPE_NONE, null); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; } }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;//from www . j a v a 2 s . co m } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); 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; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } 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; }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;/*from w w w . ja v a2 s. co m*/ } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); 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; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { FileLog.e("messenger", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:com.tmall.wireless.tangram3.ext.SwipeItemTouchListener.java
private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge, final int direction) { if (enableAnim) { int contentWidth = recyclerView.getWidth(); AnimatorSet animatorSet = new AnimatorSet(); List<Animator> list = new ArrayList<>(); String translation = "translationX"; if (swipingType == SWIPING_VER) { translation = "translationY"; }// ww w. j a v a2 s . c o m for (View view : mChildList) { ObjectAnimator animator; if (reachActionEdge) { animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction) .setDuration(ANIMATE_DURATION); animator.setInterpolator(new AccelerateInterpolator()); } else { animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION); animator.setInterpolator(new DecelerateInterpolator()); } list.add(animator); } animatorSet.playTogether(list); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); } else { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } if (swipingType == SWIPING_VER) { if (pullFromEndListener != null) { if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) { pullFromEndListener.onAction(); } else { pullFromEndListener.onReset(); } } } swipeType = SWIPING_NONE; }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
private void startOpenAnimation() { containerView.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= 20) { container.setLayerType(View.LAYER_TYPE_HARDWARE, null); }/*from w w w. ja v a2 s. c o m*/ containerView.setTranslationY(containerView.getMeasuredHeight()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0), ObjectAnimator.ofInt(backDrawable, "alpha", 51)); animatorSet.setDuration(200); animatorSet.setStartDelay(20); animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; container.setLayerType(View.LAYER_TYPE_NONE, null); } } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:ir.besteveryeverapp.ui.Components.PasscodeView.java
private void processDone(boolean fingerprint) { if (!fingerprint) { String password = ""; if (UserConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (UserConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); }/* w ww . ja v a2 s. com*/ if (password.length() == 0) { onPasscodeError(); return; } if (!UserConfig.checkPasscode(password)) { passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether(ObjectAnimator.ofFloat(this, "translationY", AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, "alpha", AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); UserConfig.appLocked = false; UserConfig.saveConfig(false); NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }
From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java
@Override public Animator onAnimateChange(List<Object> payloads, int fromLeft, int fromTop, int fromRight, int fromBottom, long duration) { if (payloads == null || payloads.isEmpty() || !payloads.contains(ANIMATE_REPEAT_DAYS)) { return null; }/*w w w.j a v a 2 s. c om*/ final boolean isExpansion = repeatDays.getVisibility() == View.VISIBLE; final int height = repeatDays.getHeight(); setTranslationY(isExpansion ? -height : 0f, isExpansion ? -height : height); repeatDays.setVisibility(View.VISIBLE); repeatDays.setAlpha(isExpansion ? 0f : 1f); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom, itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()), ObjectAnimator.ofFloat(repeatDays, View.ALPHA, isExpansion ? 1f : 0f), ObjectAnimator.ofFloat(repeatDays, TRANSLATION_Y, isExpansion ? 0f : -height), ObjectAnimator.ofFloat(ringtone, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(vibrate, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(editLabel, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(preemptiveDismissButton, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(hairLine, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(delete, TRANSLATION_Y, 0f), ObjectAnimator.ofFloat(arrow, TRANSLATION_Y, 0f)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { setTranslationY(0f, 0f); repeatDays.setAlpha(1f); repeatDays.setVisibility(isExpansion ? View.VISIBLE : View.GONE); itemView.requestLayout(); } }); animatorSet.setDuration(duration); animatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); return animatorSet; }