Exemplo n.º 1
0
  @Override
  public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

    Cursor c = (Cursor) mAdapter.getItem(info.position);
    if (c != null) {
      String gamertag = c.getString(RecentPlayersCursor.COLUMN_GAMERTAG);

      switch (menuItem.getItemId()) {
        case R.id.menu_compare_games:
          CompareGames.actionShow(getActivity(), mAccount, gamertag);
          return true;
        case R.id.menu_compose:
          MessageCompose.actionComposeMessage(getActivity(), mAccount, gamertag);
          return true;
        case R.id.menu_send_friend_request:
          AlertDialogFragment frag =
              AlertDialogFragment.newInstance(
                  DIALOG_CONFIRM_ADD,
                  getString(R.string.are_you_sure),
                  getString(R.string.send_friend_request_to_f, gamertag),
                  gamertag);

          frag.setOnOkListener(this);
          frag.show(getFragmentManager(), "dialog");

          return true;
      }
    }

    return super.onContextItemSelected(menuItem);
  }
Exemplo n.º 2
0
  @Override
  public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
    XboxLiveFriendListItem friend = (XboxLiveFriendListItem) info.targetView;

    mSelectedGamertag = friend.mGamertag;
    TaskController controller = TaskController.getInstance();

    switch (menuItem.getItemId()) {
      case R.id.menu_view_friends:
        FriendsOfFriendList.actionShow(getActivity(), mAccount, mSelectedGamertag);
        return true;
      case R.id.menu_compose:
        MessageCompose.actionComposeMessage(getActivity(), mAccount, mSelectedGamertag);
        return true;
      case R.id.menu_remove_friend:
        AlertDialogFragment frag =
            AlertDialogFragment.newInstance(
                DIALOG_CONFIRM_REMOVE,
                getString(R.string.are_you_sure),
                getString(R.string.remove_from_friends_q_f, friend.mGamertag),
                friend.mFriendId);
        frag.setOnOkListener(this);
        frag.show(getFragmentManager(), "dialog");
        return true;
      case R.id.menu_accept_friend:
        mHandler.showToast(getString(R.string.request_queued));
        controller.acceptFriendRequest(
            mAccount,
            mSelectedGamertag,
            new RequestInformation(R.string.accepted_friend_request_from_f, mSelectedGamertag),
            mRequestListener);
        return true;
      case R.id.menu_reject_friend:
        mHandler.showToast(getString(R.string.request_queued));
        controller.rejectFriendRequest(
            mAccount,
            mSelectedGamertag,
            new RequestInformation(R.string.declined_friend_request_from_f, mSelectedGamertag),
            mRequestListener);
        return true;
      case R.id.menu_cancel_friend:
        mHandler.showToast(getString(R.string.request_queued));
        controller.cancelFriendRequest(
            mAccount,
            mSelectedGamertag,
            new RequestInformation(R.string.cancelled_friend_request_to_f, mSelectedGamertag),
            mRequestListener);
        return true;
      case R.id.menu_compare_games:
        CompareGames.actionShow(getActivity(), mAccount, mSelectedGamertag);
        return true;
    }

    return super.onContextItemSelected(menuItem);
  }