use of com.android.internal.view.menu.MenuView in project android_frameworks_base by DirtyUnicorns.
the class ActionMenuPresenter method updateMenuView.
@Override
public void updateMenuView(boolean cleared) {
final ViewGroup menuViewParent = (ViewGroup) ((View) mMenuView).getParent();
if (menuViewParent != null && ACTIONBAR_ANIMATIONS_ENABLED) {
setupItemAnimations();
}
super.updateMenuView(cleared);
((View) mMenuView).requestLayout();
if (mMenu != null) {
final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
final int count = actionItems.size();
for (int i = 0; i < count; i++) {
final ActionProvider provider = actionItems.get(i).getActionProvider();
if (provider != null) {
provider.setSubUiVisibilityListener(this);
}
}
}
final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ? mMenu.getNonActionItems() : null;
boolean hasOverflow = false;
if (mReserveOverflow && nonActionItems != null) {
final int count = nonActionItems.size();
if (count == 1) {
hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
} else {
hasOverflow = count > 0;
}
}
if (hasOverflow) {
if (mOverflowButton == null) {
mOverflowButton = new OverflowMenuButton(mSystemContext);
}
ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
if (parent != mMenuView) {
if (parent != null) {
parent.removeView(mOverflowButton);
}
ActionMenuView menuView = (ActionMenuView) mMenuView;
menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
}
} else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
((ViewGroup) mMenuView).removeView(mOverflowButton);
}
((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
}
use of com.android.internal.view.menu.MenuView in project platform_frameworks_base by android.
the class ActionMenuPresenter method computeMenuItemAnimationInfo.
/**
* Store layout information about current items in the menu. This is stored for
* both pre- and post-layout phases and compared in runItemAnimations() to determine
* the animations that need to be run on any item changes.
*
* @param preLayout Whether this is being called in the pre-layout phase. This is passed
* into the MenuItemLayoutInfo structure to store the appropriate position values.
*/
private void computeMenuItemAnimationInfo(boolean preLayout) {
final ViewGroup menuView = (ViewGroup) mMenuView;
final int count = menuView.getChildCount();
SparseArray items = preLayout ? mPreLayoutItems : mPostLayoutItems;
for (int i = 0; i < count; ++i) {
View child = menuView.getChildAt(i);
final int id = child.getId();
if (id > 0 && child.getWidth() != 0 && child.getHeight() != 0) {
MenuItemLayoutInfo info = new MenuItemLayoutInfo(child, preLayout);
items.put(id, info);
}
}
}
use of com.android.internal.view.menu.MenuView in project platform_frameworks_base by android.
the class ActionMenuPresenter method updateMenuView.
@Override
public void updateMenuView(boolean cleared) {
final ViewGroup menuViewParent = (ViewGroup) ((View) mMenuView).getParent();
if (menuViewParent != null && ACTIONBAR_ANIMATIONS_ENABLED) {
setupItemAnimations();
}
super.updateMenuView(cleared);
((View) mMenuView).requestLayout();
if (mMenu != null) {
final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
final int count = actionItems.size();
for (int i = 0; i < count; i++) {
final ActionProvider provider = actionItems.get(i).getActionProvider();
if (provider != null) {
provider.setSubUiVisibilityListener(this);
}
}
}
final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ? mMenu.getNonActionItems() : null;
boolean hasOverflow = false;
if (mReserveOverflow && nonActionItems != null) {
final int count = nonActionItems.size();
if (count == 1) {
hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
} else {
hasOverflow = count > 0;
}
}
if (hasOverflow) {
if (mOverflowButton == null) {
mOverflowButton = new OverflowMenuButton(mSystemContext);
}
ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
if (parent != mMenuView) {
if (parent != null) {
parent.removeView(mOverflowButton);
}
ActionMenuView menuView = (ActionMenuView) mMenuView;
menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
}
} else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
((ViewGroup) mMenuView).removeView(mOverflowButton);
}
((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
}
use of com.android.internal.view.menu.MenuView in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindow method initializePanelContent.
/**
* Initializes the panel associated with the panel feature state. You must
* at the very least set PanelFeatureState.panel to the View implementing
* its contents. The default implementation gets the panel from the menu.
*
* @param st The panel state being initialized.
* @return Whether the initialization was successful.
*/
protected boolean initializePanelContent(PanelFeatureState st) {
if (st.createdPanelView != null) {
st.shownPanelView = st.createdPanelView;
return true;
}
if (st.menu == null) {
return false;
}
if (mPanelMenuPresenterCallback == null) {
mPanelMenuPresenterCallback = new PanelMenuPresenterCallback();
}
MenuView menuView = st.isInListMode() ? st.getListMenuView(getContext(), mPanelMenuPresenterCallback) : st.getIconMenuView(getContext(), mPanelMenuPresenterCallback);
st.shownPanelView = (View) menuView;
if (st.shownPanelView != null) {
// Use the menu View's default animations if it has any
final int defaultAnimations = menuView.getWindowAnimations();
if (defaultAnimations != 0) {
st.windowAnimations = defaultAnimations;
}
return true;
} else {
return false;
}
}
use of com.android.internal.view.menu.MenuView in project android_frameworks_base by AOSPA.
the class ActionMenuPresenter method getMenuView.
@Override
public MenuView getMenuView(ViewGroup root) {
MenuView oldMenuView = mMenuView;
MenuView result = super.getMenuView(root);
if (oldMenuView != result) {
((ActionMenuView) result).setPresenter(this);
if (oldMenuView != null) {
((View) oldMenuView).removeOnAttachStateChangeListener(mAttachStateChangeListener);
}
((View) result).addOnAttachStateChangeListener(mAttachStateChangeListener);
}
return result;
}
Aggregations