Example #1
1
    @Override
    public boolean onContextItemSelected(MenuItem item) {

      int posn = (int) ((AdapterContextMenuInfo) item.getMenuInfo()).position;
      Codec c = codecs.elementAt(posn);
      if (item.getItemId() == MENU_UP) {
        if (posn == 0) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn - 1);
        codecs.set(posn - 1, c);
        codecs.set(posn, tmp);
      } else if (item.getItemId() == MENU_DOWN) {
        if (posn == codecs.size() - 1) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn + 1);
        codecs.set(posn + 1, c);
        codecs.set(posn, tmp);
      }
      PreferenceScreen ps = getPreferenceScreen();
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
      String v = "";
      SharedPreferences.Editor e = sp.edit();

      for (Codec d : codecs) v = v + d.number() + " ";
      e.putString(Settings.PREF_CODECS, v);
      e.commit();
      ps.removeAll();
      addPreferences(ps);
      return super.onContextItemSelected(item);
    }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    boolean handled = false;
    boolean deleteMessage = false;
    if (item.getItemId() == R.id.delete_message) {
      deleteMessage = true;
      handled = true;
    } else if (item.getItemId() == R.id.delete_conversation) {
      deleteMessage = false;
      handled = true;
    }
    EMConversation tobeDeleteCons =
        adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
    // 删除此会话
    EMChatManager.getInstance()
        .deleteConversation(tobeDeleteCons.getUserName(), tobeDeleteCons.isGroup(), deleteMessage);
    InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
    inviteMessgeDao.deleteMessage(tobeDeleteCons.getUserName());
    adapter.remove(tobeDeleteCons);
    adapter.notifyDataSetChanged();

    // 更新消息未读数
    ((MainActivity) getActivity()).updateUnreadLabel();

    return handled ? true : super.onContextItemSelected(item);
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String listItemName1 = Biography[info.position - 1];
    ListView wirdlist = (ListView) findViewById(R.id.biolist);
    LayoutInflater mInflater = getLayoutInflater();
    final View mLayout =
        mInflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
    final TextView mText = (TextView) mLayout.findViewById(R.id.toast_text);
    Toast mToast = new Toast(getApplicationContext());
    mToast.setDuration(Toast.LENGTH_SHORT);
    mToast.setView(mLayout);

    if (item.getItemId() == 0) {

      int menuItemIndex = item.getItemId();
      String[] menuItems = getResources().getStringArray(R.array.menu2);
      String menuItemName = menuItems[menuItemIndex];

      ClipData clip = ClipData.newPlainText("simple text", listItemName1);
      clipboard.setPrimaryClip(clip);

      mText.setText("Text Copied");
      mToast.show();
    }

    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.principal.novo) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Novo\"", Toast.LENGTH_SHORT).show();

      Intent i = new Intent(this, Formulario.class);

      startActivity(i);
    }

    if (item.getItemId() == R.principal.galeria) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Galeria\"", Toast.LENGTH_SHORT).show();

      startActivity(new Intent(ListaAluno.this, Galeria.class));
    }

    if (item.getItemId() == R.principal.sincronizar) {
      Sincronismo s = new Sincronismo(ListaAluno.this);

      s.sincronizar();
    }

    if (item.getItemId() == R.principal.mapa) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Mapa\"", Toast.LENGTH_SHORT).show();

      startActivity(new Intent(ListaAluno.this, Mapa.class));
    }

    return super.onOptionsItemSelected(item);
  }
