List of usage examples for android.os Bundle getCharSequenceArray
@Override
@Nullable
public CharSequence[] getCharSequenceArray(@Nullable String key)
From source file:org.xbmc.kore.ui.generic.GenericSelectDialog.java
/** * Build the dialog/* w ww. j a va2 s .c o m*/ * * @param savedInstanceState State * * @return Dialog to select calendars */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); Bundle args = getArguments(); final String title = args.getString(TITLE_KEY); final int token = args.getInt(TOKEN_KEY); final int selectedItem = args.getInt(SELECTED_ITEM_KEY); builder.setTitle(title); if (getArguments().containsKey(ARRAY_ID_KEY)) { final int arrayId = args.getInt(ARRAY_ID_KEY); builder.setSingleChoiceItems(arrayId, selectedItem, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mListener != null) mListener.onDialogSelect(token, which); dialog.dismiss(); } }); } else { final CharSequence[] items = args.getCharSequenceArray(ARRAY_ITEMS); // TODO: This should be a singleChoiceItems, but how do we include actions in it? // builder.setSingleChoiceItems(items, selectedItem, // new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // if (mListener != null) // mListener.onDialogSelect(token, which); // dialog.dismiss(); // } // }); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mListener != null) mListener.onDialogSelect(token, which); dialog.dismiss(); } }); } return builder.create(); }
From source file:jp.co.noxi.app.NXAlertDialog.java
private void setItems(AlertDialog.Builder builder) { final Bundle args = getArguments(); final CharSequence[] items = args.getCharSequenceArray(ARG_ITEMS); if (items == null) { return;/* w w w .j a v a 2s. c om*/ } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final OnChoiceClickListener listener = findListenerByTag(OnChoiceClickListener.class, ARG_ITEMS_LISTENER); if (listener != null) { listener.onClick(NXAlertDialog.this, which); } } }); }
From source file:jp.co.noxi.app.NXAlertDialog.java
private void setMultiChoiceItems(AlertDialog.Builder builder) { final Bundle args = getArguments(); final CharSequence[] items = args.getCharSequenceArray(ARG_MULTI_CHOICE_ITEMS); final boolean[] checked = args.getBooleanArray(ARG_CHECKED_ITEMS); if ((items == null) || (checked == null) || (items.length != checked.length)) { return;/*from w ww . j a va 2s . c om*/ } builder.setMultiChoiceItems(items, checked, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { final OnMultiChoiceClickListener listener = findListenerByTag(OnMultiChoiceClickListener.class, ARG_MULTI_CHOICE_LISTENER); if (listener != null) { listener.onClick(NXAlertDialog.this, which, isChecked); } } }); }
From source file:jp.co.noxi.app.NXAlertDialog.java
private void setSingleChoiceItems(AlertDialog.Builder builder) { final Bundle args = getArguments(); final CharSequence[] items = args.getCharSequenceArray(ARG_SINGLE_CHOICE_ITEMS); final int checkedItem = args.getInt(ARG_CHECKED_ITEM); if (items != null) { builder.setSingleChoiceItems(items, checkedItem, new DialogInterface.OnClickListener() { @Override/*from w w w. j a v a 2 s . co m*/ public void onClick(DialogInterface dialog, int which) { final OnChoiceClickListener listener = findListenerByTag(OnChoiceClickListener.class, ARG_SINGLE_CHOICE_LISTENER); if (listener != null) { listener.onClick(NXAlertDialog.this, which); } } }); return; } final ListAdapterDelegate delegate = findListenerByTag(ListAdapterDelegate.class, ARG_SINGLE_CHOICE_ADAPTER); if (delegate == null) { return; } builder.setSingleChoiceItems(delegate.getListAdapter(this), checkedItem, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final OnChoiceClickListener listener = findListenerByTag(OnChoiceClickListener.class, ARG_SINGLE_CHOICE_LISTENER); if (listener != null) { listener.onClick(NXAlertDialog.this, which); } } }); }
From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { final DialogPreference preference = getPreference(); mDialogTitle = preference.getDialogTitle(); mDialogMessage = preference.getDialogMessage(); if (preference instanceof ListPreference) { mMulti = false;//from w ww . j a va 2s .co m mEntries = ((ListPreference) preference).getEntries(); mEntryValues = ((ListPreference) preference).getEntryValues(); mInitialSelection = ((ListPreference) preference).getValue(); } else if (preference instanceof MultiSelectListPreference) { mMulti = true; mEntries = ((MultiSelectListPreference) preference).getEntries(); mEntryValues = ((MultiSelectListPreference) preference).getEntryValues(); mInitialSelections = ((MultiSelectListPreference) preference).getValues(); } else { throw new IllegalArgumentException( "Preference must be a ListPreference or " + "MultiSelectListPreference"); } } else { mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE); mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE); mMulti = savedInstanceState.getBoolean(SAVE_STATE_IS_MULTI); mEntries = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRIES); mEntryValues = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRY_VALUES); if (mMulti) { final String[] initialSelections = savedInstanceState.getStringArray(SAVE_STATE_INITIAL_SELECTIONS); mInitialSelections = new ArraySet<>(initialSelections != null ? initialSelections.length : 0); if (initialSelections != null) { Collections.addAll(mInitialSelections, initialSelections); } } else { mInitialSelection = savedInstanceState.getString(SAVE_STATE_INITIAL_SELECTION); } } }
From source file:com.tomeokin.lspush.ui.widget.dialog.BaseDialogFragment.java
protected Builder applyArgsSetting(Builder builder) { Bundle args = getArguments(); if (args != null) { CharSequence field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_TITLE, null); if (field != null) { builder.setTitle(field);/*from www .j a v a2 s. com*/ } field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_MESSAGE, null); if (field != null) { builder.setTitle(field); } // it also contain builder setting hasCancelListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_CANCEL_LISTENING, hasCancelListener); hasDismissListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_DISMISS_LISTENING, hasDismissListener); hasActionClickListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_ACTION_CLICK_LISTENING, hasActionClickListener); DialogInterface.OnClickListener listener = hasActionClickListener ? this : null; field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_NEUTRAL_TEXT, null); if (field != null) { builder.addNeutralButton(field, listener); } field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_NEGATIVE_TEXT, null); if (field != null) { builder.addNegativeButton(field, listener); } field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_POSITIVE_TEXT, null); if (field != null) { builder.addPositiveButton(field, listener); } CharSequence[] items = args.getCharSequenceArray(BaseDialogBuilder.EXTRA_DIALOG_LIST_ITEMS); if (items != null) { builder.setItems(new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, items), this); } boolean flag = args.getBoolean(BaseDialogBuilder.EXTRA_DIALOG_CANCELABLE, true); builder.setCancelable(flag); flag = args.getBoolean(BaseDialogBuilder.EXTRA_DIALOG_CANCELED_ON_TOUCH_OUTSIDE, true); builder.setCanceledOnTouchOutside(flag); } return builder; }