@Override public void onClick(DialogInterface dialog, int which) { super.onClick(dialog, which); switch (which) { case DialogInterface.BUTTON_POSITIVE: final boolean isEditing = !isIncomplete(); final SubtypeLocaleItem locale = (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem(); final KeyboardLayoutSetItem layout = (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem(); final InputMethodSubtype subtype = AdditionalSubtype.createAdditionalSubtype(locale.first, layout.first, ASCII_CAPABLE); setSubtype(subtype); notifyChanged(); if (isEditing) { mProxy.onSavePressed(this); } else { mProxy.onAddPressed(this); } break; case DialogInterface.BUTTON_NEUTRAL: // Nothing to do break; case DialogInterface.BUTTON_NEGATIVE: mProxy.onRemovePressed(this); break; } }
@Override protected View onCreateDialogView() { final View v = super.onCreateDialogView(); mSubtypeLocaleSpinner = (Spinner) v.findViewById(R.id.subtype_locale_spinner); mSubtypeLocaleSpinner.setAdapter(mProxy.getSubtypeLocaleAdapter()); mKeyboardLayoutSetSpinner = (Spinner) v.findViewById(R.id.keyboard_layout_set_spinner); mKeyboardLayoutSetSpinner.setAdapter(mProxy.getKeyboardLayoutSetAdapter()); return v; }
@Override public void onCancel(DialogInterface dialog) { if (isIncomplete()) { mProxy.onRemovePressed(this); } }