Example #5
0
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    // Handle select all/none first, and if it isn't those then don't do anything if we haven't
    // selected any items.
    if (item.getItemId() == R.id.action_select_all) {
      adapter.selectAll();
      return true;
    } else if (item.getItemId() == R.id.action_select_none) {
      adapter.clearSelections();
      return true;
    } else if (adapter.getSelectedItemCount() == 0) return true;

    // Handle actions.
    switch (item.getItemId()) {
      case R.id.action_tag:
        //noinspection unchecked
        TaggingActivity.start(this, adapter.getSelectedRealmObjects());
        return true;
      case R.id.action_rate:
        int initialRating =
            adapter.getSelectedItemCount() == 1
                ? ((RBook) adapter.getSelectedRealmObjects().get(0)).rating
                : 0;
        Dialogs.ratingDialog(getContext(), initialRating);
        return true;
      case R.id.action_mark_as:
        Dialogs.markAsDialog(getActivity());
        return true;
      case R.id.action_add_to_list:
        Dialogs.addToListDialogOrSnack(getActivity(), realm);
        return true;
      case R.id.action_re_import:
        Dialogs.simpleConfirmDialog(
            getContext(),
            R.string.title_re_import_books,
            R.string.prompt_re_import_books,
            R.string.action_re_import,
            R.id.action_re_import);
        return true;
      case R.id.action_remove:
        Dialogs.simpleConfirmDialog(
            getContext(),
            R.string.title_remove_books,
            R.string.prompt_remove_from_recents,
            R.string.action_remove,
            R.id.action_remove);
        return true;
      case R.id.action_delete:
        Dialogs.confirmCheckBoxDialog(
            getContext(),
            R.string.title_delete_books,
            R.string.prompt_delete_books,
            R.string.prompt_delete_from_device_too,
            R.string.action_delete,
            R.id.action_delete);
        return true;
      default:
        return false;
    }
  }
Example #6
0
  @Override
  public boolean onOptionsItemSelected(final MenuItem item) {
    int openMenuIndex = -1;

    // detect which menu entry has been touched
    if (item.getItemId() == R.id.menu_settings_world) {
      openMenuIndex = WORLD_SETTINGS_INDEX;
    } else if (item.getItemId() == R.id.menu_settings_arena) {
      openMenuIndex = ARENA_SETTINGS_INDEX;
    } else if (item.getItemId() == R.id.menu_settings_shots) {
      openMenuIndex = SHOTS_SETTINGS_INDEX;
    } else if (item.getItemId() != R.id.menu_settings_main) {
      // no valid entry has been touched!
      Log.e(TAG, "Unknown menu entry: " + item.getItemId());
      return false;
    }

    // create new intent which opens settings
    final Intent intent = new Intent(this, SettingsActivity.class);

    // if the user didn't touch the main menu entry, tell the settings
    // activity to open a submenu
    if (openMenuIndex != -1) {
      intent.putExtra("openMenuIndex", openMenuIndex);
    }

    // launch activity
    startActivityForResult(intent, RESULT_SETTINGS);

    Log.d(TAG, "SettingsActivity started");

    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      getActivity().onBackPressed();
      return true;
    }

    item.setChecked(true);

    if (item.getItemId() == 0) {
      pics_sources.clear();
      for (int i = 0; i < covers.size(); i++) pics_sources.add(covers.get(i).getUrl());
      if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged();
    } else {
      pics_sources.clear();
      for (int i = 0; i < covers.size(); i++) {
        if (covers.get(i).getLanguage().equals(items[item.getItemId()])) {
          pics_sources.add(covers.get(i).getUrl());
        }
      }
      if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged();
    }

    return super.onOptionsItemSelected(item);
  }
Example #8
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == 1) {
     if (!prefs.getString("userKey", "").equals("")) {
       if (item.getItemId() == 1) {
         editor = prefs.edit();
         editor.putString("userKey", "");
         editor.commit();
         loginStatus.setText("Not loged in");
         startActivity(new Intent(Main.this, Login.class));
         finish();
       }
     } else {
       startActivity(new Intent(Main.this, Login.class));
       finish();
     }
   } else if (item.getItemId() == 2) {
     startActivity(new Intent(Main.this, Preference.class));
   } else if (item.getItemId() == 3) {
     startActivity(new Intent(Main.this, AboutUs.class));
   } else {
     dialogHelp.show();
   }
   return true;
 }
