當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。