Java Code Examples for android.view.View.animate()

The following are Jave code examples for showing how to use animate() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 8 votes
/**
 * Animates a tab to be swiped horizontally.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, which should be swiped, as an instance of
 *         the class {@link TabItem}. The tab item may not be null
 * @param targetPosition
 *         The position on the x-axis, the tab should be moved to, in pixels as a {@link Float}
 *         value
 * @param selected
 *         True, if the tab should become the selected one, false otherwise
 * @param animationDuration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param velocity
 *         The velocity of the drag gesture, which caused the tab to be swiped, in pixels per
 *         second as a {@link Float} value
 */
private void animateSwipe(@NonNull final TabItem tabItem, final float targetPosition,
                          final boolean selected, final long animationDuration,
                          final float velocity) {
    View view = tabItem.getView();
    float currentPosition = getArithmetics().getPosition(Axis.X_AXIS, tabItem);
    float distance = Math.abs(targetPosition - currentPosition);
    float maxDistance = getArithmetics().getSize(Axis.X_AXIS, tabItem) + swipedTabDistance;
    long duration = velocity > 0 ? Math.round((distance / velocity) * 1000) :
            Math.round(animationDuration * (distance / maxDistance));
    ViewPropertyAnimator animation = view.animate();
    animation.setListener(new AnimationListenerWrapper(
            selected ? createSwipeSelectedTabAnimationListener(tabItem) :
                    createSwipeNeighborAnimationListener(tabItem)));
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    animation.setDuration(duration);
    animation.setStartDelay(0);
    getArithmetics().animatePosition(Axis.X_AXIS, animation, tabItem, targetPosition, true);
    animation.start();
}
 
Example 2
Project: android_ui   File: SearchView.java   Source Code and License Vote up 7 votes
/**
 */
@Override
void hideProgressBar(SearchView searchView) {
	final CircularProgressBar progressBar = searchView.mProgressBar;
	final ViewPropertyAnimator progressBarAnimator = progressBar.animate();
	progressBarAnimator.setListener(null);
	progressBarAnimator.cancel();
	progressBarAnimator
			.alpha(0.0f)
			.setDuration(UiConfig.ANIMATION_DURATION_SHORT)
			.setListener(new AnimatorListenerAdapter() {
				@Override
				public void onAnimationEnd(Animator animation) {
					progressBar.setVisibility(View.INVISIBLE);
				}
			})
			.start();
	final View icon = searchView.mButtonIcon;
	final ViewPropertyAnimator iconAnimator = icon.animate();
	iconAnimator.setListener(null);
	iconAnimator.cancel();
	icon.setVisibility(View.VISIBLE);
	icon.setScaleX(0.5f);
	icon.setScaleY(0.5f);
	icon.setAlpha(0.0f);
	iconAnimator
			.scaleX(1.0f)
			.scaleY(1.0f)
			.alpha(1.0f)
			.setDuration(UiConfig.ANIMATION_DURATION_SHORT)
			.setInterpolator(iconInterpolator)
			.setListener(null)
			.start();
}
 
Example 3
Project: editor-sql   File: FeViewUtils.java   Source Code and License Vote up 7 votes
public static void listItemUpAnim(View view, int position,
                                  AnimatorListenerAdapter animatorListenerAdapter) {
    view.setTranslationY(150);
    view.setAlpha(0.f);
    ViewPropertyAnimator animate = view.animate();
    animate.translationY(0).alpha(1.f)
            .setStartDelay(20 * (position))
            .setInterpolator(new DecelerateInterpolator(2.f))
            .setDuration(400);

    if (animatorListenerAdapter != null) {
        animate.setListener(animatorListenerAdapter);
    }

    animate.withLayer().start();
}
 
Example 4
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 7 votes
/**
 * Starts a reveal animation to add a specific tab.
 *
 * @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 revealAnimation
 *         The reveal animation, which should be started, as an instance of the class {@link
 *         RevealAnimation}. The reveal animation may not be null
 */
