android.support.v7.view.menu.MenuItemImpl Java Examples

The following examples show how to use android.support.v7.view.menu.MenuItemImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BottomNavigationMenuView.java    From MiPushFramework with GNU General Public License v3.0 6 votes vote down vote up
public void buildMenuView() {
    if (mButtons != null) {
        for (BottomNavigationItemView item : mButtons) {
            sItemPool.release(item);
        }
    }
    removeAllViews();
    mButtons = new BottomNavigationItemView[mMenu.size()];
    mShiftingMode = mMenu.size() > 3;
    for (int i = 0; i < mMenu.size(); i++) {
        mPresenter.setUpdateSuspended(true);
        mMenu.getItem(i).setCheckable(true);
        mPresenter.setUpdateSuspended(false);
        BottomNavigationItemView child = getNewItem();
        mButtons[i] = child;
        child.setIconTintList(mItemIconTint);
        child.setTextColor(mItemTextColor);
        child.setItemBackground(mItemBackgroundRes);
        child.setShiftingMode(mShiftingMode);
        child.initialize((MenuItemImpl) mMenu.getItem(i), 0);
        child.setItemPosition(i);
        child.setOnClickListener(mOnClickListener);
        addView(child);
    }
}
 
Example #2
Source File: ListItemView.java    From ListItemView with Apache License 2.0 5 votes vote down vote up
/**
 * Getter for action menu item.
 *
 * @return a menu item
 */
public MenuItemImpl findMenuItem(int menuId) {
    if (mMenuView == null || mMenuView.getMenuItems() == null) {
        return null;
    }
    for (MenuItemImpl item : mMenuView.getMenuItems()) {
        if (item.getItemId() == menuId) {
            return item;
        }
    }
    return null;
}
 
Example #3
Source File: MenuPopupHelper.java    From floatingsearchview with Apache License 2.0 5 votes vote down vote up
void findExpandedIndex() {
    final MenuItemImpl expandedItem = mMenu.getExpandedItem();
    if (expandedItem != null) {
        final ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
        final int count = items.size();
        for (int i = 0; i < count; i++) {
            final MenuItemImpl item = items.get(i);
            if (item == expandedItem) {
                mExpandedIndex = i;
                return;
            }
        }
    }
    mExpandedIndex = -1;
}
 
Example #4
Source File: MenuView.java    From ListItemView with Apache License 2.0 5 votes vote down vote up
private List<MenuItemImpl> filter(List<MenuItemImpl> target, MenuItemImplPredicate predicate) {
    List<MenuItemImpl> result = new ArrayList<>();
    for (MenuItemImpl element : target) {
        if (predicate.apply(element)) {
            result.add(element);
        }
    }
    return result;
}
 
Example #5
Source File: MenuPopupHelper.java    From floatingsearchview with Apache License 2.0 5 votes vote down vote up
public MenuItemImpl getItem(int position) {
    ArrayList<MenuItemImpl> items = mOverflowOnly ?
            mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
    if (mExpandedIndex >= 0 && position >= mExpandedIndex) {
        position++;
    }
    return items.get(position);
}
 
Example #6
Source File: MenuPopupHelper.java    From floatingsearchview with Apache License 2.0 5 votes vote down vote up
public int getCount() {
    ArrayList<MenuItemImpl> items = mOverflowOnly ?
            mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
    if (mExpandedIndex < 0) {
        return items.size();
    }
    return items.size() - 1;
}
 
Example #7
Source File: BottomNavigationItemView.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
    mItemData = itemData;
    setCheckable(itemData.isCheckable());
    setChecked(itemData.isChecked());
    setEnabled(itemData.isEnabled());
    setIcon(itemData.getIcon());
    setTitle(itemData.getTitle());
    setId(itemData.getItemId());
}
 
Example #8
Source File: BottomNavigationMenuView.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
public void updateMenuView() {
    final int menuSize = mMenu.size();
    if (menuSize != mButtons.length) {
        // The size has changed. Rebuild menu view from scratch.
        buildMenuView();
        return;
    }
    for (int i = 0; i < menuSize; i++) {
        mPresenter.setUpdateSuspended(true);
        mButtons[i].initialize((MenuItemImpl) mMenu.getItem(i), 0);
        mPresenter.setUpdateSuspended(false);
    }
}
 
Example #9
Source File: MenuView.java    From floatingsearchview with Apache License 2.0 5 votes vote down vote up
private List<MenuItemImpl> filter(List<MenuItemImpl> target, MenuItemImplPredicate predicate) {
    List<MenuItemImpl> result = new ArrayList<>();
    for (MenuItemImpl element : target) {
        if (predicate.apply(element)) {
            result.add(element);
        }
    }
    return result;
}
 
Example #10
Source File: MenuView.java    From ListItemView with Apache License 2.0 4 votes vote down vote up
public List<MenuItemImpl> getMenuItems() {
    return mMenuItems;
}
 
Example #11
Source File: MenuPopupHelper.java    From floatingsearchview with Apache License 2.0 4 votes vote down vote up
public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
    return false;
}
 
Example #12
Source File: MenuPopupHelper.java    From floatingsearchview with Apache License 2.0 4 votes vote down vote up
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
    return false;
}
 
Example #13
Source File: MenuView.java    From floatingsearchview with Apache License 2.0 4 votes vote down vote up
public List<MenuItemImpl> getCurrentMenuItems(){
    return mMenuItems;
}
 
Example #14
Source File: BottomNavigationItemView.java    From MiPushFramework with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MenuItemImpl getItemData() {
    return mItemData;
}
 
Example #15
Source File: BottomNavigationPresenter.java    From MiPushFramework with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
    return false;
}
 
Example #16
Source File: BottomNavigationPresenter.java    From MiPushFramework with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
    return false;
}
 
Example #17
Source File: FloatingSearchView.java    From floatingsearchview with Apache License 2.0 2 votes vote down vote up
/**
 * Provides clients access to the menu items
 *
 * @return
 */
public List<MenuItemImpl> getCurrentMenuItems(){
    return mMenuView.getCurrentMenuItems();
}
 
Example #18
Source File: MenuView.java    From floatingsearchview with Apache License 2.0 votes vote down vote up
boolean apply(MenuItemImpl menuItem); 
Example #19
Source File: MenuView.java    From ListItemView with Apache License 2.0 votes vote down vote up
boolean apply(MenuItemImpl menuItem);