本文整理汇总了Java中org.chromium.chrome.browser.preferences.ChromePreferenceManager.getNewTabPageFirstCardAnimationRunCount方法的典型用法代码示例。如果您正苦于以下问题:Java ChromePreferenceManager.getNewTabPageFirstCardAnimationRunCount方法的具体用法?Java ChromePreferenceManager.getNewTabPageFirstCardAnimationRunCount怎么用?Java ChromePreferenceManager.getNewTabPageFirstCardAnimationRunCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.chrome.browser.preferences.ChromePreferenceManager
的用法示例。
在下文中一共展示了ChromePreferenceManager.getNewTabPageFirstCardAnimationRunCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSnippetBound
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* To be triggered when a snippet is bound to a ViewHolder.
*/
public void onSnippetBound(View cardView) {
// We only run if the feature is enabled and once per NTP.
if (!SnippetsConfig.isIncreasedCardVisibilityEnabled() || mFirstCardAnimationRun) return;
mFirstCardAnimationRun = true;
// We only want an animation to run if we are not scrolled.
if (computeVerticalScrollOffset() != 0) return;
// We only show the animation a certain number of times to a user.
ChromePreferenceManager manager = ChromePreferenceManager.getInstance(getContext());
int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);
// We do not show the animation if the user has previously seen it then scrolled.
if (manager.getCardsImpressionAfterAnimation()) return;
// The peeking card bounces up twice from its position.
ObjectAnimator animator = ObjectAnimator.ofFloat(cardView, View.TRANSLATION_Y,
0f, -mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
animator.start();
}
示例2: onCardBound
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
@Override
public void onCardBound(CardViewHolder cardViewHolder) {
if (cardViewHolder.getAdapterPosition() == getNewTabPageAdapter().getFirstCardPosition()) {
updatePeekingCard(cardViewHolder);
} else {
cardViewHolder.setNotPeeking();
}
// Animate the peeking card.
// We only run if the feature is enabled and once per NTP.
if (!shouldAnimateFirstCard()) return;
mFirstCardAnimationRun = true;
// We only want an animation to run if we are not scrolled.
if (computeVerticalScrollOffset() != 0) return;
// We only show the animation a certain number of times to a user.
ChromePreferenceManager manager = ChromePreferenceManager.getInstance();
int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);
// We do not show the animation if the user has previously seen it then scrolled.
if (manager.getCardsImpressionAfterAnimation()) return;
// The peeking card bounces up twice from its position.
ObjectAnimator animator =
ObjectAnimator.ofFloat(cardViewHolder.itemView, View.TRANSLATION_Y, 0f,
-mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
animator.start();
}