@Override
  public void onClick(View v) {
    Log.d("mine", "onClick");

    switch (v.getId()) {
      case R.id.newExerciseOK:

        // get the data newExerciseName
        String name = etName.getText().toString();
        Exercise exercise = new Exercise();
        exercise.setExerciseName(name);

        // TODO: for now take only one selection, future = multiple
        SparseBooleanArray checked = mTypeListView.getCheckedItemPositions();
        ArrayList<String> selectedItems = new ArrayList<String>();
        for (int i = 0; i < checked.size(); i++) {
          // Item position in adapter
          int position = checked.keyAt(i);
          // Add sport if it is checked i.e.) == TRUE!
          if (checked.valueAt(i)) selectedItems.add(mTypeArrayAdapter.getItem(position));
        }

        String[] outputStrArr = new String[selectedItems.size()];

        for (int i = 0; i < selectedItems.size(); i++) {
          outputStrArr[i] = selectedItems.get(i);
          Log.d("mine", outputStrArr[i]);
          String type = outputStrArr[i];
          exercise.setExerciseType(type);
        }

        // validate entry

        // create Exercise Object

        // Toast.makeText(this.getActivity(),"hi",Toast.LENGTH_LONG).show();

        // return object
        mListener.onDialogPositiveClick(exercise);
        break;

      case R.id.newExerciseCancel:
        mListener.onDialogNegativeClick();
        this.dismiss();
        break;
        //            case R.id.button_three:
        //                // i'm lazy, do nothing
        //                break;
    }

    this.dismiss();
  }
示例#2
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   mListener.onDialogSelect(which);
 }