Search in sources :

Example 91 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project smartmodule by carozhu.

the class FloatingActionMenu method init.

private void init() {
    mOvershootInterpolator = new OvershootInterpolator();
    mAccelerateInterpolator = new AccelerateInterpolator();
    initCover();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator)

Example 92 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project android_frameworks_base by crdroidandroid.

the class PhoneStatusBar method setAreThereNotifications.

@Override
protected void setAreThereNotifications() {
    if (SPEW) {
        final boolean clearable = hasActiveNotifications() && hasActiveClearableNotifications();
        Log.d(TAG, "setAreThereNotifications: N=" + mNotificationData.getActiveNotifications().size() + " any=" + hasActiveNotifications() + " clearable=" + clearable);
    }
    final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out);
    final boolean showDot = hasActiveNotifications() && !areLightsOn();
    if (showDot != (nlo.getAlpha() == 1.0f)) {
        if (showDot) {
            nlo.setAlpha(0f);
            nlo.setVisibility(View.VISIBLE);
        }
        nlo.animate().alpha(showDot ? 1 : 0).setDuration(showDot ? 750 : 250).setInterpolator(new AccelerateInterpolator(2.0f)).setListener(showDot ? null : new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator _a) {
                nlo.setVisibility(View.GONE);
            }
        }).start();
    }
    findAndUpdateMediaNotifications();
}
Also used : Animator(android.animation.Animator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActivatableNotificationView(com.android.systemui.statusbar.ActivatableNotificationView) BatteryMeterView(com.android.systemui.BatteryMeterView) DismissView(com.android.systemui.statusbar.DismissView) NotificationBackgroundView(com.android.systemui.statusbar.NotificationBackgroundView) VisualizerView(com.android.systemui.statusbar.VisualizerView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) ImageView(android.widget.ImageView) BatteryLevelTextView(com.android.systemui.BatteryLevelTextView) BackDropView(com.android.systemui.statusbar.BackDropView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) EmptyShadeView(com.android.systemui.statusbar.EmptyShadeView) View(android.view.View) TextView(android.widget.TextView) ScrimView(com.android.systemui.statusbar.ScrimView)

Example 93 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project floatingsearchview by arimorty.

the class MenuView method hideIfRoomItems.

/**
 * Hides all the menu items flagged with "ifRoom"
 *
 * @param withAnim
 */
public void hideIfRoomItems(boolean withAnim) {
    if (mMenu == -1) {
        return;
    }
    mActionShowAlwaysItems.clear();
    cancelChildAnimListAndClear();
    List<MenuItemImpl> showAlwaysActionItems = filter(mMenuItems, new MenuItemImplPredicate() {

        @Override
        public boolean apply(MenuItemImpl menuItem) {
            return menuItem.getIcon() != null && menuItem.requiresActionButton();
        }
    });
    int actionItemIndex;
    for (actionItemIndex = 0; actionItemIndex < mActionItems.size() && actionItemIndex < showAlwaysActionItems.size(); actionItemIndex++) {
        final MenuItemImpl showAlwaysActionItem = showAlwaysActionItems.get(actionItemIndex);
        // reset action item image if needed
        if (mActionItems.get(actionItemIndex).getItemId() != showAlwaysActionItem.getItemId()) {
            ImageView action = (ImageView) getChildAt(actionItemIndex);
            action.setImageDrawable(showAlwaysActionItem.getIcon());
            Util.setIconColor(action, mOverflowIconColor);
            action.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (mMenuCallback != null) {
                        mMenuCallback.onMenuItemSelected(mMenuBuilder, showAlwaysActionItem);
                    }
                }
            });
        }
        mActionShowAlwaysItems.add(showAlwaysActionItem);
    }
    final int diff = mActionItems.size() - actionItemIndex + (mHasOverflow ? 1 : 0);
    anims = new ArrayList<>();
    // add anims for moving showAlwaysItem views to the right
    for (int i = 0; i < actionItemIndex; i++) {
        final View currentChild = getChildAt(i);
        final float destTransX = (ACTION_DIMENSION_PX * diff) - (mHasOverflow ? Util.dpToPx(8) : 0);
        anims.add(ViewPropertyObjectAnimator.animate(currentChild).setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0).setInterpolator(new AccelerateInterpolator()).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentChild.setTranslationX(destTransX);
            }
        }).translationXBy(destTransX).get());
    }
    // add anims for moving to right and/or zooming out previously shown items
    for (int i = actionItemIndex; i < (diff + actionItemIndex); i++) {
        final View currentView = getChildAt(i);
        currentView.setClickable(false);
        // move to right
        if (i != (getChildCount() - 1)) {
            anims.add(ViewPropertyObjectAnimator.animate(currentView).setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0).addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    currentView.setTranslationX(ACTION_DIMENSION_PX);
                }
            }).translationXBy(ACTION_DIMENSION_PX).get());
        }
        // scale and zoom out
        anims.add(ViewPropertyObjectAnimator.animate(currentView).setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setScaleX(0.5f);
            }
        }).scaleX(.5f).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView).setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setScaleY(0.5f);
            }
        }).scaleY(.5f).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView).setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setAlpha(0.0f);
            }
        }).alpha(0.0f).get());
    }
    final int actionItemsCount = actionItemIndex;
    // finally, run animation
    if (!anims.isEmpty()) {
        AnimatorSet animSet = new AnimatorSet();
        if (!withAnim) {
            // temporary, from laziness
            animSet.setDuration(0);
        }
        animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()]));
        animSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (mOnVisibleWidthChangedListener != null) {
                    mVisibleWidth = ((int) ACTION_DIMENSION_PX * actionItemsCount);
                    mOnVisibleWidthChangedListener.onItemsMenuVisibleWidthChanged(mVisibleWidth);
                }
            }
        });
        animSet.start();
    }
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyObjectAnimator(com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) View(android.view.View) MenuItemImpl(android.support.v7.view.menu.MenuItemImpl) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyObjectAnimator(com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ImageView(android.widget.ImageView)

Example 94 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project PreviewSeekBar by rubensousa.

the class PreviewAnimatorLollipopImpl method startUnreveal.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void startUnreveal() {
    Animator animator = ViewAnimationUtils.createCircularReveal(previewChildView, getCenterX(previewChildView), getCenterY(previewChildView), getRadius(previewChildView), morphView.getWidth() * 2);
    animator.setTarget(previewChildView);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            previewChildView.animate().setListener(null);
            frameView.setVisibility(View.INVISIBLE);
            previewChildView.setVisibility(View.INVISIBLE);
            morphView.setVisibility(View.VISIBLE);
            morphView.animate().y(getHideY()).scaleY(0.5f).scaleX(0.5f).setDuration(UNMORPH_MOVE_DURATION).setInterpolator(new AccelerateInterpolator()).setListener(hideListener);
        }
    });
    frameView.animate().alpha(1f).setDuration(UNMORPH_UNREVEAL_DURATION).setInterpolator(new AccelerateInterpolator());
    animator.setDuration(UNMORPH_UNREVEAL_DURATION).setInterpolator(new AccelerateInterpolator());
    animator.start();
}
Also used : Animator(android.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) TargetApi(android.annotation.TargetApi)

