FlyoutController

public class FlyoutController extends Object

Provides control logic for the toolbox and trash in a workspace. Ensures the toolbox and trash block-list flyouts are populated, opened, and closed in coordination.

Field Summary

protected CategorySelectorUI.Callback mCategoriesCallback Callback for user category selection.
protected CategorySelectorUI mCategorySelectorUi The fragment for displaying toolbox categories.
protected BlocklyController mController Main controller for any actions that require wider state changes.
protected BlockListUI mToolbox The fragment for displaying blocks in the current category.
protected FlyoutCallback mToolboxCallback Callbacks for user actions on the toolbox's flyout.
protected boolean mToolboxIsCloseable Whether the toolbox is currently closeable, depending on configuration.
protected BlocklyCategory mToolboxRoot The root of the toolbox tree, containing either blocks or subcategories (not both).
protected FlyoutCallback mTrashCallback Callbacks for user actions on the trash's flyout.
protected BlocklyCategory mTrashCategory The category backing the trash's list of blocks.
protected View.OnClickListener mTrashClickListener Opens/closes the trash in response to clicks on the trash icon.
protected boolean mTrashIsCloseable Whether the trash is closeable, depending on configuration.
protected BlockListUI mTrashUi The UI for displaying blocks in the trash.

Public Constructor Summary

Public Method Summary

boolean
closeFlyouts()
Closes the trash and toolbox if they're open and closeable.
boolean
boolean
void
setToolboxRoot(BlocklyCategory root)
Sets the root of the toolbox tree.
void
setToolboxUiComponents(CategorySelectorUI categoryFragment, BlockListUI toolbox)
Sets the fragments used by a toolbox.
void
void
setTrashIcon(View trashIcon)
void

Inherited Method Summary

Fields

protected CategorySelectorUI.Callback mCategoriesCallback

Callback for user category selection.

protected CategorySelectorUI mCategorySelectorUi

The fragment for displaying toolbox categories.

protected BlocklyController mController

Main controller for any actions that require wider state changes.

protected BlockListUI mToolbox

The fragment for displaying blocks in the current category.

protected FlyoutCallback mToolboxCallback

Callbacks for user actions on the toolbox's flyout.

protected boolean mToolboxIsCloseable

Whether the toolbox is currently closeable, depending on configuration.

protected BlocklyCategory mToolboxRoot

The root of the toolbox tree, containing either blocks or subcategories (not both).

protected FlyoutCallback mTrashCallback

Callbacks for user actions on the trash's flyout.

protected BlocklyCategory mTrashCategory

The category backing the trash's list of blocks.

protected View.OnClickListener mTrashClickListener

Opens/closes the trash in response to clicks on the trash icon.

protected boolean mTrashIsCloseable

Whether the trash is closeable, depending on configuration.

protected BlockListUI mTrashUi

The UI for displaying blocks in the trash.

Public Constructors

public FlyoutController (BlocklyController controller)

Parameters
controller

Public Methods

public boolean closeFlyouts ()

Closes the trash and toolbox if they're open and closeable.

Returns
  • True if either flyout was closed, false otherwise.

public boolean isToolboxCloseable ()

Returns
  • True if the toolbox's flyout may be closed.

public boolean isTrashCloseable ()

Returns
  • True if the trash's flyout may be closed.

public void setToolboxRoot (BlocklyCategory root)

Sets the root of the toolbox tree. This will be used to populate the category and toolbox.

Parameters
root The root category for the toolbox.

public void setToolboxUiComponents (CategorySelectorUI categoryFragment, BlockListUI toolbox)

Sets the fragments used by a toolbox. At minimum a flyout is needed. If a category fragment is provided it will be used to switch between categories and open/close the flyout if it is closeable.

Parameters
categoryFragment The fragment for displaying category tabs.
toolbox The fragment for displaying blocks in a category.

public void setTrashContents (BlocklyCategory trashContents)

Parameters
trashContents The category with the set of blocks for display in the trash.

public void setTrashIcon (View trashIcon)

Parameters
trashIcon The view for toggling the trash.

public void setTrashUi (BlockListUI trashUi)

Parameters
trashUi The trash UI to use for displaying blocks in the trash.