コード例 #1
0
  public static ConfirmationDialogFragment newInstance(
      int dialogId, String title, String message, String confirmText, String cancelText) {
    ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();

    Bundle args = new Bundle();
    args.putInt(ARG_DIALOG_ID, dialogId);
    args.putString(ARG_TITLE, title);
    args.putString(ARG_MESSAGE, message);
    args.putString(ARG_CONFIRM_TEXT, confirmText);
    args.putString(ARG_CANCEL_TEXT, cancelText);
    fragment.setArguments(args);

    return fragment;
  }
コード例 #2
0
ファイル: MessageViewFragment.java プロジェクト: hckleo/k-9
  private void showDialog(int dialogId) {
    DialogFragment fragment;
    switch (dialogId) {
      case R.id.dialog_confirm_delete:
        {
          String title = getString(R.string.dialog_confirm_delete_title);
          String message = getString(R.string.dialog_confirm_delete_message);
          String confirmText = getString(R.string.dialog_confirm_delete_confirm_button);
          String cancelText = getString(R.string.dialog_confirm_delete_cancel_button);

          fragment =
              ConfirmationDialogFragment.newInstance(
                  dialogId, title, message, confirmText, cancelText);
          break;
        }
      case R.id.dialog_confirm_spam:
        {
          String title = getString(R.string.dialog_confirm_spam_title);
          String message =
              getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, 1);
          String confirmText = getString(R.string.dialog_confirm_spam_confirm_button);
          String cancelText = getString(R.string.dialog_confirm_spam_cancel_button);

          fragment =
              ConfirmationDialogFragment.newInstance(
                  dialogId, title, message, confirmText, cancelText);
          break;
        }
      case R.id.dialog_attachment_progress:
        {
          String title = getString(R.string.dialog_attachment_progress_title);
          fragment = ProgressDialogFragment.newInstance(title);
          break;
        }
      default:
        {
          throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
        }
    }

    fragment.setTargetFragment(this, dialogId);
    fragment.show(getFragmentManager(), getDialogTag(dialogId));
  }