/**
* Animates the position and size of a specific tab in order to show the tab switcher.
*
* @param item
* The item, which corresponds to the tab, which should be animated, as an instance of
* the class {@link AbstractItem}. The item may not be null
* @param duration
* The duration of the animation in milliseconds as a {@link Long} value
* @param interpolator
* The interpolator, which should be used by the animation, as an instance of the type
* {@link Interpolator}. The interpolator may not be null
* @param listener
* The listener, which should be notified about the animation's progress, as an instance
* of the type {@link AnimatorListener} or null, if no listener should be notified
*/
private void animateShowSwitcher(@NonNull final AbstractItem item, final long duration,
@NonNull final Interpolator interpolator,
@Nullable final AnimatorListener listener) {
View view = item.getView();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
view.setX(layoutParams.leftMargin);
view.setY(layoutParams.topMargin);
getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
float scale = getArithmetics().getScale(item, true);
int selectedTabIndex = getModel().getSelectedTabIndex();
if (item.getIndex() < selectedTabIndex) {
getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
} else if (item.getIndex() > selectedTabIndex) {
getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
layoutParams.topMargin);
}
if (tabViewBottomMargin == -1) {
tabViewBottomMargin = calculateBottomMargin(item);
}
animateBottomMargin(view, tabViewBottomMargin, duration, 0);
ViewPropertyAnimator animation = view.animate();
animation.setDuration(duration);
animation.setInterpolator(interpolator);
animation.setListener(new AnimationListenerWrapper(listener));
getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale);
getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale);
getArithmetics()
.animatePosition(Axis.DRAGGING_AXIS, animation, item, item.getTag().getPosition(),
true);
getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item, 0, true);
animation.setStartDelay(0);
animation.start();
}
PhoneTabSwitcherLayout.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:ChromeLikeTabSwitcher
作者:
评论列表
文章目录