private void animateReveal(@NonNull final TabItem tabItem,
                           @NonNull final RevealAnimation revealAnimation) {
    tabViewBottomMargin = -1;
    recyclerAdapter.clearCachedPreviews();
    dragHandler.setCallback(null);
    View view = tabItem.getView();
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(
            revealAnimation.getInterpolator() != null ? revealAnimation.getInterpolator() :
                    new AccelerateDecelerateInterpolator());
    animation.setListener(new AnimationListenerWrapper(createHideSwitcherAnimationListener()));
    animation.setStartDelay(0);
    animation.setDuration(revealAnimation.getDuration() != -1 ? revealAnimation.getDuration() :
            revealAnimationDuration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    animation.start();
    animateToolbarVisibility(getModel().areToolbarsShown() && getModel().isEmpty(), 0);
}
 
Example 5
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 7 votes
/**
 * Starts a reveal animation to add a specific tab.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @param revealAnimation
 *         The reveal animation, which should be started, as an instance of the class {@link
 *         RevealAnimation}. The reveal animation may not be null
 */
private void animateReveal(@NonNull final AbstractItem item,
                           @NonNull final RevealAnimation revealAnimation) {
    tabViewBottomMargin = -1;
    tabRecyclerAdapter.clearCachedPreviews();
    dragHandler.setCallback(null);
    View view = item.getView();
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(
            revealAnimation.getInterpolator() != null ? revealAnimation.getInterpolator() :
                    new AccelerateDecelerateInterpolator());
    animation.setListener(new AnimationListenerWrapper(createHideSwitcherAnimationListener()));
    animation.setStartDelay(0);
    animation.setDuration(revealAnimation.getDuration() != -1 ? revealAnimation.getDuration() :
            revealAnimationDuration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    animation.start();
    animateToolbarVisibility(getModel().areToolbarsShown() && getModel().isEmpty(), 0);
}
 
Example 6
Project: file.io-app   File: MaterialIn.java   Source Code and License Vote up 6 votes
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
    if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
        view.clearAnimation();
        view.animate().cancel();
        final Resources res = view.getResources();
        final float endAlpha = view.getAlpha();
        final float endTranslateX = view.getTranslationX();
        final float endTranslateY = view.getTranslationY();
        view.setAlpha(0);
        final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
        fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setStartDelay(delay);
        fade.start();
        ViewPropertyAnimator slide = view.animate();
        if (startOffsetY != 0) {
            view.setTranslationY(startOffsetY);
            slide.translationY(endTranslateY);
        } else {
            view.setTranslationX(startOffsetX);
            slide.translationX(endTranslateX);
        }
        slide.setInterpolator(new DecelerateInterpolator(2));
        slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
        slide.setStartDelay(delay);
        slide.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                if (fade.isStarted()) {
                    fade.cancel();
                }
                view.setAlpha(endAlpha);
                view.setTranslationX(endTranslateX);
                view.setTranslationY(endTranslateY);
            }
        });
        slide.start();
    }
}
 
Example 7
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Animates to rotation of all tabs to be reset to normal.
 *
 * @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 maxAngle
 *         The angle, the tabs may be rotated by at maximum, in degrees as a {@link Float}
 *         value
 * @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
 * @return True, if at least one tab was animated, false otherwise
 */
private boolean animateTilt(@NonNull final Interpolator interpolator, final float maxAngle,
                            @Nullable final AnimatorListener listener) {
    TabItemIterator iterator =
            new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).reverse(true).create();
    TabItem tabItem;
    boolean result = false;

    while ((tabItem = iterator.next()) != null) {
        if (tabItem.isInflated()) {
            View view = tabItem.getView();

            if (getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, view) != 0) {
                ViewPropertyAnimator animation = view.animate();
                animation.setListener(new AnimationListenerWrapper(
                        createRevertOvershootAnimationListener(view,
                                !result ? listener : null)));
                animation.setDuration(Math.round(revertOvershootAnimationDuration *
                        (Math.abs(getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, view)) /
                                maxAngle)));
                animation.setInterpolator(interpolator);
                getArithmetics().animateRotation(Axis.ORTHOGONAL_AXIS, animation, 0);
                animation.setStartDelay(0);
                animation.start();
                result = true;
            }
        }
    }

    return result;
}
 
