use of android.support.v7.widget.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();
}
use of android.support.v7.widget.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);
}
}
use of android.support.v7.widget.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);
}
}
use of android.support.v7.widget.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;
}
use of android.support.v7.widget.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);
}
Aggregations