PhoneTabSwitcherLayout.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:NeoTerm 作者:
/**
 * Creates and returns a layout listener, which allows to start a peek animation to add a tab,
 * once its view has been inflated.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, which should be added, as an instance of
 *         the class {@link TabItem}. The tab item may not be null
 * @param peekAnimation
 *         The peek animation, which should be started, as an instance of the class {@link
 *         PeekAnimation}. The peek animation may not be null
 * @return The listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The listener may not be null
 */
private OnGlobalLayoutListener createPeekLayoutListener(@NonNull final TabItem tabItem,
                                                        @NonNull final PeekAnimation peekAnimation) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            long totalDuration =
                    peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() :
                            peekAnimationDuration;
            long duration = totalDuration / 3;
            Interpolator interpolator =
                    peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() :
                            new AccelerateDecelerateInterpolator();
            float peekPosition =
                    getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false) * 0.66f;
            animatePeek(tabItem, duration, interpolator, peekPosition, peekAnimation);
        }

    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号