Example 95 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project AndriodDesignPattern by Shimingli.

the class StrategyModelFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    FivePriceStrategy fivePriceStrategy = new FivePriceStrategy();
    ContextPrice contextPrice = new ContextPrice(fivePriceStrategy);
    int i = contextPrice.setNewPrice(10);
    SevenPriceStrategy sevenPriceStrategy = new SevenPriceStrategy();
    contextPrice.setNewStrategy(sevenPriceStrategy);
    int i1 = contextPrice.setNewPrice(20);
    mTextView = (TextView) getView().findViewById(R.id.tvdes);
    final TextView viewById1 = (TextView) getView().findViewById(R.id.tv_text);
    mTextView.setText("第一种策略模式实现的价格:\n原价是10 减半后" + i + "\n" + "第二种策略模式实现的价格\n原价是20 7折后" + i1);
    // 时间差值器,也是策略模式
    final Button viewById = (Button) getView().findViewById(R.id.btn);
    viewById.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(viewById1, View.ALPHA, 0, 1);
            // 这里就相当于策略模式实现的
            // 加速
            objectAnimator.setInterpolator(new AccelerateInterpolator());
            // huilai
            objectAnimator.setInterpolator(new OvershootInterpolator());
            objectAnimator.start();
        }
    });
}
Also used : ContextPrice(com.shiming.andrioddesignpattern.strategy_model.ContextPrice) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) Button(android.widget.Button) ObjectAnimator(android.animation.ObjectAnimator) SevenPriceStrategy(com.shiming.andrioddesignpattern.strategy_model.SevenPriceStrategy) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) FivePriceStrategy(com.shiming.andrioddesignpattern.strategy_model.FivePriceStrategy)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8