Search in sources :

Example 11 with ActionProvider

use of android.view.ActionProvider in project XobotOS by xamarin.

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(android.view.ActionProvider) ViewGroup(android.view.ViewGroup)

Example 12 with ActionProvider

use of android.view.ActionProvider in project android_frameworks_base by ResurrectionRemix.

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);
}
Also used : MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) ActionProvider(android.view.ActionProvider) ViewGroup(android.view.ViewGroup) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Example 13 with ActionProvider

use of android.view.ActionProvider in project android_frameworks_base by crdroidandroid.

the class MenuBuilder method performItemAction.

public boolean performItemAction(MenuItem item, MenuPresenter preferredPresenter, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;
    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }
    boolean invoked = itemImpl.invoke();
    final ActionProvider provider = item.getActionProvider();
    final boolean providerHasSubMenu = provider != null && provider.hasSubMenu();
    if (itemImpl.hasCollapsibleActionView()) {
        invoked |= itemImpl.expandActionView();
        if (invoked) {
            close(true);
        }
    } else if (itemImpl.hasSubMenu() || providerHasSubMenu) {
        if (!itemImpl.hasSubMenu()) {
            itemImpl.setSubMenu(new SubMenuBuilder(getContext(), this, itemImpl));
        }
        final SubMenuBuilder subMenu = (SubMenuBuilder) itemImpl.getSubMenu();
        if (providerHasSubMenu) {
            provider.onPrepareSubMenu(subMenu);
        }
        invoked |= dispatchSubMenuSelected(subMenu, preferredPresenter);
        if (!invoked) {
            close(true);
        }
    } else {
        if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
            close(true);
        }
    }
    return invoked;
}
Also used : ActionProvider(android.view.ActionProvider)

Example 14 with ActionProvider

use of android.view.ActionProvider 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);
}
Also used : MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) ActionProvider(android.view.ActionProvider) ViewGroup(android.view.ViewGroup) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Example 15 with ActionProvider

use of android.view.ActionProvider in project CodenameOne by codenameone.

the class ShareCompatICS method configureMenuItem.

public static void configureMenuItem(MenuItem item, Activity callingActivity, Intent intent) {
    ActionProvider itemProvider = item.getActionProvider();
    ShareActionProvider provider = null;
    if (!(itemProvider instanceof ShareActionProvider)) {
        provider = new ShareActionProvider(callingActivity);
    } else {
        provider = (ShareActionProvider) itemProvider;
    }
    provider.setShareHistoryFileName(HISTORY_FILENAME_PREFIX + callingActivity.getClass().getName());
    provider.setShareIntent(intent);
    item.setActionProvider(provider);
}
Also used : ShareActionProvider(android.widget.ShareActionProvider) ActionProvider(android.view.ActionProvider) ShareActionProvider(android.widget.ShareActionProvider)

Aggregations

ActionProvider (android.view.ActionProvider)15 ViewGroup (android.view.ViewGroup)7 View (android.view.View)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 MenuItemImpl (com.android.internal.view.menu.MenuItemImpl)5 MenuView (com.android.internal.view.menu.MenuView)5 ShareActionProvider (android.widget.ShareActionProvider)2