From 9045cec67d189c83df92c1fd90e8ffd78c233446 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 23:13:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A?= =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 13 +++++++++++ .../feature/library/LibraryPageFragment.java | 8 +++++++ .../feature/library/ListItemAdapter.java | 23 ++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index b0052b70..5c65a2af 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -121,6 +121,19 @@ public class LacertaLibraryImpl implements LacertaLibrary { listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt)); listItem.setItemId(documentEntity.id); listItem.setHasCombined(documentEntity.isCombineParent); + // タグを取得して関連付ける処理 TODO-rca: わかりにくい + 責任がめちゃくちゃ + めちゃくちゃ重いのでなんとかする + List documentTagEntities = database.toxiDocumentTagDao().findByDocumentId(documentEntity.id); + ArrayList documentTags = new ArrayList<>(); + for (ToxiDocumentTagEntity toxiDocumentTagEntity : documentTagEntities) { + logger.debug("LacertaLibraryImpl", "toxiDocumentTagEntity.tagId: " + toxiDocumentTagEntity.tagId); + TagEntity tagEntity = database.tagDao().findById(toxiDocumentTagEntity.tagId); + if (tagEntity != null) { + logger.debug("LacertaLibraryImpl", "tagEntity.tagName: " + tagEntity.tagName); + documentTags.add(convertTagEntityToDocumentTag(tagEntity)); + } + } + listItem.setTagList(documentTags); + logger.debug("LacertaLibraryImpl", "documentTags.size(): " + documentTags.size()); listItems.add(listItem); } diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 7a37e9f1..158e61e1 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -21,9 +21,11 @@ import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.viewer.ViewerMainActivity; +import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.ListItemType; +import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; @@ -53,6 +55,9 @@ public class LibraryPageFragment extends Fragment { @Inject LacertaLogger logger; + @Inject + Document document; + ListItemAdapter listItemAdapter; public LibraryPageFragment() { @@ -233,6 +238,9 @@ public class LibraryPageFragment extends Fragment { }); } + private void getTag(String documentId) { //debug + } + /** * Toolbarのサブタイトルを更新 * @param subtitle サブタイトル diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/ListItemAdapter.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/ListItemAdapter.java index 57edf131..63014f09 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/ListItemAdapter.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/ListItemAdapter.java @@ -1,14 +1,19 @@ package one.nem.lacerta.feature.library; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.chip.Chip; +import com.google.android.material.chip.ChipGroup; + import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; @@ -31,7 +36,7 @@ public class ListItemAdapter extends RecyclerView.Adapter { if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) { listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined()); @@ -64,12 +83,14 @@ public class ListItemAdapter extends RecyclerView.Adapter