Ejemplo n.º 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.show_details:
        handleShowDetails(!currentFragment.getShowDetails(), item);
        break;

      case R.id.unpacking:
        currentFragment.startUnPackingActionMode();
        break;

      case R.id.delete:
        currentFragment.startDeleteActionMode();
        break;
    }
    return super.onOptionsItemSelected(item);
  }
Ejemplo n.º 2
0
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    // Dismiss ActionMode without effecting checked items

    if (currentFragment != null
        && currentFragment.getActionModeActive()
        && event.getKeyCode() == KeyEvent.KEYCODE_BACK
        && event.getAction() == KeyEvent.ACTION_UP) {
      ListAdapter adapter = null;
      if (currentFragment instanceof BackPackScriptFragment) {
        adapter = ((BackPackScriptFragment) currentFragment).getAdapter();
      } else {
        adapter = currentFragment.getListAdapter();
      }
      ((ScriptActivityAdapterInterface) adapter).clearCheckedItems();
    }

    return super.dispatchKeyEvent(event);
  }
Ejemplo n.º 3
0
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   if (currentFragment != null) {
     handleShowDetails(currentFragment.getShowDetails(), menu.findItem(R.id.show_details));
     menu.findItem(R.id.unpacking).setVisible(false);
     menu.findItem(R.id.backpack).setVisible(false);
     menu.findItem(R.id.cut).setVisible(false);
     menu.findItem(R.id.rename).setVisible(false);
   }
   return super.onPrepareOptionsMenu(menu);
 }
Ejemplo n.º 4
0
  public void handleShowDetails(boolean showDetails, MenuItem item) {
    currentFragment.setShowDetails(showDetails);

    item.setTitle(showDetails ? R.string.hide_details : R.string.show_details);
  }