// Method to handle menu selections on the app bar @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_settings: // TODO: Implement actual settings and bind to action return true; case R.id.action_new_task: if (pager.getCurrentItem() == 0) { createTask(); } else { createNote(); } return true; case R.id.action_delete_all_tasks: dbHelper.remakeTaskTable(); TasksFragment tf = (TasksFragment) adapter.getRegisteredFragment(pager.getCurrentItem()); tf.populateTaskList(); return true; default: // None of our actions were initiated, refer to super class return super.onOptionsItemSelected(item); } }
// Method to handle data returned from a finished activity started by this activity @Override protected void onActivityResult(int resultCode, int requestCode, Intent data) { if (resultCode == CREATE_TASK_REQUEST) { if (requestCode == RESULT_OK) { // update list of tasks TasksFragment tf = (TasksFragment) adapter.getRegisteredFragment(pager.getCurrentItem()); tf.populateTaskList(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.assigned_task_frames); Bundle extras = getIntent().getExtras(); groupName = extras.getString("groupname"); userName = extras.getString("userName"); param = new RequestParams(); param.add("groupname", groupName); invokeWSForGettingAssignedTasksToPersons(param, false, false); // Put ActionBar in Tab Mode tabBar = getSupportActionBar(); tabBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Store the list of tasks as an argument to the TaskFragment Bundle args = new Bundle(); args.putStringArrayList(TASK_IDS, mTaskIdsStringPending); args.putString(GROUP_NAME, groupName); args.putString(USER_NAME, userName); args.putStringArrayList(PERSON_IDS, mPersonsList); pendingFrag.setArguments(args); // Configure a tab for the Pending task TaskFragment tabBar.addTab( tabBar.newTab().setText("Pending tasks").setTabListener(new TabListener(pendingFrag))); // Store the list of tasks as an argument to the TaskFragment args = new Bundle(); args.putStringArrayList(TASK_IDS, mTaskIdsStringCompleted); args.putString(GROUP_NAME, groupName); args.putString(USER_NAME, userName); args.putStringArrayList(PERSON_IDS, mPersonsList); completedFrag.setArguments(args); // Configure a tab for the Completed tasks TaskFragment tabBar.addTab( tabBar.newTab().setText("Completed tasks").setTabListener(new TabListener(completedFrag))); }