Creates and returns a listener, which allows to show a toast, when a button of the {@link
DialogPreference}'s dialog has been clicked.

@return The listener, which has been created, as an instance of the type {@link
OnClickListener}
325483
private OnClickListener createDialogPreferenceClickListener() {
        return new OnClickListener() {

            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                String button = getString(
                        which == DialogInterface.BUTTON_POSITIVE ? android.R.string.ok :
                                android.R.string.cancel);
                String text = String.format(getString(R.string.dialog_dismissed_toast), button);
                Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
            }

        };
    }
691184
private OnCheckedChangeListener createCheckedChangeListener() {
        return new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
                if (getOnPreferenceChangeListener() == null || getOnPreferenceChangeListener()
                        .onPreferenceChange(SwitchPreference.this, isChecked)) {
                    setChecked(isChecked);
                } else {
                    setChecked(!isChecked);
                }
            }

        };
    }
1283494
@NonNull
    private ListDialog.OnItemSelectedListener createItemSelectedListener() {
        return new ListDialog.OnItemSelectedListener() {

            @Override
            public void onItemSelected(final int position) {
                ColorPalettePreference.this.selectedIndex = position;
                ColorPalettePreference.this.onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);

                if (getDialog() != null) {
                    getDialog().dismiss();
                }
            }

        };
    }
475400
public CheckBox addListener(Listener listener) {
        if(listener != null && !listeners.contains(listener)) {
            listeners.add(listener);
        }
        return this;
    }
264453
private AnimatorListener createDismissAnimationListener() {
        return new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                AbstractAnimateableDialog.super.dismiss();
            }

        };
    }
1290925
public Button createCloseButton() {

        Button button = new Button(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_BUTTON_CLOSE_DIALOG_0));
        button.setWidth("150px");
        button.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {

                m_context.finish(Lists.newArrayList(m_context.getResources().get(0).getStructureId()));
            }
        });
        return button;
    }
619417
private OnItemClickListener createItemClickListener() {
        return new OnItemClickListener() {

            @Override
            public void onItemClick(final AdapterView<?> parent, final View view,
                                    final int position, final long id) {
                if (itemClickListener != null && !rootView.isDragging() &&
                        !rootView.isAnimationRunning()) {
                    int index = position;

                    if (adapter.containsDividers()) {
                        for (int i = position; i >= 0; i--) {
                            if (adapter.getItem(i) == null ||
                                    (adapter.getItem(i) instanceof Divider &&
                                            i % adapter.getColumnCount() > 0)) {
                                index--;
                            }
                        }
                    }

                    itemClickListener.onItemClick(parent, view, index, getId(position));
                }

                dismiss();
            }

        };
    }
195001
private void initializeSelectionListener() {
        ChoiceMode choiceMode = adapter.getChoiceMode();

        if (choiceMode instanceof MultipleChoiceMode) {
            adapter.setOnItemClickListener(
                    new OnMultiChoiceClickListenerWrapper(multiChoiceListener, getDialog(), 0));
        } else if (choiceMode instanceof SingleChoiceMode) {
            adapter.setOnItemClickListener(
                    new OnItemClickListenerWrapper(singleChoiceListener, getDialog(), 0));
        } else {
            adapter.setOnItemClickListener(
                    new OnItemClickListenerWrapper(singleChoiceListener, getDialog(),
                            DialogInterface.BUTTON_POSITIVE));
        }
    }
455862
private AnimatorListener createCancelAnimationListener() {
        return new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(final Animator animation) {
                super.onAnimationEnd(animation);
                AbstractAnimateableDialog.super.cancel();
            }

        };
    }
1170347
public final AbstractOutput[] getListener() {
        final AbstractOutput[] returnVal = new AbstractOutput[listeners.length];
        System.arraycopy(listeners, 0, returnVal, 0, returnVal.length);
        return returnVal;
    }
1006584
private OnMultiChoiceClickListener createMultiChoiceListener() {
        return new OnMultiChoiceClickListener() {

            @Override
            public void onClick(final DialogInterface dialog, final int position,
                                final boolean isChecked) {
                String text = getString(R.string.multi_choice_listener_selected_text);

                if (!isChecked) {
                    text = getString(R.string.multi_choice_listener_unselected_text);
                }

                if (toast != null) {
                    toast.cancel();
                }

                showToast(String.format(text, position));
            }

        };
    }
482924
public AcceptListener getAcceptListener() {
        if (tc.isEntryEnabled())
            SibTr.entry(this, tc, "getAcceptListener");
        if (tc.isEntryEnabled())
            SibTr.exit(this, tc, "getAcceptListener", acceptListener);
        return acceptListener;
    }
1266775
private View.OnTouchListener createCancelOnTouchListener() {
        return new View.OnTouchListener() {

            @Override
            public boolean onTouch(final View v, final MotionEvent event) {
                if (cancelable && canceledOnTouchOutside) {
                    cancel();
                    v.performClick();
                    return true;
                }

                return false;
            }

        };
    }
749871
public final synchronized void addListener(EventListener l) {
        if(l ==null) {
            throw new IllegalArgumentException("Listener " + l +
                                               " is null");
        }
        if(listeners == EMPTY_LISTENERS) {
            listeners = new EventListener[1];
            listeners[0] = l;
        }
        else {
            int i = listeners.length;
            EventListener[] tmp = new EventListener[i+1];
            System.arraycopy(listeners, 0, tmp, 0, i);

            tmp[i] = l;
            listeners = tmp;
        }
    }
859894
public T longClicked(View.OnLongClickListener listener) {

        if (view != null) {
            view.setOnLongClickListener(listener);
        }

        return self();
    }
1188667
protected Future<T> addToListeners(
    final GenericCompletionListener<? extends Future<T>> listener) {
    if (listener == null) {
      throw new IllegalArgumentException("The listener can't be null.");
    }

    synchronized(this) {
      listeners.add(listener);
    }

    if(isDone()) {
      notifyListeners();
    }

    return this;
  }
1202556
public static Button.ClickListener createClickListener(final Runnable action) {

        return new Button.ClickListener() {

            /** Serial version id. */
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {

                action.run();
            }
        };
    }