登録されているタグ一覧の取得を切り出し

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

View File

@ -135,21 +135,20 @@ public class LacertaApplyTagDialog extends DialogFragment {
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<>();
lacertaLibrary.getTagList().thenAccept(documentTags -> { setRegisteredTagList().thenAccept(Void -> {
setAppliedTagList(documentId); setAppliedTagList(documentId).join();
for (int i = 0; i < documentTags.size(); i++) { for (int i = 0; i < this.registeredTags.size(); i++) {
boolean isChecked = false; boolean isChecked = false;
for (int j = 0; j < this.appliedTags.size(); j++) { for (int j = 0; j < this.appliedTags.size(); j++) {
if (documentTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) {
isChecked = true; isChecked = true;
break; break;
} }
} }
documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel(
new DocumentTag(documentTags.get(i).getId(), documentTags.get(i).getName(), documentTags.get(i).getColor()), isChecked)); new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked));
} }
}); });
return documentTagArrayList; return documentTagArrayList;
}); });
} }
@ -162,10 +161,12 @@ public class LacertaApplyTagDialog extends DialogFragment {
}); });
} }
private void setRegisteredTagList() { private CompletableFuture<Void> setRegisteredTagList() {
return CompletableFuture.runAsync(() -> {
lacertaLibrary.getTagList().thenAccept(documentTags -> { lacertaLibrary.getTagList().thenAccept(documentTags -> {
this.registeredTags = documentTags; this.registeredTags = documentTags;
}); });
});
} }
} }