Example 8
Project: chat-sdk-android-push-firebase   File: ChatSDKMessagesListAdapter.java   Source Code and License Vote up 6 votes
/**
 * Animating the sides of the row, For example animating the user profile image and the message date.
 * */
private void animateSides(View view, boolean fromLeft, Animation.AnimationListener animationListener){
    if (!isScrolling)
        return;

    if (fromLeft)
        view.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.expand_slide_form_left));
    else view.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.expand_slide_form_right));

    view.getAnimation().setAnimationListener(animationListener);
    view.animate();
}
 
Example 9
Project: chat-sdk-android-push-firebase   File: ChatSDKMessagesListAdapter.java   Source Code and License Vote up 6 votes
/**
 *  Animating the center part of the row, For example the image in an image message or the text in text message.
 * */
private void animateContent(View view, Animation.AnimationListener animationListener, boolean showFull){
    if (!isScrolling)
        return;

    view.setAnimation(AnimationUtils.loadAnimation(mActivity, showFull ? R.anim.fade_in_expand : R.anim.fade_in_half_and_expand));
    view.getAnimation().setAnimationListener(animationListener);
    view.animate();
}
 
Example 10
Project: DailyStudy   File: ViewPropertyAnimatorActivity.java   Source Code and License Vote up 6 votes
private void buildAndStartAnimation(View view) {
    ViewPropertyAnimator propertyAnimator = view.animate();
    propertyAnimator.alpha(0);
    propertyAnimator.scaleX(0).scaleY(0);
    propertyAnimator.setDuration(500l);
    propertyAnimator.setInterpolator(new LinearInterpolator());
    propertyAnimator.start();

}
 
Example 11
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Animates the position and size of a specific tab in order to hide 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 class
 *         {@link Interpolator}. The interpolator may not be null
 * @param delay
 *         The delay of the animation in milliseconds as a {@link Long} value
 * @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 animateHideSwitcher(@NonNull final AbstractItem item, final long duration,
                                 @NonNull final Interpolator interpolator, final long delay,
                                 @Nullable final AnimatorListener listener) {
    View view = item.getView();
    animateBottomMargin(view, -(tabInset + tabBorderWidth), duration, delay);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item,
            getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? layoutParams.topMargin :
                    0);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (item.getIndex() < selectedTabIndex) {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
    } else if (item.getIndex() > selectedTabIndex) {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    } else {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    }

    animation.setStartDelay(delay);
    animation.start();
}
 
Example 12
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Starts a peek animation to add a specific tab.
 *
 * @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 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 peekPosition
 *         The position on the dragging axis, the tab should be moved to, in pixels as a {@link
 *         Float} value
 * @param peekAnimation
 *         The peek animation, which has been used to add the tab, as an instance of the class
 *         {@link PeekAnimation}. The peek animation may not be null
 */
private void animatePeek(@NonNull final TabItem tabItem, final long duration,
                         @NonNull final Interpolator interpolator, final float peekPosition,
                         @NonNull final PeekAnimation peekAnimation) {
    PhoneTabViewHolder viewHolder = tabItem.getViewHolder();
    viewHolder.closeButton.setVisibility(View.GONE);
    View view = tabItem.getView();
    float x = peekAnimation.getX();
    float y = peekAnimation.getY() + tabTitleContainerHeight;
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setAlpha(1f);
    getArithmetics().setPivot(Axis.X_AXIS, view, x);
    getArithmetics().setPivot(Axis.Y_AXIS, view, y);
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 0);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(interpolator);
    animation.setListener(
            new AnimationListenerWrapper(createPeekAnimationListener(tabItem, peekAnimation)));
    animation.setStartDelay(0);
    animation.setDuration(duration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view, peekPosition, true);
    animation.start();
    int selectedTabIndex = getModel().getSelectedTabIndex();
    TabItem selectedTabItem = TabItem.create(getModel(), viewRecycler, selectedTabIndex);
    viewRecycler.inflate(selectedTabItem);
    selectedTabItem.getTag().setPosition(0);
    PhoneTabViewHolder selectedTabViewHolder = selectedTabItem.getViewHolder();
    selectedTabViewHolder.closeButton.setVisibility(View.GONE);
    animateShowSwitcher(selectedTabItem, duration, interpolator,
            createZoomOutAnimationListener(selectedTabItem, peekAnimation));
}
 
