From 751089a73a921faf329f75ebedbbaf57b558a553 Mon Sep 17 00:00:00 2001 From: nero Date: Fri, 22 Dec 2023 12:24:01 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A9=9F=E8=83=BD=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=BF=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/LibraryFolderFragment.java | 32 +++++++++++++++++++ .../feature/library/LibraryTopFragment.java | 12 ++++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryFolderFragment.java diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryFolderFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryFolderFragment.java new file mode 100644 index 00000000..8d19d589 --- /dev/null +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryFolderFragment.java @@ -0,0 +1,32 @@ +package one.nem.lacerta.feature.library; + +import androidx.fragment.app.Fragment; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import one.nem.lacerta.model.document.DocumentMeta; + +public class LibraryFolderFragment extends Fragment{ + + private Map> folderMap; + + public LibraryFolderFragment() { + folderMap = new HashMap<>(); + } + + public void addDocumentToFolder(String folderName, DocumentMeta documentMeta) { + if (!folderMap.containsKey(folderName)) { + folderMap.put(folderName, new ArrayList<>()); + } + + List documents = folderMap.get(folderName); + documents.add(documentMeta); + } + + public List getDocumentsInFolder(String folderName) { + return folderMap.getOrDefault(folderName, new ArrayList<>()); + } + } diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java index eb672856..4c555da0 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java @@ -36,6 +36,8 @@ public class LibraryTopFragment extends Fragment { @Inject Document document; + private LibraryFolderFragment folderManager; + // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER private static final String ARG_PARAM1 = "param1"; @@ -74,6 +76,7 @@ public class LibraryTopFragment extends Fragment { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } + folderManager = new LibraryFolderFragment(); } @@ -89,8 +92,15 @@ public class LibraryTopFragment extends Fragment { documentRecyclerView.setLayoutManager(layoutManager); //データを取得 + List metas = document.getAllDocumentMetas(100); - List metas = document.getAllDocumentMetas(100); + // フォルダごとにドキュメントを管理する + for (DocumentMeta meta : metas) { + folderManager.addDocumentToFolder("Default Folder", meta); + } + + // 特定のフォルダのドキュメントを取得 + List folderDocuments = folderManager.getDocumentsInFolder("Default Folder"); Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();