use of android.app.Activity.RESULT_OK in project PocketHub by pockethub.
the class LabelsDialogFragment method onCreateDialog.
@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();
}
use of android.app.Activity.RESULT_OK in project PocketHub by pockethub.
the class AssigneeDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
int selected = getArguments().getInt(ARG_SELECTED_CHOICE);
GroupAdapter adapter = new GroupAdapter();
for (User user : getChoices()) {
adapter.add(new AssigneeDialogItem(avatars, user, selected));
}
return createDialogBuilder().adapter(adapter, null).negativeText(R.string.cancel).neutralText(R.string.clear).onNeutral((dialog, which) -> onResult(RESULT_OK)).build();
}
Aggregations