Class PopupToolbar
-
- All Implemented Interfaces:
public class PopupToolbar
A class used for displaying a toolbar as a popup. It's a remake of a default Android text selection toolbar, where the items are displayed horizontally, with overflow button if there are items that don't fit the screen. Then once the overflow button is pressed, the toolbar displays other items vertically, with back button on the bottom to return to the main items.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
PopupToolbar.OnPopupToolbarItemClickedListener
Listener for menu item clicks.
-
Constructor Summary
Constructors Constructor Description PopupToolbar(PdfFragment pdfFragment)
Creates a popup toolbar on the given PdfFragment.
-
Method Summary
Modifier and Type Method Description int
getViewId()
Returns the id of the content view for this toolbar. void
setMenuItems(@NonNull() List<PopupToolbarMenuItem> popupToolbarMenuItems)
Sets menu items to be displayed in this popup toolbar. List<PopupToolbarMenuItem>
getMenuItems()
Gets menu items currently displayed in this popup toolbar. void
setOnPopupToolbarItemClickedListener(@Nullable() PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener)
Sets the listener for popup toolbar menu item clicks. void
showAgain()
Show the popup toolbar with the parameters that were last used when calling show. void
show(int pageIndex, float x, float y)
Show the popup toolbar at the specified page index with possible X and Y offsets. boolean
isShowing()
Gets whether the popup toolbar is currently showing or not. void
dismiss()
Hides/dismisses the popup toolbar. boolean
onItemClicked(@NonNull() PopupToolbarMenuItem popupToolbarMenuItem)
Called when the menu item has been clicked. -
-
Constructor Detail
-
PopupToolbar
PopupToolbar(PdfFragment pdfFragment)
Creates a popup toolbar on the given PdfFragment.- Parameters:
pdfFragment
- PDF fragment for which to create the popup toolbar.
-
-
Method Detail
-
getViewId
@IdRes() int getViewId()
Returns the id of the content view for this toolbar.
- Returns:
Toolbar's content view ID.
-
setMenuItems
void setMenuItems(@NonNull() List<PopupToolbarMenuItem> popupToolbarMenuItems)
Sets menu items to be displayed in this popup toolbar.
- Parameters:
popupToolbarMenuItems
- List of menu items to display in the toolbar.
-
getMenuItems
@NonNull() List<PopupToolbarMenuItem> getMenuItems()
Gets menu items currently displayed in this popup toolbar.
- Returns:
List of menu items to display in the toolbar. The items will be displayed as ordered in the list.
-
setOnPopupToolbarItemClickedListener
void setOnPopupToolbarItemClickedListener(@Nullable() PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener)
Sets the listener for popup toolbar menu item clicks.
- Parameters:
onPopupToolbarItemClickedListener
- Listener to be set.
-
showAgain
void showAgain()
Show the popup toolbar with the parameters that were last used when calling show. This is useful after dismiss was called to temporarily hide the toolbar. If show was never used before, this defaults to
pageIndex
0
and coordinates0,0
.
-
show
void show(int pageIndex, float x, float y)
Show the popup toolbar at the specified page index with possible X and Y offsets. Leaving offset parameters at 0, the toolbar will be displayed so that its center matched the given coordinate horizontally, and that bottom of the toolbar matches the coordinate vertically. Noticeably, all offsets are represented in PDF values.
- Parameters:
pageIndex
- Index of the page on which to show the toolbar.x
- X offset for the toolbar position (in PDF points).y
- Y offset for the toolbar position (in PDF points).
-
isShowing
boolean isShowing()
Gets whether the popup toolbar is currently showing or not.
- Returns:
true
if the toolbar is showing,false
otherwise.
-
dismiss
void dismiss()
Hides/dismisses the popup toolbar.
-
onItemClicked
boolean onItemClicked(@NonNull() PopupToolbarMenuItem popupToolbarMenuItem)
Called when the menu item has been clicked. When overriding this method, make sure you call `super()` so that the OnPopupToolbarItemClickedListener is invoked correctly.
- Parameters:
popupToolbarMenuItem
- Item that was clicked.- Returns:
true
to interrupt the callback,false
to let it go through and allow the default menu item click handling.
-
-
-
-