@Override public void onPause() { super.onPause(); // We are being hidden: commit changes to the user dictionary, unless we were deleting it if (!mIsDeleting) { mContents.apply(getActivity(), null); } }
/** * Callback for the framework when a menu option is pressed. * * <p>This class only supports the delete menu item. * * @param MenuItem the item that was pressed * @return false to allow normal menu processing to proceed, true to consume it here */ @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == OPTIONS_MENU_DELETE) { mContents.delete(getActivity()); mIsDeleting = true; getActivity().onBackPressed(); return true; } return false; }
@Override public void onItemSelected( final AdapterView<?> parent, final View view, final int pos, final long id) { final LocaleRenderer locale = (LocaleRenderer) parent.getItemAtPosition(pos); if (locale.isMoreLanguages()) { PreferenceActivity preferenceActivity = (PreferenceActivity) getActivity(); preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(this), true); } else { mContents.updateLocale(locale.getLocaleString()); } }
private void updateSpinner() { final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity()); final Spinner localeSpinner = (Spinner) mRootView.findViewById(R.id.user_dictionary_add_locale); final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<LocaleRenderer>( getActivity(), android.R.layout.simple_spinner_item, localesList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); localeSpinner.setAdapter(adapter); localeSpinner.setOnItemSelectedListener(this); }
// Called by the locale picker @Override public void onLocaleSelected(final Locale locale) { mContents.updateLocale(locale.toString()); getActivity().onBackPressed(); }
@Override public void onNothingSelected(final AdapterView<?> parent) { // I'm not sure we can come here, but if we do, that's the right thing to do. final Bundle args = getArguments(); mContents.updateLocale(args.getString(UserDictionaryAddWordContents.EXTRA_LOCALE)); }