Example #9
0
  @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.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
      return true;
    }

    switch (item.getItemId()) {
      case R.id.showRouteInfoItem:
        showRouteInfo();
        break;
      case R.id.showRouteEditItem:
        isEditable = true;
        setUpListeners();
        break;
      case R.id.showRouteSaveItem:
        toPersist = true;
        fillRouteInfo();
        break;
      case R.id.showRouteDeleteItem:
        deciedeToDelete();
        // removeRoute();
        break;
      case R.id.action_showLocation:
        showUserLocation();

        break;
      default:
    }

    return super.onOptionsItemSelected(item);
  }
  public boolean onContextItemSelected(MenuItem item) {

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == 0) {
      int groupIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition);

      Log.i("长按获取下标2", "groupIndex=" + groupIndex);
      switch (item.getItemId()) {
        case ADD_GROUP:
          onInputDialog();
          break;
        case DELETE_GROUP:
          deleteGroup(groupIndex);
          break;
        case REN_GROUP:
          renGroup(groupIndex);
          break;
        case ADD_FRIEND_GROUP:
          Intent intent = new Intent();
          intent.setClass(getActivity(), AddFriendActivity.class);
          getActivity().startActivity(intent);
          break;
        default:
          break;
      }
      return true;
    } else if (type == 1) {
      // 长按联系人的名字
      String childName =
          ((TextView) info.targetView.findViewById(R.id.child_name)).getText().toString();
      // 长按组的下标
      int groupIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition);
      // 长按联系人的下标
      int childIndex = (int) ExpandableListView.getPackedPositionChild(info.packedPosition);
      Log.i(
          "事件处理",
          "groupIndex=" + groupIndex + "/childIndex=" + childIndex + "/childName=" + childName);
      if (groupIndex != 0) {
        switch (item.getItemId()) {
          case DELETE_FRIEND:
            deleteFriend(groupIndex, childIndex, childName);
            break;
          case MOVE:
            addGroup(childName, groupIndex, childIndex);
            break;
          case MARK:
            addMark(childName, groupIndex, childIndex);
            break;
          default:
            break;
        }

      } else {
        moveFriend(groupIndex, item.getItemId(), childIndex);
      }
      return true;
    }
    return false;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    try {

      int id = item.getItemId();

      CharSequence itemTitle = item.getTitle();

      // Esto podria ser un enum de item menu que correspondan a otro menu
      if (itemTitle.equals("New Identity")) {
        changeActivity(Activities.CWP_INTRA_USER_CREATE_ACTIVITY.getCode());
      }
      //            if(id == R.id.action_connection_request){
      //                Toast.makeText(getActivity(),"Intra user
      // request",Toast.LENGTH_SHORT).show();
      //            }
      if (item.getItemId() == R.id.action_notifications) {
        changeActivity(Activities.CCP_SUB_APP_INTRA_USER_COMMUNITY_REQUEST.getCode());
        return true;
      }

    } catch (Exception e) {
      errorManager.reportUnexpectedUIException(
          UISource.ACTIVITY,
          UnexpectedUIExceptionSeverity.UNSTABLE,
          FermatException.wrapException(e));
      makeText(getActivity(), "Oooops! recovering from system error", LENGTH_LONG).show();
    }
    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.archive) {
      mBuffer.archive();
      TapchatApp.goHome(getActivity(), mConnection.getId());
      return true;

    } else if (item.getItemId() == R.id.unarchive) {
      mBuffer.unarchive();
      return true;

    } else if (item.getItemId() == R.id.delete) {
      new AlertDialog.Builder(getActivity())
          .setMessage(R.string.confirm_delete_buffer)
          .setPositiveButton(
              android.R.string.yes,
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  mBuffer.delete();
                  TapchatApp.goHome(getActivity(), mConnection.getId());
                }
              })
          .setNegativeButton(android.R.string.no, null)
          .show();
      return true;
    }
    return false;
  }