Example 13
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Animates to rotation of all tabs to be reset to normal.
 *
 * @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 maxAngle
 *         The angle, the tabs may be rotated by at maximum, in degrees as a {@link Float}
 *         value
 * @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
 * @return True, if at least one tab was animated, false otherwise
 */
private boolean animateTilt(@NonNull final Interpolator interpolator, final float maxAngle,
                            @Nullable final AnimatorListener listener) {
    ItemIterator iterator =
            new ItemIterator.Builder(getTabSwitcher(), tabViewRecycler).reverse(true).create();
    AbstractItem item;
    boolean result = false;

    while ((item = iterator.next()) != null) {
        if (item.isInflated() &&
                getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, item) != 0) {
            View view = item.getView();
            ViewPropertyAnimator animation = view.animate();
            animation.setListener(new AnimationListenerWrapper(
                    createRevertOvershootAnimationListener(item, !result ? listener : null)));
            animation.setDuration(Math.round(revertOvershootAnimationDuration *
                    (Math.abs(getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, item)) /
                            maxAngle)));
            animation.setInterpolator(interpolator);
            getArithmetics().animateRotation(Axis.ORTHOGONAL_AXIS, animation, 0);
            animation.setStartDelay(0);
            animation.start();
            result = true;
        }
    }

    return result;
}
 
Example 14
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Animates the position and size of a specific tab item in order to hide the tab switcher.
 *
 * @param tabItem
 *         The tab item, which should be animated, as an instance of the class {@link TabItem}.
 *         The tab 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 class
 *         {@link Interpolator}. The interpolator may not be null
 * @param delay
 *         The delay of the animation in milliseconds as a {@link Long} value
 * @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 animateHideSwitcher(@NonNull final TabItem tabItem, final long duration,
                                 @NonNull final Interpolator interpolator, final long delay,
                                 @Nullable final AnimatorListener listener) {
    View view = tabItem.getView();
    animateBottomMargin(view, -(tabInset + tabBorderWidth), duration, delay);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, view,
            getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? layoutParams.topMargin : 0,
            false);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (tabItem.getIndex() < selectedTabIndex) {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS), false);
    } else if (tabItem.getIndex() > selectedTabIndex) {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin, false);
    } else {
        getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin, false);
    }

    animation.setStartDelay(delay);
    animation.start();
}
 
Example 15
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Creates and returns an animation listener, which allows to hide a tab, which has been added
 * by using a peek animation, when the animation has been ended.
 *
 * @param item
 *         The item, which corresponds to the tab, which has been added by using the peek
 *         animation, as an instance of the class {@link AbstractItem}. The item may not be
 *         null
 * @param peekAnimation
 *         The peek animation 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
 * AnimatorListener}. The listener may not be null
 */
