BlocklySectionsActivity

public abstract class BlocklySectionsActivity extends AbstractBlocklyActivity
implements AdapterView.OnItemClickListener

Activity holding a full-screen Blockly workspace with multiple sections in the navigation menu.

Field Summary

protected int mCurrentSection
protected ListAdapter mListAdapter
protected ListView mSectionsListView

Inherited Field Summary

Public Constructor Summary

Public Method Summary

final int
void
onItemClick(AdapterView<?> parent, View view, int position, long id)
Handles clicks to mSectionsListView by calling onSectionItemClicked(int) with the selected position.
void
onSectionItemClicked(int sectionIndex)
Handles the selection of a section, including closing the navigation drawer.

Protected Method Summary

int
CharSequence
void
onCreate(Bundle savedInstanceState)
Creates the activity's views and fragments (via onCreateActivityRootView(), and then initializes Blockly via onCreateActivityHelper(), using the values from getBlockDefinitionsJsonPaths() and getToolboxContentsXmlPath().
View
onCreateAppNavigationDrawer()
Creates mSectionsListView and configures it with onCreateSectionsListAdapter() to use as the activity's navigation menu.
abstract ListAdapter
onCreateSectionsListAdapter()
Populate the navigation menu with the list of available sections.
abstract boolean
onSectionChanged(int oldSection, int newSection)
Called to load a new Section.

Inherited Method Summary

Fields

protected int mCurrentSection

protected ListAdapter mListAdapter

protected ListView mSectionsListView

Public Constructors

public BlocklySectionsActivity ()

Public Methods

public final int getCurrentSectionIndex ()

Returns
  • The section that is currently displayed.

public void onItemClick (AdapterView<?> parent, View view, int position, long id)

Handles clicks to mSectionsListView by calling onSectionItemClicked(int) with the selected position.

Parameters
parent The ListView.
view The selected item view.
position The position in the list.
id The id of the list item.

public void onSectionItemClicked (int sectionIndex)

Handles the selection of a section, including closing the navigation drawer.

Protected Methods

protected int getSectionCount ()

Returns
  • The number of sections in this activity.

protected CharSequence getWorkspaceTitle ()

Returns
  • The title of the current workspace / section.

protected void onCreate (Bundle savedInstanceState)

Creates the activity's views and fragments (via onCreateActivityRootView(), and then initializes Blockly via onCreateActivityHelper(), using the values from getBlockDefinitionsJsonPaths() and getToolboxContentsXmlPath(). Subclasses should override those methods to configure the Blockly environment.

Once the controller and fragments are configured, if checkAllowRestoreBlocklyState(Bundle) returns true, the activity will attempt to load a prior workspace from the instance state bundle. If no workspace is loaded, it defers to onLoadInitialWorkspace().

Parameters
savedInstanceState

protected View onCreateAppNavigationDrawer ()

Creates mSectionsListView and configures it with onCreateSectionsListAdapter() to use as the activity's navigation menu.

Returns

protected abstract ListAdapter onCreateSectionsListAdapter ()

Populate the navigation menu with the list of available sections.

Returns
  • An adapter of sections for the navigation menu.

protected abstract boolean onSectionChanged (int oldSection, int newSection)

Called to load a new Section. If you don't want to re-use the previous section's code loadWorkspaceContents(InputStream) should be called here.

Parameters
oldSection The previous level.
newSection The level that was just configured.
Returns
  • True if the new section was successfully loaded. Otherwise false.