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() { lacertaApplyTagAdapter.setListener(new LacertaApplyTagAdapter.LacertaApplyTagDialogListener() {
@Override @Override
public void itemChecked(View view, String tagId) { public void itemChecked(View view, String tagId) {
// Do something applyChangeToVariable(true, tagId);
Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void itemUnchecked(View view, String tagId) { public void itemUnchecked(View view, String tagId) {
// Do something applyChangeToVariable(false, tagId);
Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show();
} }
}); });
@ -132,6 +130,14 @@ public class LacertaApplyTagDialog extends DialogFragment {
return builder.create(); 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) { private CompletableFuture<ArrayList<DocumentTagApplyTagDialogExtendedModel>> getDocumentTagArrayList(String documentId) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList = new ArrayList<>(); ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList = new ArrayList<>();