Java Code Examples for com.actionbarsherlock.view.MenuItem#getSubMenu()

The following examples show how to use com.actionbarsherlock.view.MenuItem#getSubMenu() . 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: MenuBuilder.java    From android-apps with MIT License 6 votes vote down vote up
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 2
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 3
Source File: MenuBuilder.java    From zen4android with MIT License 6 votes vote down vote up
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 4
Source File: MenuBuilder.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 5
Source File: MenuBuilder.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 6
Source File: MenuBuilder.java    From zen4android with MIT License 5 votes vote down vote up
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
Example 7
Source File: ActionMenuPresenter.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
Example 8
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
Example 9
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
Example 10
Source File: ActionMenuPresenter.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
Example 11
Source File: MenuBuilder.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
Example 12
Source File: MenuBuilder.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
Example 13
Source File: ActionMenuPresenter.java    From zen4android with MIT License 5 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
Example 14
Source File: MenuBuilder.java    From zen4android with MIT License 5 votes vote down vote up
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
Example 15
Source File: ActionMenuPresenter.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
Example 16
Source File: MenuBuilder.java    From android-apps with MIT License 5 votes vote down vote up
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
Example 17
Source File: MenuBuilder.java    From android-apps with MIT License 5 votes vote down vote up
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
Example 18
Source File: ActionMenuPresenter.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
 
Example 19
Source File: MenuBuilder.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) close(true);
    } else if (item.hasSubMenu()) {
        close(false);

        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        final ActionProvider provider = item.getActionProvider();
        if (provider != null && provider.hasSubMenu()) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu);
        if (!invoked) close(true);
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }

    return invoked;
}
 
Example 20
Source File: MenuBuilder.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}