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

The following examples show how to use com.actionbarsherlock.view.MenuItem#getActionProvider() . 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 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 2
Source File: ResultActivity.java    From ContentProviderHelper with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getSupportMenuInflater().inflate(R.menu.result_activity, menu);

	MenuItem item = menu.findItem(R.id.share);
	ShareActionProvider shareActionProvider = (ShareActionProvider) item.getActionProvider();

	Intent shareIntent = createShareIntent();
	shareActionProvider.setShareIntent(shareIntent);

	return super.onCreateOptionsMenu(menu);
}
 
Example 3
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 4
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 5
Source File: GalleryView.java    From Favorite-Android-Client with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

	MenuItem item;
	
  
if(edit_mode){
	menu.add(0, 1, 0, getString(R.string.ok)).setIcon(R.drawable.accept)
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}else{
	// Inflate your menu.
	getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);

	// Set file with share history to the provider and set the share intent.
	MenuItem actionItem = menu
			.findItem(R.id.menu_item_share_action_provider_action_bar);
	ShareActionProvider actionProvider = (ShareActionProvider) actionItem
			.getActionProvider();
	actionProvider
			.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
	// Note that you can set/change the intent any time,
	// say when the user has selected an image.
	actionProvider.setShareIntent(createShareIntent());
}

	return true;

}
 
Example 6
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 7
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 8
Source File: PostDetailFragment.java    From Broadsheet.ie-Android with MIT License 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    if (mPost != null) {

        inflater.inflate(R.menu.post_detail, menu);

        menu.findItem(R.id.menu_make_comment).setVisible(mPost.getComment_status().equals("open"));

        menu.findItem(R.id.menu_view_comments).setVisible((mPost.getComment_count() > 0));

        MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);

        mActionProvider = (ShareActionProvider) actionItem.getActionProvider();
        mActionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);

        mActionProvider.setShareIntent(createShareIntent());
    }
}