diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 913621a8..aabc81d5 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -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> getDocumentTagArrayList(String documentId) { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>();