@NonNull
private AnimatorListener createPeekAnimationListener(@NonNull final AbstractItem item,
                                                     @NonNull final PeekAnimation peekAnimation) {
    return new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            super.onAnimationEnd(animation);
            long totalDuration =
                    peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() :
                            peekAnimationDuration;
            long duration = totalDuration / 3;
            Interpolator interpolator =
                    peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() :
                            new AccelerateDecelerateInterpolator();
            View view = item.getView();
            getArithmetics().setPivot(Axis.DRAGGING_AXIS, item, tabTitleContainerHeight);
            getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
                    getArithmetics().getSize(Axis.ORTHOGONAL_AXIS, item) / 2f);
            ViewPropertyAnimator animator = view.animate();
            animator.setDuration(duration);
            animator.setStartDelay(duration);
            animator.setInterpolator(interpolator);
            animator.setListener(
                    new AnimationListenerWrapper(createRevertPeekAnimationListener(item)));
            animator.alpha(0);
            getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animator, item,
                    getArithmetics().getPosition(Axis.DRAGGING_AXIS, item) * 1.5f);
            getArithmetics().animateScale(Axis.DRAGGING_AXIS, animator, 0);
            getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animator, 0);
            animator.start();
        }

    };
}
 
Example 16
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 5 votes
/**
 * Animates the position and size of a specific tab in order to show the tab switcher.
 *
 * @param tabItem
 *         The tab item, which should be animated, as an instance of the class {@link TabItem}.
 *         The tab 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 TabItem tabItem, final long duration,
                                 @NonNull final Interpolator interpolator,
                                 @Nullable final AnimatorListener listener) {
    View view = tabItem.getView();
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
    getArithmetics().setPivot(Axis.DRAGGING_AXIS, view,
            getArithmetics().getPivot(Axis.DRAGGING_AXIS, view, DragState.NONE));
    getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, view,
            getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, view, DragState.NONE));
    float scale = getArithmetics().getScale(view, true);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (tabItem.getIndex() < selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, view,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
    } else if (tabItem.getIndex() > selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, view,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    }

    if (tabViewBottomMargin == -1) {
        tabViewBottomMargin = calculateBottomMargin(view);
    }

    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, view,
            tabItem.getTag().getPosition(), true);
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, view, 0, true);
    animation.setStartDelay(0);
    animation.start();
}
 
Example 17
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 5 votes
/**
 * Animates the position of a specific tab item in order to relocate it.
 *
 * @param tabItem
 *         The tab item, which should be animated, as an instance of the class {@link TabItem}.
 *         The tab item may not be null
 * @param position
 *         The position, the tab should be relocated to, in pixels as a {@link Float} value
 * @param tag
 *         The tag, which should be applied to the given tab item, as an instance of the class
 *         {@link Tag} or null, if no tag should be applied
 * @param delay
 *         The delay of the relocate animation in milliseconds as a {@link Long} value
 * @param listener
 *         The listener, which should be notified about the progress of the relocate animation,
 *         as an instance of the type {@link AnimatorListener} or null, if no listener should be
 *         notified
 */
private void animateRelocate(@NonNull final TabItem tabItem, final float position,
                             @Nullable final Tag tag, final long delay,
                             @Nullable final AnimatorListener listener) {
    if (tag != null) {
        tabItem.getView().setTag(R.id.tag_properties, tag);
        tabItem.setTag(tag);
    }

    View view = tabItem.getView();
    ViewPropertyAnimator animation = view.animate();
    animation.setListener(new AnimationListenerWrapper(listener));
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    animation.setDuration(relocateAnimationDuration);
    getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view, position, true);
    animation.setStartDelay(delay);
    animation.start();
}
 
Example 18
Project: phonk   File: PAnimation.java   Source Code and License Vote up 5 votes
public PAnimation(View view) {
    mView = view;
    mAnim = view.animate();
}
 
Example 19
Project: exciting-app   File: ViewPropertyAnimatorICS.java   Source Code and License Vote up 5 votes
ViewPropertyAnimatorICS(View view) {
    mNative = new WeakReference<android.view.ViewPropertyAnimator>(view.animate());
}
 
Example 20
Project: boohee_v5.6   File: ViewPropertyAnimatorICS.java   Source Code and License Vote up 5 votes
ViewPropertyAnimatorICS(View view) {
    this.mNative = new WeakReference(view.animate());
}