public class

QuickMenuBuilder

extends Object
implements Menu SubMenu
java.lang.Object
   ↳ com.pdftron.pdf.tools.QuickMenuBuilder

Class Overview

A helper Menu class for constructing QuickMenu

Summary

[Expand]
Inherited Constants
From interface android.view.Menu
Public Constructors
QuickMenuBuilder(Context context, ToolManager toolManager, boolean annotationPermission)
Public Methods
MenuItem add(int groupId, int itemId, int order, CharSequence title)
Add a new item to the menu.
MenuItem add(int titleRes)
Add a new item to the menu.
MenuItem add(CharSequence title)
Add a new item to the menu.
MenuItem add(int groupId, int itemId, int order, int titleRes)
Variation on add(int, int, int, CharSequence) that takes a string resource identifier instead of the string itself.
SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title)
Add a new sub-menu to the menu.
SubMenu addSubMenu(int titleRes)
Add a new sub-menu to the menu.
SubMenu addSubMenu(CharSequence title)
Add a new sub-menu to the menu.
SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes)
Variation on addSubMenu(int, int, int, CharSequence) that takes a string resource identifier for the title instead of the string itself.
void clear()
Remove all existing items from the menu, leaving it empty as if it had just been created.
void close()
Same as clear()
MenuItem findItem(int id)
Return the menu item with a particular identifier.
MenuItem getItem(int index)
Gets the menu item at the given index.
MenuItem getItem()
Gets the MenuItem that represents this submenu in the parent menu.
ArrayList<QuickMenuItem> getMenuItems()
Gets menu items, it will remove items if menu item's sub menu list is empty
void removeGroup(int groupId)
Remove all items in the given group.
void removeItem(int id)
Remove the item with the given identifier.
void setParentMenuItem(QuickMenuItem item)
Sets parent item that represents this submenu in the parent.
int size()
Gets the number of items in the menu.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.view.Menu
From interface android.view.SubMenu

Public Constructors

public QuickMenuBuilder (Context context, ToolManager toolManager, boolean annotationPermission)

Public Methods

public MenuItem add (int groupId, int itemId, int order, CharSequence title)

Add a new item to the menu. This item displays the given title for its label.

Parameters
groupId The group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order.
title The text to display for the item.
Returns
  • The newly added menu item.

public MenuItem add (int titleRes)

Add a new item to the menu. This item displays the given title for its label.

Parameters
titleRes Resource identifier of title string.
Returns
  • The newly added menu item.

public MenuItem add (CharSequence title)

Add a new item to the menu. This item displays the given title for its label.

Parameters
title The text to display for the item.
Returns
  • The newly added menu item.

public MenuItem add (int groupId, int itemId, int order, int titleRes)

Variation on add(int, int, int, CharSequence) that takes a string resource identifier instead of the string itself.

Parameters
groupId The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order.
titleRes Resource identifier of title string.
Returns
  • The newly added menu item.

public SubMenu addSubMenu (int groupId, int itemId, int order, CharSequence title)

Add a new sub-menu to the menu. This item displays the given title for its label. To modify other attributes on the submenu's menu item, use getItem().

You can only have one level of sub-menus, i.e. you cannot add a subMenu to a subMenu. Exception will be thrown if you try.

Parameters
groupId The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order.
title The text to display for the item.
Returns
  • The newly added sub-menu

public SubMenu addSubMenu (int titleRes)

Add a new sub-menu to the menu. This item displays the given title for its label. To modify other attributes on the submenu's menu item, use getItem().

Parameters
titleRes Resource identifier of title string.
Returns
  • The newly added sub-menu

public SubMenu addSubMenu (CharSequence title)

Add a new sub-menu to the menu. This item displays the given title for its label. To modify other attributes on the submenu's menu item, use getItem().

Parameters
title The text to display for the item.
Returns
  • The newly added sub-menu

public SubMenu addSubMenu (int groupId, int itemId, int order, int titleRes)

Variation on addSubMenu(int, int, int, CharSequence) that takes a string resource identifier for the title instead of the string itself.

Parameters
groupId The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order.
titleRes Resource identifier of title string.
Returns
  • The newly added sub-menu

public void clear ()

Remove all existing items from the menu, leaving it empty as if it had just been created.

public void close ()

Same as clear()

public MenuItem findItem (int id)

Return the menu item with a particular identifier.

Parameters
id The identifier to find.
Returns
  • The menu item object, or null if there is no item with this identifier.

public MenuItem getItem (int index)

Gets the menu item at the given index.

Parameters
index The index of the menu item to return.
Returns
  • The menu item.
Throws
IndexOutOfBoundsException when index < 0 || >= size()

public MenuItem getItem ()

Gets the MenuItem that represents this submenu in the parent menu. Use this for setting additional item attributes.

Returns
  • The MenuItem that launches the submenu when invoked.

public ArrayList<QuickMenuItem> getMenuItems ()

Gets menu items, it will remove items if menu item's sub menu list is empty

Returns
  • list of valid quick menu items

public void removeGroup (int groupId)

Remove all items in the given group.

Parameters
groupId The group to be removed. If there are no items in this group, nothing happens.

public void removeItem (int id)

Remove the item with the given identifier.

Parameters
id The item to be removed. If there is no item with this identifier, nothing happens.

public void setParentMenuItem (QuickMenuItem item)

Sets parent item that represents this submenu in the parent. Use this for getItem()

Parameters
item parent menu item

public int size ()

Gets the number of items in the menu. Note that this will change any times items are added or removed from the menu.

Returns
  • The item count.