@NonNull
    @Override
    public Dialog onCreateDialog(final Bundle savedInstanceState) {
        selectedChoices = getArguments().getBooleanArray(ARG_SELECTED_CHOICES);

        ArrayList<Label> choices = getChoices();
        List<String> selected = new ArrayList<>();
        if (selectedChoices != null) {
            for (int i = 0; i < choices.size(); i++) {
                if (selectedChoices[i]) {
                    selected.add(choices.get(i).name());
                }
            }
        }

        adapter = new GroupAdapter();
        for (Label label : getChoices()) {
            adapter.add(new LabelDialogItem(label, selected.contains(label.name())));
        }
        adapter.setOnItemClickListener(this);

        return createDialogBuilder()
                .adapter(adapter, null)
                .negativeText(R.string.cancel)
                .neutralText(R.string.clear)
                .positiveText(R.string.apply)
                .onNeutral((dialog, which) -> {
                    Arrays.fill(getArguments().getBooleanArray(ARG_SELECTED_CHOICES), false);
                    onResult(RESULT_OK);
                })
                .onPositive((dialog, which) -> onResult(RESULT_OK))
                .build();
    }
Confirm message and deliver callback to given activity

@param activity
@param requestCode
@param title
@param message
@param choices
@param selectedChoices
app/src/main/java/com/github/pockethub/android/ui/issue/LabelsDialogFragment.java