本文整理汇总了Java中android.animation.Animator.getDuration方法的典型用法代码示例。如果您正苦于以下问题:Java Animator.getDuration方法的具体用法?Java Animator.getDuration怎么用?Java Animator.getDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.Animator
的用法示例。
在下文中一共展示了Animator.getDuration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: animateView
import android.animation.Animator; //导入方法依赖的package包/类
/**
* 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
*/
@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;
}