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