@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; case R.id.input_history_relaunch: MessageHelper.showOptionsDialog( currentActivity, "Do you want to launch the workflow again ?", null, new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { SystemStatesChecker sysChecker = new SystemStatesChecker(currentActivity); if (!(sysChecker.isNetworkConnected())) { return true; } WorkflowLaunchHelper launchHelper = new WorkflowLaunchHelper(currentActivity, Activity_Starter_Code); launchHelper.launch(workflowEntity, 0); return null; } @Override public Object onTaskComplete(Object... result) { return null; } }, null); return true; default: return super.onOptionsItemSelected(item); } }
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.input_history_launch: MessageHelper.showOptionsDialog( currentActivity, "Launch the workflow with selected inputs ?", "Alert", new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { // set input history files path of the workflow entity // which will be used to load previous inputs List<String> paths = new ArrayList<String>(); for (File f : selectedInputs) { paths.add(f.getAbsolutePath()); } workflowEntity.setSavedInputsFilesPath(paths); WorkflowLaunchHelper launchHelper = new WorkflowLaunchHelper(currentActivity, Activity_Starter_Code); launchHelper.registerLaunchListener( new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { return null; } @Override public Object onTaskComplete(Object... result) { if (result != null && result.length > 0 && result[0] instanceof String) { MessageHelper.showMessageDialog( currentActivity, null, (String) result[0], new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { currentActivity.finish(); return null; } @Override public Object onTaskComplete(Object... result) { return null; } }); } return null; } }); launchHelper.launch(workflowEntity, 1); // exit action mode mode.finish(); return null; } @Override public Object onTaskComplete(Object... result) { return null; } }, null); return true; case R.id.input_history_delete: MessageHelper.showOptionsDialog( currentActivity, "Delete selected inputs ?", null, new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { for (File f : selectedInputs) { f.delete(); } mode.finish(); return null; } @Override public Object onTaskComplete(Object... result) { refreshFilesList(); return null; } }, null); return true; default: return false; } }