Example #13
0
  @Override
  public boolean onContextItemSelected(android.view.MenuItem item) {
    if (item.getGroupId() == MENU_GROUP_FILTER) {
      // give an initial value for the row before adding it
      CustomFilterCriterion criterion = filterCriteriaProvider.getAll().get(item.getItemId());
      final CriterionInstance instance = new CriterionInstance();
      instance.criterion = criterion;
      adapter.showOptionsFor(
          instance,
          new Runnable() {
            @Override
            public void run() {
              adapter.add(instance);
              updateList();
            }
          });
      return true;
    }

    // item type context item
    else if (item.getGroupId() == MENU_GROUP_CONTEXT_TYPE) {
      CriterionInstance instance = adapter.getItem(item.getOrder());
      instance.type = item.getItemId();
      updateList();
    }

    // delete context item
    else if (item.getGroupId() == MENU_GROUP_CONTEXT_DELETE) {
      CriterionInstance instance = adapter.getItem(item.getOrder());
      adapter.remove(instance);
      updateList();
    }

    return super.onContextItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == 0) {

      if (JSUMainActivity.webInstance != null) {
        JSUMainActivity.webInstance.finish();
      }
      finish();
    } else if (item.getItemId() == 1) {
      DialogUtils.dialogBuilder(
          webInstance,
          "提示",
          "确定要注销用户并退出?",
          new DialogCallBack() {
            public void callBack() {
              dialog.show();
              dialog.setMessage("注销用户中...");
              ExitAppThread exit = new ExitAppThread(mContext);
              Thread thread = new Thread(exit);
              thread.start();

              ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
              am.restartPackage(getPackageName());
            }
          });
    }
    return super.onOptionsItemSelected(item);
  }
