public class

PopupToolbar

extends Object
java.lang.Object
   ↳ com.pspdfkit.ui.PopupToolbar
Known Direct Subclasses

Class Overview

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.

Summary

Nested Classes
interface PopupToolbar.OnPopupToolbarItemClickedListener Listener for menu item clicks. 
Fields
protected PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener Currently assigned popup toolbar menu item click listener (if any).
protected final PdfFragment pdfFragment Fragment on which the popup toolbar will be displayed.
protected final PopupWindow popupWindow Popup window in which the content will be displayed.
Public Constructors
PopupToolbar(PdfFragment pdfFragment)
Creates a popup toolbar on the given PdfFragment.
Public Methods
void dismiss()
Hides/dismisses the popup toolbar.
List<PopupToolbarMenuItem> getMenuItems()
Gets menu items currently displayed in this popup toolbar.
int getViewId()
Returns the id of the content view for this toolbar.
boolean isShowing()
Gets whether the popup toolbar is currently showing or not.
boolean onItemClicked(PopupToolbarMenuItem popupToolbarMenuItem)
Called when the menu item has been clicked.
void setMenuItems(List<PopupToolbarMenuItem> popupToolbarMenuItems)
Sets menu items to be displayed in this popup toolbar.
void setOnPopupToolbarItemClickedListener(PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener)
Sets the listener for popup toolbar menu item clicks.
void show(int pageIndex, float x, float y)
Show the popup toolbar at the specified page index with possible X and Y offsets.
void showAgain()
Show the popup toolbar with the parameters that were last used when calling show(int, float, float).
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener

Currently assigned popup toolbar menu item click listener (if any).

protected final PdfFragment pdfFragment

Fragment on which the popup toolbar will be displayed.

protected final PopupWindow popupWindow

Popup window in which the content will be displayed.

Public Constructors

public PopupToolbar (PdfFragment pdfFragment)

Creates a popup toolbar on the given PdfFragment. Use show(int, float, float) to display the toolbar.

Parameters
pdfFragment PDF fragment for which to create the popup toolbar.

Public Methods

public void dismiss ()

Hides/dismisses the popup toolbar.

public 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.

public int getViewId ()

Returns the id of the content view for this toolbar.

Returns
  • Toolbar's content view ID.

public boolean isShowing ()

Gets whether the popup toolbar is currently showing or not.

Returns
  • true if the toolbar is showing, false otherwise.

public boolean onItemClicked (PopupToolbarMenuItem popupToolbarMenuItem)

Called when the menu item has been clicked. When overriding this method, make sure you call `super()` so that the PopupToolbar.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.

public void setMenuItems (List<PopupToolbarMenuItem> popupToolbarMenuItems)

Sets menu items to be displayed in this popup toolbar.

Parameters
popupToolbarMenuItems List of menu items to display in the toolbar. The items will be displayed as ordered in the list.

public void setOnPopupToolbarItemClickedListener (PopupToolbar.OnPopupToolbarItemClickedListener onPopupToolbarItemClickedListener)

Sets the listener for popup toolbar menu item clicks.

Parameters
onPopupToolbarItemClickedListener Listener to be set.

public 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).

public void showAgain ()

Show the popup toolbar with the parameters that were last used when calling show(int, float, float). This is useful after dismiss() was called to temporarily hide the toolbar. If show(int, float, float) was never used before, this defaults to pageIndex 0 and coordinates 0,0.