Search in sources :

Example 6 with ActionProvider

use of com.actionbarsherlock.view.ActionProvider in project Ushahidi_Android by ushahidi.

the class ActionMenuPresenter method updateMenuView.

@Override
public void updateMenuView(boolean cleared) {
    super.updateMenuView(cleared);
    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);
}
Also used : ActionProvider(com.actionbarsherlock.view.ActionProvider) ViewGroup(android.view.ViewGroup)

Example 7 with ActionProvider

use of com.actionbarsherlock.view.ActionProvider in project AndroidTraining by mixi-inc.

the class ActionMenuPresenter method updateMenuView.

@Override
public void updateMenuView(boolean cleared) {
    super.updateMenuView(cleared);
    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);
}
Also used : ActionProvider(com.actionbarsherlock.view.ActionProvider) ViewGroup(android.view.ViewGroup)

Aggregations

ViewGroup (android.view.ViewGroup)7 ActionProvider (com.actionbarsherlock.view.ActionProvider)7