Example #15
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_external) {
      AppUtils.openWebUrlExternal(this, mItem.getUrl());
      return true;
    }

    if (item.getItemId() == R.id.menu_comment) {
      final Intent intent = new Intent(this, ItemActivity.class);
      intent.putExtra(ItemActivity.EXTRA_ITEM, mItem);
      startActivity(intent);
      return true;
    }

    if (item.getItemId() == R.id.menu_favorite) {
      final int toastMessageResId;
      mIsFavorite = !mIsFavorite;
      if (mIsFavorite) {
        mFavoriteManager.add(this, mItem);
        toastMessageResId = R.string.toast_saved;
      } else {
        mFavoriteManager.remove(this, mItem.getId());
        toastMessageResId = R.string.toast_removed;
      }
      Toast.makeText(this, toastMessageResId, Toast.LENGTH_SHORT).show();
      toggleFavorite(item);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
  @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.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement

    if (item.getItemId() == android.R.id.home) {
      onBackPressed();
      return true;
    }

    if (item.getItemId() == R.id.action_logout) {
      Intent s = new Intent(ProfileViewActivity.this, LoginActivity.class);
      startActivity(s);
    }

    if (item.getItemId() == R.id.profile_edit) {
      Intent e = new Intent(ProfileViewActivity.this, ProfileEditActivity.class);
      startActivity(e);
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {

      if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
        mDrawerLayout.closeDrawer(mDrawerLinear);
      } else {
        mDrawerLayout.openDrawer(mDrawerLinear);
      }
      return true;
    }

    switch (item.getItemId()) {
      case android.R.id.home:
        // app icon in action bar clicked; go home
        Intent intent = new Intent(this, LauncherActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;
      case R.id.Opzioni:
        Intent settingsActivity = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivity(settingsActivity);
        return true;
      case R.id.TestUDP:
        Intent myIntents = new Intent(SceneListActivity.this, ManualUDPTestActivity.class);
        SceneListActivity.this.startActivity(myIntents);
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {

      if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
        mDrawerLayout.closeDrawer(mDrawerLinear);
      } else {
        mDrawerLayout.openDrawer(mDrawerLinear);
      }
      return true;
    }

    switch (item.getItemId()) {
      case android.R.id.home:
        // app icon in action bar clicked; go home
        supportFinishAfterTransition();
        return true;
      case R.id.Opzioni:
        Intent settingsActivity = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivity(settingsActivity);
        return true;
      case R.id.TestUDP:
        Intent myIntents = new Intent(TagGridActivity.this, ManualUDPTestActivity.class);
        TagGridActivity.this.startActivity(myIntents);
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    String TAG = className + "onOptionsItemSelected";
    PBLogger.entry(TAG);
    Intent preferencesIntent = null;
    switch (item.getItemId()) {
      case R.id.menu_contact_preferences:
        preferencesIntent = new Intent(getBaseContext(), ContactPreferencesActivity.class);
        break;

      case R.id.menu_subscription_preferences:
        preferencesIntent = new Intent(getBaseContext(), SubscriptionPreferencesActivity.class);
      default:
        PBLogger.w(TAG, "No preferences matching itemId = " + item.getItemId());
        break;
    }
    PBLogger.i(TAG, "Setting Preferences Activity -  = " + preferencesIntent);

    if (preferencesIntent != null) {
      startActivity(preferencesIntent);
    }
    PBLogger.exit(TAG);

    return true;
  }
  /** @see android.app.Activity#onContextItemSelected(android.view.MenuItem) */
  @Override
  public boolean onContextItemSelected(MenuItem menuItem) {
    if (menuItem.getItemId() == MENU_ITEM_CANCEL) {
      return true;
    } else if (menuItem.getItemId() == MENU_ITEM_DELETE) {
      AdapterView.AdapterContextMenuInfo info =
          (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

      ListView lv = (ListView) findViewById(R.id.query_history_all);
      QueryHistoryListItem item = (QueryHistoryListItem) lv.getItemAtPosition(info.position);
      int count = new TransitQueryDao(this).deleteTransitQuery(item.getQuery().getId());
      if (count == 1) {
        showList();
      }

      return true;
    } else if (menuItem.getItemId() == MENU_ITEM_SET_FROM
        || menuItem.getItemId() == MENU_ITEM_SET_TO) {
      AdapterView.AdapterContextMenuInfo info =
          (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

      ListView lv = (ListView) findViewById(R.id.query_history_location);
      Location item = (Location) lv.getItemAtPosition(info.position);

      Intent result = new Intent();
      result.putExtra(EXTRA_KEY_LOCATION, item);
      setResult(getResultCode(menuItem.getItemId()), result);
      finish();

      return true;
    }

    return super.onContextItemSelected(menuItem);
  }
  @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.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    switch (item.getItemId()) {
      case R.id.action_settings:
        {
          return true;
        }
      case R.id.action_appcreator:
        Toast.makeText(
                getApplicationContext(), "Alyssa Zlotnicki is the app creator", Toast.LENGTH_LONG)
            .show();

        return true;
      case R.id.action_happybirthday:
        Toast.makeText(getApplicationContext(), "Happy Birthday Chris!", Toast.LENGTH_LONG).show();

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Example #22
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.menu_send_request) {

      Intent menuRequest = new Intent(this, RequestActivity.class);
      menuRequest.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(menuRequest);

    } else if (item.getItemId() == R.id.register) {
      Intent menuRegister = new Intent(this, RegisterActivity.class);
      menuRegister.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
      Log.d("MainActivity", "Starting RegisterActivity");
      startActivity(menuRegister);
    } else if (item.getItemId() == R.id.menu_friends_list) {
      Intent menuFriends = new Intent(this, AllFriendsActivity.class);
      menuFriends.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

      startActivity(menuFriends);
    } else if (item.getItemId() == R.id.menu_location) {
      lon = loc.getLongitude();
      lat = loc.getLatitude();

      Toast.makeText(this, "LON: " + lon + ", LAT: " + lat, Toast.LENGTH_LONG).show();
    }

    return super.onOptionsItemSelected(item);
  }
 public boolean onContextItemSelected(MenuItem item) {
   AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo();
   if (item.getItemId() == CM_DELETE_ID) {
     cursor = db.getDataTrainings(null, null, null, null, null, null);
     LinearLayout llTmp = (LinearLayout) acmi.targetView;
     TextView tvTmp = (TextView) llTmp.findViewById(R.id.tvText);
     String traName = tvTmp.getText().toString();
     if (cursor.moveToFirst()) {
       do {
         if (cursor.getString(1).equals(traName)) {
           db.delRec_Trainings(cursor.getInt(0));
           Toast.makeText(
                   getActivity(), getResources().getString(R.string.deleted), Toast.LENGTH_SHORT)
               .show();
         }
       } while (cursor.moveToNext());
       ((FragmentActivity) getActivity())
           .getSupportLoaderManager()
           .getLoader(LOADER_ID)
           .forceLoad();
       cursor.close();
       return true;
     }
   } else if (item.getItemId() == CM_EDIT_ID) {
     long id = acmi.id;
     Intent intent = new Intent(getActivity(), EditingProgramAtTrainingActivity.class);
     intent.putExtra("trID", id);
     intent.putExtra("ifAddingExe", false);
     startActivityForResult(intent, 1);
     ((FragmentActivity) getActivity()).getSupportLoaderManager().getLoader(LOADER_ID).forceLoad();
     return true;
   }
   return super.onContextItemSelected(item);
 }
  /**
   * This hook is called whenever an item in your options menu is selected. The default
   * implementation simply returns false to have the normal processing happen (calling the item's
   * Runnable or sending a message to its Handler as appropriate). You can use this method for any
   * items for which you would like to do processing without those other facilities.
   *
   * <p>
   *
   * <p>Derived classes should call through to the base class for it to perform the default menu
   * handling.
   *
   * @param item The menu item that was selected.
   * @return boolean Return false to allow normal menu processing to proceed, true to consume it
   *     here.
   * @see #onCreateOptionsMenu
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id >= 0 && id < savingsAccountDataTables.size()) {

      DataTableDataFragment dataTableDataFragment =
          DataTableDataFragment.newInstance(savingsAccountDataTables.get(id), savingsAccountNumber);
      FragmentTransaction fragmentTransaction =
          getActivity().getSupportFragmentManager().beginTransaction();
      fragmentTransaction.addToBackStack(FragmentConstants.FRAG_SAVINGS_ACCOUNT_SUMMARY);
      fragmentTransaction.replace(R.id.global_container, dataTableDataFragment);
      fragmentTransaction.commit();
    }

    if (item.getItemId() == MENU_ITEM_DOCUMENTS) {

      loadDocuments();

    } else if (id == MENU_ITEM_SEARCH) {

      getActivity().finish();
    }

    return super.onOptionsItemSelected(item);
  }
  @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.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    switch (item.getItemId()) {
      case R.id.action_settings:
        Log.i(TAG, "Menu item: " + item.getTitle());
        return true;
      case R.id.action_settings_sound:
        Log.i(TAG, "Menu item: " + item.getTitle());
        Intent sound_intent = new Intent(this, SoundSettingsActivity.class);
        startActivityForResult(sound_intent, REQUEST_CODE);
        return true;
      case R.id.action_settings_ble:
        Log.i(TAG, "Menu item: " + item.getTitle());
        Intent ble_intent = new Intent(this, BLESettingsActivity.class);
        startActivity(ble_intent);
        return true;
      case R.id.action_settings_sensitivity:
        Log.i(TAG, "Menu item: " + item.getTitle());
        Intent sensitivity_intent = new Intent(this, SensitivitySettingsActivity.class);
        startActivity(sensitivity_intent);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int itemId = Integer.valueOf(String.valueOf(info.position));

    mCursor.moveToPosition(itemId);
    int ApplicationId = mCursor.getInt(0);
    String name = mCursor.getString(mCursor.getColumnIndex("name"));

    refreshMenuList(mDatabase);

    int i = 1;

    while (mCursorSubMenus.moveToNext()) {
      if (item.getItemId() == mnuMoveItem) {
        MoveApplication(ApplicationId, "MainMenu", name, null, false);
        break;
      } else if (item.getItemId() == mnuMoveItem + i) {
        MoveApplication(
            ApplicationId,
            mCursorSubMenus.getString(mCursorSubMenus.getColumnIndex("name")),
            name,
            null,
            false);
        break;
      }
      i++;
    }

    return super.onContextItemSelected(item);
  }
Example #27
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.prefs) {
      startActivity(new Intent(this, EditPreferences.class));

      return (true);
    } else if (item.getItemId() == R.id.bff) {
      try {
        List<String> bff = new ArrayList<String>();

        for (int i = 0; i < friends.size(); i++) {
          if (friendsList.isItemChecked(i)) {
            bff.add(friends.get(i));
          }
        }

        service.setBestFriends(listener, bff);
      } catch (Throwable t) {
        Log.e("Patchy", "Exception in onOptionsItemSelected()", t);
        goBlooey(t);
      }

      return (true);
    } else if (item.getItemId() == R.id.location) {
      insertLocation();

      return (true);
    } else if (item.getItemId() == R.id.help) {
      startActivity(new Intent(this, HelpPage.class));

      return (true);
    }

    return (super.onOptionsItemSelected(item));
  }
  @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.
    int id = item.getItemId();

    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
      case android.R.id.home:
        finish();
      case R.id.action_save:
        DatabaseHandler databaseHandler = new DatabaseHandler(AddClinicalNotesActivity.this);
        try {
          if (historyObj._date != null) databaseHandler.addHistory(historyObj);
          if (examObj._date != null) databaseHandler.addExam(examObj);
          if (treatmentOb._date != null) databaseHandler.addTreatment(treatmentOb);
          if (Other_Notes_Activity.otherObj != null && Other_Notes_Activity.otherObj.size() > 0) {
            for (int i = 0; i < Other_Notes_Activity.otherObj.size(); i++) {
              databaseHandler.addOther(Other_Notes_Activity.otherObj.get(i));
            }
            Other_Notes_Activity.otherObj.clear();
          }

        } catch (Exception e) {
          e.printStackTrace();
        }
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Example #29
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   MenuInflater inflater = mCoolReader.getMenuInflater();
   menu.clear();
   inflater.inflate(
       mList.isShortcutMode()
           ? R.menu.cr3_bookmark_shortcut_context_menu
           : R.menu.cr3_bookmark_context_menu,
       menu);
   AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
   if (mi != null) selectedItem = mi.position;
   Bookmark bm = mList.getSelectedBookmark();
   menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark));
   for (int i = 0; i < menu.size(); i++) {
     MenuItem menuItem = menu.getItem(i);
     if (menuItem.getItemId() == R.id.bookmark_shortcut_goto
         || menuItem.getItemId() == R.id.bookmark_edit
         || menuItem.getItemId() == R.id.bookmark_delete) menuItem.setEnabled(bm != null);
     if (menuItem.getItemId() == R.id.bookmark_edit)
       menuItem.setEnabled(
           bm != null
               && (bm.getType() == Bookmark.TYPE_COMMENT
                   || bm.getType() == Bookmark.TYPE_CORRECTION));
     menuItem.setOnMenuItemClickListener(
         new OnMenuItemClickListener() {
           public boolean onMenuItemClick(MenuItem item) {
             onContextItemSelected(item);
             return true;
           }
         });
   }
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.mnuDelete) {
      // they have requested that we delete the selected race
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      try {
        if (db.GetFile().delete()) {
          Toast.makeText(this, "Database deleted", Toast.LENGTH_LONG).show();
        } else {
          Toast.makeText(this, "Failed to delete DB", Toast.LENGTH_LONG).show();
        }
      } catch (Exception e) {
        Toast.makeText(this, "Failed to delete file " + e.toString(), Toast.LENGTH_LONG).show();
      }
      FirstTimeSetup(); // refresh the list
      return true;
    } else if (item.getItemId() == R.id.mnuRename) {
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      // they have requested that we rename the selected race
      Dialog d = new RenameDialog<DBPathEntry>(this, "Set the new DB name", db, R.id.edtRename);
      d.setOnDismissListener(this);
      d.show();

      return true;
    }
    return false;
  }