PdfFragmentToolbarBinder

Producer-side bridge between PdfFragment and a ToolbarCoordinator.

One instance per fragment. Call attach from Fragment.onViewCreated and detach from onDestroyView. After detach the binder holds no reference to the fragment — this is what makes the leak-free guarantee from loophole P0-3 enforceable at the fragment-flavor boundary.

Action-ID convention (ADR-Toolbar-4):

  • pspdf.undo / pspdf.redo for the undo manager.

  • pspdf.annotation.{tool} for annotation tools, where {tool} is the lowercase name of the AnnotationTool enum (e.g. pspdf.annotation.ink).

Items present in the coordinator with these action IDs are kept in sync with the fragment automatically. Items with other action IDs are untouched — they belong to the caller.

STATE-3 (Pre-Phase 0). Listener wiring is fragment-flavor only; the coordinator it talks to stays host-agnostic.

Constructors

Link copied to clipboard
constructor(coordinator: ToolbarCoordinator)

Types

Link copied to clipboard
object Companion

Action-ID constants and helpers shared by producers wiring items to this binder.

Functions

Link copied to clipboard
fun attach(fragment: PdfFragment)

Subscribe to fragment lifecycle and state events. Idempotent against the same fragment reference: calling attach twice without an intervening detach throws.

Link copied to clipboard
fun detach()

Release all listeners and the writer slot, clear the fragment reference. Idempotent — safe to call without a matching attach. Release on a non-active binder is a silent no-op at the coordinator level (e.g. when this binder already lost its slot to a concurrent attach on a sibling fragment).