VerticalBlockViewFactory

public class VerticalBlockViewFactory extends BlockViewFactory<BlockViewInputView>

Constructs Blockly's default, vertical stacking blocks and related views.

Field Summary

protected final String mMutatorAltText

Inherited Field Summary

Public Constructor Summary

VerticalBlockViewFactory(Context context, WorkspaceHelper helper)
VerticalBlockViewFactory(Context context, WorkspaceHelper helper, int workspaceTheme)

Public Method Summary

BlockGroup
buildBlockGroup()
Creates a new BlockGroup where the render order is reversed.
PatchManager
boolean
void
setMutatorToggleListener(BlockViewFactory.MutatorToggleListener listener)
Sets the listener to call when the user toggles a mutator.

Protected Method Summary

BlockView
FieldView
View
buildIconFieldView(View.OnClickListener listener, int resId)
View
InputView
buildInputView(Input input, List<FieldView> fieldViews)
View
buildMutatorFieldView(Block block)
Create a field view for a mutator's icon.
final int
getLayoutForField(int fieldType)
Gets the layout resource id for a given field type or 0 if none exist.
SpinnerAdapter
final void
setFieldLayout(int fieldType, int layoutResId)
Sets a layout to inflate for the given field type.

Inherited Method Summary

Fields

protected final String mMutatorAltText

Public Constructors

public VerticalBlockViewFactory (Context context, WorkspaceHelper helper)

Parameters
context
helper

public VerticalBlockViewFactory (Context context, WorkspaceHelper helper, int workspaceTheme)

Parameters
context The application or activity's Context.
helper The WorkspaceHelper associated with the workspace.
workspaceTheme The theme resource id for the block styles.

Public Methods

public BlockGroup buildBlockGroup ()

Creates a new BlockGroup where the render order is reversed. That is, for each BlockView, any next connected BlockView below it (if any) will render first. This ensures connector highlights will not be occluded.

Returns

public PatchManager getPatchManager ()

Returns

public boolean isBlockHatsEnabled ()

Returns
  • Whether blocks without previous or output should have a bump.

public void setMutatorToggleListener (BlockViewFactory.MutatorToggleListener listener)

Sets the listener to call when the user toggles a mutator. This is typically in response to a mutator button being tapped on a block.

Parameters
listener The listener to call when a user toggles a mutator.

Protected Methods

protected BlockView buildBlockView (Block block, List<InputView> inputViews, ConnectionManager connectionManager, BlockTouchHandler touchHandler)

Parameters
block The Block to build a view for.
inputViews The list of InputViews in this block.
connectionManager The ConnectionManager for the ERROR(/Workspace).
touchHandler The BlockTouchHandler this view should start with.
Returns

protected FieldView buildFieldView (Field field)

Parameters
field The Field to build a view for.
Returns

protected View buildIconFieldView (View.OnClickListener listener, int resId)

Parameters
listener
resId

protected View buildIconsView (Block block)

Parameters
block

protected InputView buildInputView (Input input, List<FieldView> fieldViews)

Parameters
input The Input to build a view for.
fieldViews The list of FieldViews in the constructed view.
Returns

protected View buildMutatorFieldView (Block block)

Create a field view for a mutator's icon. The default implementation just calls buildIconFieldView(View.OnClickListener, int) with a listener that toggles the mutator UI.

Parameters
block The block to to create the view for.
Returns

protected final int getLayoutForField (int fieldType)

Gets the layout resource id for a given field type or 0 if none exist.

Parameters
fieldType The field type to get a layout for.
Returns
  • The layout resource id or 0 if not found.

protected SpinnerAdapter getVariableAdapter ()

protected final void setFieldLayout (int fieldType, int layoutResId)

Sets a layout to inflate for the given field type. The layout file must contain a subclass of the appropriate field as its only top element. Setting the resource id to 0 will clear it.

Parameters
fieldType The type of field this layout should be used for.
layoutResId The layout resource id to inflate when creating views for this field type.