public class

ToolbarCoordinatorLayout

extends ViewGroup
implements ToolbarCoordinatorLayoutController
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.pspdfkit.ui.toolbar.ToolbarCoordinatorLayout

Class Overview

This layout is responsible for handling toolbars. It is used in PdfActivity, but it can be added to any view group, for example to the root view of the custom activity.

Summary

Nested Classes
class ToolbarCoordinatorLayout.LayoutParams Layout parameters for ContextualToolbars added to ToolbarCoordinatorLayout
interface ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener Listener for the lifecycle of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout
interface ToolbarCoordinatorLayout.OnContextualToolbarMovementListener Listener for ContextualToolbar movements inside the ToolbarCoordinatorLayout
interface ToolbarCoordinatorLayout.OnContextualToolbarPositionListener Listener for ContextualToolbar position changes inside the ToolbarCoordinatorLayout
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ToolbarCoordinatorLayout(Context context)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void attachContextualToolbar()
Attach current contextual toolbar (if any) to the layout so it's unable to move.
void detachContextualToolbar()
Detach current contextual toolbar (if any) from the layout so it's able to move.
void displayContextualToolbar(ContextualToolbar toolbar, boolean animate)
Sets the contextual toolbar to be displayed in the coordinator.
ContextualToolbar getCurrentlyDisplayedContextualToolbar()
Gets the currently displayed contextual toolbar (if any).
boolean isDisplayingContextualToolbar()
Indicates whether the contextual toolbar is being currently displayed.
void onContextualToolbarChanged(ContextualToolbar contextualToolbar)
Called when the ContextualToolbar menu items have changed internally.
void onContextualToolbarPositionChanged(ContextualToolbar toolbar, ToolbarCoordinatorLayout.LayoutParams.Position oldPosition, ToolbarCoordinatorLayout.LayoutParams.Position newPosition)
Called when the ContextualToolbar position has changed.
boolean onInterceptTouchEvent(MotionEvent ev)
void removeContextualToolbar(boolean animate)
Removes current contextual toolbar from the layout (if there is any).
void setDragTargetColor(int dragTargetColor)
Sets the color for possible position areas when the toolbar is being dragged.
void setMainToolbarEnabled(boolean enabled)
Set whether the main toolbar is enabled or not.
void setOnContextualToolbarLifecycleListener(ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener)
Sets the listener for lifecycle changes of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout - preparing, displaying, removing.
void setOnContextualToolbarMovementListener(ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener)
Sets the listener for ContextualToolbar movements within the layout.
void setOnContextualToolbarPositionListener(ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener)
Sets the listener for ContextualToolbar position within the layout.
void toggleMainToolbarVisibility(boolean visible, long startDelayMs, long animationDurationMs)
Toggles the visibility of the main toolbar.
Protected Methods
void dispatchDraw(Canvas canvas)
boolean fitSystemWindows(Rect insets)
ViewGroup.LayoutParams generateDefaultLayoutParams()
void onLayout(boolean changed, int left, int top, int right, int bottom)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource
From interface com.pspdfkit.ui.toolbar.ToolbarCoordinatorLayoutController

Public Constructors

public ToolbarCoordinatorLayout (Context context)

public ToolbarCoordinatorLayout (Context context, AttributeSet attrs)

public ToolbarCoordinatorLayout (Context context, AttributeSet attrs, int defStyleAttr)

public ToolbarCoordinatorLayout (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public Methods

public void attachContextualToolbar ()

Attach current contextual toolbar (if any) to the layout so it's unable to move.

public void detachContextualToolbar ()

Detach current contextual toolbar (if any) from the layout so it's able to move.

public void displayContextualToolbar (ContextualToolbar toolbar, boolean animate)

Sets the contextual toolbar to be displayed in the coordinator. Only one contextual toolbar can be set, so if there is a previously added contextual toolbar, it will be removed.

Parameters
toolbar Toolbar to be set to the coordinator and displayed.
animate true to animate toolbar removal, false otherwise.

public ContextualToolbar getCurrentlyDisplayedContextualToolbar ()

Gets the currently displayed contextual toolbar (if any).

Returns
  • Currently displayed contextual toolbar, null if none available.

public boolean isDisplayingContextualToolbar ()

Indicates whether the contextual toolbar is being currently displayed.

Returns
  • true if contextual toolbar is currently being displayed, false otherwise.

public void onContextualToolbarChanged (ContextualToolbar contextualToolbar)

Called when the ContextualToolbar menu items have changed internally.

This will trigger a call to onPrepareContextualToolbar(ContextualToolbar), giving users the chance to modify the toolbar - e.g. to apply a custom grouping rule or hide toolbar items.

Parameters
contextualToolbar Toolbar that has changed.

public void onContextualToolbarPositionChanged (ContextualToolbar toolbar, ToolbarCoordinatorLayout.LayoutParams.Position oldPosition, ToolbarCoordinatorLayout.LayoutParams.Position newPosition)

Called when the ContextualToolbar position has changed.

Parameters
toolbar Toolbar which position has changed.
oldPosition Old position, or null if toolbar has been just shown.
newPosition New posiiton of the toolbar.

public boolean onInterceptTouchEvent (MotionEvent ev)

public void removeContextualToolbar (boolean animate)

Removes current contextual toolbar from the layout (if there is any).

Parameters
animate true to animate toolbar removal, false otherwise.

public void setDragTargetColor (int dragTargetColor)

Sets the color for possible position areas when the toolbar is being dragged.

Parameters
dragTargetColor Color of the possible targets when dragging the toolbar.

public void setMainToolbarEnabled (boolean enabled)

Set whether the main toolbar is enabled or not.

Parameters
enabled true to make the main toolbar enabled, false to disable.

public void setOnContextualToolbarLifecycleListener (ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener)

Sets the listener for lifecycle changes of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout - preparing, displaying, removing. Calling this method will replace any previously set listener. You may provide null to clear the listener.

Parameters
lifecycleListener ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener that should be notified, or null to clear the listener.

public void setOnContextualToolbarMovementListener (ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener)

Sets the listener for ContextualToolbar movements within the layout. Calling this method will replace any previously set listener. You may provide null to clear the listener.

Parameters
movementListener ToolbarCoordinatorLayout.OnContextualToolbarMovementListener that should be notified, or null to clear the listener.

public void setOnContextualToolbarPositionListener (ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener)

Sets the listener for ContextualToolbar position within the layout. Calling this method will replace any previously set listener. You may provide null to clear the listener.

Parameters
positionListener ToolbarCoordinatorLayout.OnContextualToolbarPositionListener that should be notified, or null to clear the listener.

public void toggleMainToolbarVisibility (boolean visible, long startDelayMs, long animationDurationMs)

Toggles the visibility of the main toolbar.

Parameters
visible If true, the toolbar will be shown. It'll be hidden otherwise.
startDelayMs Delay after which the toolbar toggle will start (in ms).
animationDurationMs Duration od the hide/show animation (in ms).

Protected Methods

protected void dispatchDraw (Canvas canvas)

protected boolean fitSystemWindows (Rect insets)

protected ViewGroup.LayoutParams generateDefaultLayoutParams ()

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)