当前位置: 首页>>代码示例>>Java>>正文


Java Animator.getDuration方法代码示例

本文整理汇总了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;
	}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:72,代码来源:AnimatorAdapter.java


注:本文中的android.animation.Animator.getDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。