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();