CheckBoxの変化に応じてインスタンス変数のTagListを変化させるように

This commit is contained in:
r-ca 2024-01-29 00:44:02 +09:00
parent f2f4c77016
commit d66546a567
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -98,14 +98,12 @@ public class LacertaApplyTagDialog extends DialogFragment {
lacertaApplyTagAdapter.setListener(new LacertaApplyTagAdapter.LacertaApplyTagDialogListener() {
@Override
public void itemChecked(View view, String tagId) {
// Do something
Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show();
applyChangeToVariable(true, tagId);
}
@Override
public void itemUnchecked(View view, String tagId) {
// Do something
Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show();
applyChangeToVariable(false, tagId);
}
});
@ -132,6 +130,14 @@ public class LacertaApplyTagDialog extends DialogFragment {
return builder.create();
}
private void applyChangeToVariable(boolean isChecked, String tagId) {
if (isChecked) {
this.registeredTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.add(tag));
} else {
this.appliedTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.remove(tag));
}
}
private CompletableFuture<ArrayList<DocumentTagApplyTagDialogExtendedModel>> getDocumentTagArrayList(String documentId) {
return CompletableFuture.supplyAsync(() -> {
ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList = new ArrayList<>();