public BlocklyController build(){
  if (mViewFactory == null && (mWorkspaceFragment != null || mTrashFragment != null || mToolboxFragment != null || mToolboxDrawer != null)) {
    throw new IllegalStateException("BlockViewFactory cannot be null when using Fragments.");
  }
  if (mWorkspaceHelper == null) {
    mWorkspaceHelper=new WorkspaceHelper(mContext);
  }
  BlockFactory factory=new BlockFactory(mContext,null);
  for (int i=0; i < mBlockDefResources.size(); i++) {
    try {
      factory.addBlocks(mBlockDefResources.get(i));
    }
 catch (    Throwable e) {
      factory.clear();
      throw e;
    }
  }
  for (int i=0; i < mBlockDefAssets.size(); i++) {
    String assetPath=mBlockDefAssets.get(i);
    try {
      factory.addBlocks(mAssetManager.open(assetPath));
    }
 catch (    IOException e) {
      factory.clear();
      throw new IllegalStateException("Failed to load block definitions from asset: " + assetPath,e);
    }
  }
  for (int i=0; i < mBlockDefs.size(); i++) {
    factory.addBlockTemplate(mBlockDefs.get(i));
  }
  BlocklyController controller=new BlocklyController(mContext,factory,mWorkspaceHelper,mViewFactory);
  if (mToolboxResId != 0) {
    controller.loadToolboxContents(mToolboxResId);
  }
 else   if (mToolboxXml != null) {
    controller.loadToolboxContents(mToolboxXml);
  }
 else   if (mToolboxAssetId != null && mAssetManager != null) {
    try {
      controller.loadToolboxContents(mAssetManager.open(mToolboxAssetId));
    }
 catch (    IOException e) {
      throw new IllegalArgumentException("Failed to load toolbox from assets " + mToolboxAssetId,e);
    }
  }
  controller.setWorkspaceFragment(mWorkspaceFragment);
  controller.setTrashFragment(mTrashFragment);
  controller.setToolboxFragment(mToolboxFragment);
  controller.setTrashIcon(mTrashIcon);
  controller.setVariableCallback(mVariableCallback);
  return controller;
}

public BlocklyController build ( ) { if ( mViewFactory == null && ( mWorkspaceFragment != null || mTrashFragment != null || mToolboxFragment != null || mToolboxDrawer != null ) ) { throw new IllegalStateException ( "BlockViewFactory cannot be null when using Fragments." ) ; } if ( mWorkspaceHelper == null ) { mWorkspaceHelper = new WorkspaceHelper ( mContext ) ; } BlockFactory factory = new BlockFactory ( mContext , null ) ; for ( int i = 0 ; i < mBlockDefResources . size ( ) ; i ++ ) { try { factory . addBlocks ( mBlockDefResources . get ( i ) ) ; } catch ( Throwable e ) { factory . clear ( ) ; throw e ; } } for ( int i = 0 ; i < mBlockDefAssets . size ( ) ; i ++ ) { String assetPath = mBlockDefAssets . get ( i ) ; try { factory . addBlocks ( mAssetManager . open ( assetPath ) ) ; } catch ( IOException e ) { factory . clear ( ) ; throw new IllegalStateException ( "Failed to load block definitions from asset: " + assetPath , e ) ; } } for ( int i = 0 ; i < mBlockDefs . size ( ) ; i ++ ) { factory . addBlockTemplate ( mBlockDefs . get ( i ) ) ; } BlocklyController controller = new BlocklyController ( mContext , factory , mWorkspaceHelper , mViewFactory ) ; if ( mToolboxResId != 0 ) { controller . loadToolboxContents ( mToolboxResId ) ; } else if ( mToolboxXml != null ) { controller . loadToolboxContents ( mToolboxXml ) ; } else if ( mToolboxAssetId != null && mAssetManager != null ) { try { controller . loadToolboxContents ( mAssetManager . open ( mToolboxAssetId ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Failed to load toolbox from assets " + mToolboxAssetId , e ) ; } } controller . setWorkspaceFragment ( mWorkspaceFragment ) ; controller . setTrashFragment ( mTrashFragment ) ; controller . setToolboxFragment ( mToolboxFragment ) ; controller . setTrashIcon ( mTrashIcon ) ; controller . setVariableCallback ( mVariableCallback ) ; return controller ; }
create a new workspace using the configuration in this builder .
