Search in sources :

Example 1 with ActionMenuView

use of android.support.v7.internal.view.menu.ActionMenuView in project material by rey5137.

the class ToolbarManager method animateOut.

private void animateOut() {
    ActionMenuView menuView = getMenuView();
    int count = menuView == null ? 0 : menuView.getChildCount();
    Animation slowestAnimation = null;
    mAnimations.clear();
    mAnimations.ensureCapacity(count);
    for (int i = 0; i < count; i++) {
        View child = menuView.getChildAt(i);
        Animation anim = mAnimator.getOutAnimation(child, i);
        mAnimations.add(anim);
        if (anim != null)
            if (slowestAnimation == null || slowestAnimation.getStartOffset() + slowestAnimation.getDuration() < anim.getStartOffset() + anim.getDuration())
                slowestAnimation = anim;
    }
    if (slowestAnimation == null)
        mOutAnimationEndListener.onAnimationEnd(null);
    else {
        slowestAnimation.setAnimationListener(mOutAnimationEndListener);
        for (int i = 0; i < count; i++) {
            Animation anim = mAnimations.get(i);
            if (anim != null)
                menuView.getChildAt(i).startAnimation(anim);
        }
    }
    mAnimations.clear();
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ActionMenuView(android.support.v7.widget.ActionMenuView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 2 with ActionMenuView

use of android.support.v7.internal.view.menu.ActionMenuView in project LookLook by xinghongfei.

the class MainActivity method animateToolbar.

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;
        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX ¯\_(ツ)_/¯
        title.setAlpha(0f);
        title.setScaleX(0.8f);
        title.animate().alpha(1f).scaleX(1f).setStartDelay(500).setDuration(900).setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)).start();
    }
    View amv = toolbar.getChildAt(1);
    if (amv != null & amv instanceof ActionMenuView) {
        ActionMenuView actions = (ActionMenuView) amv;
        // filter
        popAnim(actions.getChildAt(0), 500, 200);
        // overflow
        popAnim(actions.getChildAt(1), 700, 200);
    }
}
Also used : TextView(android.widget.TextView) ActionMenuView(android.support.v7.widget.ActionMenuView) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView) TextView(android.widget.TextView)

Example 3 with ActionMenuView

use of android.support.v7.internal.view.menu.ActionMenuView in project sbt-android by scala-android.

the class HomeActivity method animateToolbar.

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;
        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX ¯\_(ツ)_/¯
        title.setAlpha(0f);
        title.setScaleX(0.8f);
        title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900).setInterpolator(AnimUtils.getMaterialInterpolator(this));
    }
    View amv = toolbar.getChildAt(1);
    if (amv != null & amv instanceof ActionMenuView) {
        ActionMenuView actions = (ActionMenuView) amv;
        // filter
        popAnim(actions.getChildAt(0), 500, 200);
        // overflow
        popAnim(actions.getChildAt(1), 700, 200);
    }
}
Also used : TextView(android.widget.TextView) ActionMenuView(android.widget.ActionMenuView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ActionMenuView(android.widget.ActionMenuView)

Example 4 with ActionMenuView

use of android.support.v7.internal.view.menu.ActionMenuView in project HoloEverywhere by Prototik.

the class ActionBarView method setMenu.

public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu) {
        return;
    }
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.FILL_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 5 with ActionMenuView

use of android.support.v7.internal.view.menu.ActionMenuView in project Shuttle by timusus.

the class AestheticCoordinatorLayout method tintMenu.

@SuppressWarnings("unchecked")
private static void tintMenu(@NonNull AestheticToolbar toolbar, @Nullable Menu menu, final ActiveInactiveColors colors) {
    if (toolbar.getNavigationIcon() != null) {
        toolbar.setNavigationIcon(toolbar.getNavigationIcon(), colors.activeColor());
    }
    Util.setOverflowButtonColor(toolbar, colors.activeColor());
    try {
        final Field field = Toolbar.class.getDeclaredField("mCollapseIcon");
        field.setAccessible(true);
        Drawable collapseIcon = (Drawable) field.get(toolbar);
        if (collapseIcon != null) {
            field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, colors.toEnabledSl()));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(colors.activeColor(), PorterDuff.Mode.SRC_IN);
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        final View v = toolbar.getChildAt(i);
        // We can't iterate through the toolbar.getMenu() here, because we need the ActionMenuItemView.
        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                    for (int k = 0; k < drawablesCount; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            ((ActionMenuItemView) innerView).getCompoundDrawables()[k].setColorFilter(colorFilter);
                        }
                    }
                }
            }
        }
    }
    if (menu == null) {
        menu = toolbar.getMenu();
    }
    ViewUtil.tintToolbarMenu(toolbar, menu, colors);
}
Also used : Field(java.lang.reflect.Field) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ActionMenuView(android.support.v7.widget.ActionMenuView) ActionMenuView(android.support.v7.widget.ActionMenuView) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView) View(android.view.View) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView)

Aggregations

View (android.view.View)12 ActionMenuView (android.support.v7.widget.ActionMenuView)10 RecyclerView (android.support.v7.widget.RecyclerView)4 ViewGroup (android.view.ViewGroup)4 TextView (android.widget.TextView)4 ActionMenuItemView (android.support.v7.view.menu.ActionMenuItemView)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 ActionMenuPresenter (android.support.v7.internal.view.menu.ActionMenuPresenter)2 ActionMenuView (android.support.v7.internal.view.menu.ActionMenuView)2 MenuBuilder (android.support.v7.internal.view.menu.MenuBuilder)2 Animation (android.view.animation.Animation)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 ImageView (android.widget.ImageView)2 BindView (butterknife.BindView)2 AccountManagerCallback (android.accounts.AccountManagerCallback)1 AccountManagerFuture (android.accounts.AccountManagerFuture)1 ObjectAnimator (android.animation.ObjectAnimator)1 SuppressLint (android.annotation.SuppressLint)1 SearchManager (android.app.SearchManager)1 Intent (android.content.Intent)1