Class ToolbarCoordinatorLayout
-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.ViewManager
,android.view.ViewParent
,android.view.accessibility.AccessibilityEventSource
,com.pspdfkit.ui.toolbar.ToolbarCoordinatorLayoutController
public class ToolbarCoordinatorLayout extends ViewGroup implements ToolbarCoordinatorLayoutController
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
ToolbarCoordinatorLayout.LayoutParams
Layout parameters for ContextualToolbars added to ToolbarCoordinatorLayout.
public interface
ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener
Listener for the lifecycle of the ContextualToolbar as it goes through the .
public interface
ToolbarCoordinatorLayout.OnContextualToolbarMovementListener
Listener for ContextualToolbar movements inside the ToolbarCoordinatorLayout.
public interface
ToolbarCoordinatorLayout.OnContextualToolbarPositionListener
Listener for ContextualToolbar position changes inside the .
-
Constructor Summary
Constructors Constructor Description ToolbarCoordinatorLayout(Context context)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr)
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
Method Summary
Modifier and Type Method Description void
toggleMainToolbarVisibility(boolean visible, long startDelayMs, long animationDurationMs)
Toggles the visibility of the main toolbar. int
getToolbarInset()
Calculates inset that should be applied on views under currently displayed toolbar to correctly inset their content below toolbar. void
setMainToolbarEnabled(boolean enabled)
Sets whether the main toolbar is enabled or not. void
setDragTargetColor(@ColorInt() int dragTargetColor)
Sets the color for possible position areas when the toolbar is being dragged. ContextualToolbar
getCurrentlyDisplayedContextualToolbar()
Gets the currently displayed contextual toolbar (if any). boolean
isDisplayingContextualToolbar()
Indicates whether the contextual toolbar is being currently displayed. void
displayContextualToolbar(@NonNull() ContextualToolbar toolbar, boolean animate)
Sets the contextual toolbar to be displayed in the coordinator. void
removeContextualToolbar(boolean animate)
Removes current contextual toolbar from the layout (if there is any). void
detachContextualToolbar()
Detach current contextual toolbar (if any) from the layout so it's able to move. void
attachContextualToolbar()
Attach current contextual toolbar (if any) to the layout so it's unable to move. void
onContextualToolbarPositionChanged(@NonNull() ContextualToolbar toolbar, @Nullable() ToolbarCoordinatorLayout.LayoutParams.Position oldPosition, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position newPosition)
Called when the ContextualToolbar position has changed. void
onContextualToolbarChanged(@NonNull() ContextualToolbar contextualToolbar)
Called when the ContextualToolbar menu items have changed internally. void
setOnContextualToolbarLifecycleListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener lifecycleListener)
Sets the listener for lifecycle changes of the ContextualToolbar as it goes through the ToolbarCoordinatorLayout - preparing, displaying, removing. void
setOnContextualToolbarMovementListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarMovementListener movementListener)
Sets the listener for ContextualToolbar movements within the layout. void
setOnContextualToolbarPositionListener(@Nullable() ToolbarCoordinatorLayout.OnContextualToolbarPositionListener positionListener)
Sets the listener for ContextualToolbar position within the layout. boolean
onInterceptTouchEvent(MotionEvent ev)
-
-
Constructor Detail
-
ToolbarCoordinatorLayout
ToolbarCoordinatorLayout(Context context)
-
ToolbarCoordinatorLayout
ToolbarCoordinatorLayout(Context context, AttributeSet attrs)
-
ToolbarCoordinatorLayout
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr)
-
ToolbarCoordinatorLayout
ToolbarCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
-
Method Detail
-
toggleMainToolbarVisibility
void toggleMainToolbarVisibility(boolean visible, long startDelayMs, long animationDurationMs)
Toggles the visibility of the main toolbar.
- Parameters:
visible
- Iftrue
, the toolbar will be shown.startDelayMs
- Delay after which the toolbar toggle will start (in ms).animationDurationMs
- Duration od the hide/show animation (in ms).
-
getToolbarInset
int getToolbarInset()
Calculates inset that should be applied on views under currently displayed toolbar to correctly inset their content below toolbar.
-
setMainToolbarEnabled
void setMainToolbarEnabled(boolean enabled)
Sets whether the main toolbar is enabled or not.
- Parameters:
enabled
-true
to make the main toolbar enabled,false
to disable.
-
setDragTargetColor
void setDragTargetColor(@ColorInt() 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.
-
getCurrentlyDisplayedContextualToolbar
@Nullable() ContextualToolbar getCurrentlyDisplayedContextualToolbar()
Gets the currently displayed contextual toolbar (if any).
- Returns:
Currently displayed contextual toolbar,
null
if none available.
-
isDisplayingContextualToolbar
boolean isDisplayingContextualToolbar()
Indicates whether the contextual toolbar is being currently displayed.
- Returns:
true
if contextual toolbar is currently being displayed,false
otherwise.
-
displayContextualToolbar
void displayContextualToolbar(@NonNull() 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.
-
removeContextualToolbar
void removeContextualToolbar(boolean animate)
Removes current contextual toolbar from the layout (if there is any).
- Parameters:
animate
-true
to animate toolbar removal,false
otherwise.
-
detachContextualToolbar
void detachContextualToolbar()
Detach current contextual toolbar (if any) from the layout so it's able to move.
-
attachContextualToolbar
void attachContextualToolbar()
Attach current contextual toolbar (if any) to the layout so it's unable to move.
-
onContextualToolbarPositionChanged
void onContextualToolbarPositionChanged(@NonNull() ContextualToolbar toolbar, @Nullable() ToolbarCoordinatorLayout.LayoutParams.Position oldPosition, @NonNull() ToolbarCoordinatorLayout.LayoutParams.Position newPosition)
Called when the ContextualToolbar position has changed.
- Parameters:
toolbar
- Toolbar which position has changed.oldPosition
- Old position, ornull
if toolbar has been just shown.newPosition
- New posiiton of the toolbar.
-
onContextualToolbarChanged
void onContextualToolbarChanged(@NonNull() ContextualToolbar contextualToolbar)
Called when the ContextualToolbar menu items have changed internally.
This will trigger a call to onPrepareContextualToolbar, giving users the chance to modify the toolbar - e.g. to apply a custom grouping rule or hide toolbar items.
-
setOnContextualToolbarLifecycleListener
void setOnContextualToolbarLifecycleListener(@Nullable() 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
- OnContextualToolbarLifecycleListener that should be notified, ornull
to clear the listener.
-
setOnContextualToolbarMovementListener
void setOnContextualToolbarMovementListener(@Nullable() 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
- OnContextualToolbarMovementListener that should be notified, ornull
to clear the listener.
-
setOnContextualToolbarPositionListener
void setOnContextualToolbarPositionListener(@Nullable() 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
- OnContextualToolbarPositionListener that should be notified, ornull
to clear the listener.
-
onInterceptTouchEvent
boolean onInterceptTouchEvent(MotionEvent ev)
-
-
-
-