BlockGroup

public class BlockGroup extends NonPropagatingViewGroup

This wraps a set of sequential BlockView instances.

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

BlockGroup(Context context, WorkspaceHelper helper)
Creates a BlockGroup to wrap one or more BlockViews.

Public Method Summary

void
addView(View child, int index, ViewGroup.LayoutParams params)
BlockGroup
extractBlocksAsNewGroup(Block firstBlock)
Move block views to a new block group, starting with the given block and continuing through its chain of next blocks.
Block
WorkspacePoint
BlockView
void
moveBlocksFrom(BlockGroup from, Block firstBlock)
Move block views into this group from the given group, starting with the given block and continuing through its chain of next blocks.
void
onMeasure(int widthSpec, int heightSpec)
void
setTouchHandler(BlockTouchHandler touchHandler)
Recursively sets the BlockTouchHandler for this view tree.
void
unlinkModel()
Recursively disconnects the model from view and unregisters and removes all views.
void
updateAllConnectorLocations()
Force every BlockView in this group to recalculate the locations of its connections; used to return the views and models to a consistent state after a drag.

Protected Method Summary

void
onLayout(boolean changed, int l, int t, int r, int b)

Inherited Method Summary

Public Constructors

public BlockGroup (Context context, WorkspaceHelper helper)

Creates a BlockGroup to wrap one or more BlockViews. App developers should not call this constructor directly. Instead, use buildBlockGroupTree(Block, ConnectionManager, BlockTouchHandler).

Parameters
context The context for creating this view.
helper The helper for loading workspace configs and doing calculations.

Public Methods

public void addView (View child, int index, ViewGroup.LayoutParams params)

Parameters
child
index
params

public BlockGroup extractBlocksAsNewGroup (Block firstBlock)

Move block views to a new block group, starting with the given block and continuing through its chain of next blocks.

Parameters
firstBlock The first Block to move to the new group.
Returns
  • A new BlockGroup containing blocks from the old group.

public Block getFirstBlock ()

Returns
  • The first block in this group, or null if this group is empty.

public WorkspacePoint getFirstBlockPosition ()

Returns
  • The workspace position of the top block in this group, or null if this group is empty.

public BlockView getFirstBlockView ()

Returns
  • The view for the first block in this group, or null if this group is empty.

public void moveBlocksFrom (BlockGroup from, Block firstBlock)

Move block views into this group from the given group, starting with the given block and continuing through its chain of next blocks.

Parameters
from The BlockGroup to move block views from.
firstBlock The first Block to move between groups.

public void onMeasure (int widthSpec, int heightSpec)

Parameters
widthSpec
heightSpec

public void setTouchHandler (BlockTouchHandler touchHandler)

Recursively sets the BlockTouchHandler for this view tree.

Parameters
touchHandler The new touch handler.

public void unlinkModel ()

Recursively disconnects the model from view and unregisters and removes all views.

public void updateAllConnectorLocations ()

Force every BlockView in this group to recalculate the locations of its connections; used to return the views and models to a consistent state after a drag.

Protected Methods

protected void onLayout (boolean changed, int l, int t, int r, int b)

Parameters
changed
l
t
r
b