public class Main extends Activity implements ModuleListFragment.OnModuleSelectedListener, ButtonGridFragment.AnswerSelectedListener, ConfirmDeleteDialog.ConfirmDeleteDialogListener, ConfirmResetDialog.ConfirmResetDialogListener
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEVELOPER_MODE
Set to true to enable StrictMode testing
|
private ActionMode |
mActionMode
reference to the Activity's ActionMode, is null if the Activity is not in ActionMode
|
private ModuleListAdapter |
mAdapter
Adapter used by the Main Activity's ListView.
|
private Dialog |
mDialog
Dialog currently being shown or null if none.
|
private static java.util.List<Module> |
mModules
Lists all the Modules currently installed, used by the Main Activity's ListView
adapter.
|
private static java.lang.String |
PREFS_FIRSTLAUNCH
The index of the currently selected entry in the ModuleListFragment
|
static java.lang.String |
PREFS_NAME |
private java.util.List<Module> |
selection
when in ActionMode, this List contains all the Modules the user currently has
selected.
|
static java.lang.String |
SERVER_HOST
The server address to use for fetching remote data
|
static java.lang.String |
SERVER_PATH
The path on the server where the data can be found
|
static int |
SERVER_PORT
The server port to use for fetching remote data
|
static java.lang.String |
VERSION
Version string, only used in About dialog.
|
Constructor and Description |
---|
Main() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<Module> |
getModuleList()
Returns the value of
mModules . |
private void |
installDefaultModules()
Install the default module_*.json files from the assets.
|
private static java.util.List<Module> |
loadModulesList(Context ctx)
Loads all the locally installed modules, and returns them as a sorted list.
|
void |
onAnswerSelected(int position)
Defers click event on the ButtonGrid to the ExerciseFragment (tablets only)
|
void |
onClickPlay(View view)
Defers click event on Play button to the ExerciseFragment (tablets only)
|
protected void |
onCreate(Bundle savedInstanceState)
Loads saved state and preferences, installs default package of modules if this is the
first time the App runs, ties the volume controls to the media stream that we use
and sets up the context actionbar (CAB).
|
void |
onCreateContextMenu(ContextMenu menu,
View v,
ContextMenuInfo menuInfo) |
boolean |
onCreateOptionsMenu(Menu menu) |
void |
onDeleteAbort(DialogFragment dialog)
Handler for when the user aborts to delete the selected modules.
|
void |
onDeleteConfirm(DialogFragment dialog)
Handler for when user confirms to delete the selected modules.
|
void |
onModuleSelected(View view,
int position)
Listener for the attached ListView, handles item selection.
|
boolean |
onOptionsItemSelected(MenuItem item)
Implements the Manage and About Actionbar options.
|
void |
onPause()
Close any open Dialogs to prevent window leak.
|
void |
onResetAbort(DialogFragment dialog)
Handler for when the user aborts to reset the selected modules.
|
void |
onResetConfirm(DialogFragment dialog)
Handler for when user confirms to reset the selected modules.
|
protected void |
onSaveInstanceState(Bundle outState) |
static void |
refreshModuleList(Context ctx)
Refreshes
mModules to contain all the locally installed modules. |
public static final java.lang.String VERSION
public static final java.lang.String SERVER_HOST
public static final int SERVER_PORT
public static final java.lang.String SERVER_PATH
private static final boolean DEVELOPER_MODE
private static final java.lang.String PREFS_FIRSTLAUNCH
public static final java.lang.String PREFS_NAME
private ActionMode mActionMode
private java.util.List<Module> selection
private static java.util.List<Module> mModules
private ModuleListAdapter mAdapter
private Dialog mDialog
protected void onCreate(Bundle savedInstanceState)
savedInstanceState
- the previously saved instance state, can be null.public void onPause()
protected void onSaveInstanceState(Bundle outState)
public boolean onCreateOptionsMenu(Menu menu)
public boolean onOptionsItemSelected(MenuItem item)
item
- Menu item that was selectedpublic void onModuleSelected(View view, int position)
ExerciseActivity
Intent
with the position of the clicked item or updates the ExerciseFragment
to display the item at position.onModuleSelected
in interface ModuleListFragment.OnModuleSelectedListener
position
- Position of the list item that was clicked.private static java.util.List<Module> loadModulesList(Context ctx)
ctx
- The context used for the File functions and the Module constructor.public static void refreshModuleList(Context ctx)
mModules
to contain all the locally installed modules.
Invalidates the current adapter used for the ListView in Main
.ctx
- public static java.util.List<Module> getModuleList()
mModules
.mModules
.private void installDefaultModules()
public void onClickPlay(View view)
view
- The view that was clicked.public void onAnswerSelected(int position)
onAnswerSelected
in interface ButtonGridFragment.AnswerSelectedListener
position
- Position of the button that was clicked.public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
public void onDeleteConfirm(DialogFragment dialog)
ExerciseFragment
to display the
module at index 0 and display a Toast indicating the successful removal.onDeleteConfirm
in interface ConfirmDeleteDialog.ConfirmDeleteDialogListener
dialog
- The dialog that was clicked will be passed into the method.public void onDeleteAbort(DialogFragment dialog)
onDeleteAbort
in interface ConfirmDeleteDialog.ConfirmDeleteDialogListener
dialog
- The dialog that was clicked will be passed into the method.public void onResetConfirm(DialogFragment dialog)
ModuleListFragment
and ExerciseFragment
and displays a Toast indicating the successful history reset.onResetConfirm
in interface ConfirmResetDialog.ConfirmResetDialogListener
dialog
- The dialog that was clicked will be passed into the method.public void onResetAbort(DialogFragment dialog)
onResetAbort
in interface ConfirmResetDialog.ConfirmResetDialogListener
dialog
- The dialog that was clicked will be passed into the method.