Compare commits

...
Author SHA1 Message Date
nero efceb0dac7 コメント追加 2024-01-17 12:42:34 +09:00
nero 7ca947615b コメントの修正 2024-01-17 11:49:39 +09:00
nero b1af3f01f2 フォーマット整理 2024-01-17 11:36:38 +09:00
nero df95ce4405 Adapterのところを修正 2024-01-17 11:15:05 +09:00
nero 13a2130df6 コメント追加とコードを少し書き換えた 2024-01-17 11:14:25 +09:00
nero c668c188e0 コメントの追加とコードの修正 2024-01-17 10:13:55 +09:00
nero e7b2519de0 必要のないクラスと文の削除 2024-01-17 09:59:09 +09:00
nero 3f503e14a7 コメントの削除 2024-01-16 12:38:37 +09:00
nero 7d3d4a0ebf エラー時のトーストメッセージ出力 2024-01-16 12:14:14 +09:00
nero 391c093437 メタデータを取得できるようになった
(LacertaLibraryを使用して。)
2024-01-16 12:10:27 +09:00
nero 23668c50e6 コードの書き換えがなかなかうまくいってない 2024-01-16 11:10:35 +09:00
nero 341b694298 ListItemPageを宣言
ListItemのコードを削除
2024-01-16 10:00:34 +09:00
nero 87e734332c コメント追加 2024-01-16 09:49:49 +09:00
nero c65e6215fe LibraryUtilsとの結びつけ 2024-01-15 16:32:17 +09:00
nero 311dc21a07 ListItemの利用 2024-01-15 16:31:43 +09:00
nero 8620a4de64 DocumentMetaリストをLibraryItemPageに変換するユーティリティメソッド 2024-01-15 16:06:01 +09:00
nero 9c927d76dc 微修正 2024-01-15 15:35:46 +09:00
nero 006b19165e インポートとxmlコードの修正 2024-01-15 14:30:57 +09:00
r-ca 6acfe16e36 インポート修正 2024-01-14 18:54:40 +09:00
r-ca 0e25c96ec4 Merge remote-tracking branch 'origin/feature/library/add_document_list' into feature/library/add_document_list 2024-01-14 18:53:59 +09:00
r-ca a03f7111cc Merge remote-tracking branch 'origin/develop' into feature/library/add_document_list 2024-01-14 18:53:27 +09:00
nero 06bd6a1172 解決できない… 2024-01-14 18:44:43 +09:00
nero 84b9de17cf フォーマット 2024-01-12 09:56:51 +09:00
nero 63009b1a9a トーストメッセージを英語から日本語に変更 2024-01-11 15:40:04 +09:00
nero 49a7e9677c コメント追加 2024-01-11 14:25:19 +09:00
nero 5cbf1f4553 コメント追加 2023-12-22 12:41:55 +09:00
nero 751089a73a フォルダ管理機能を実装してみた。 2023-12-22 12:24:01 +09:00
5 changed files with 105 additions and 20 deletions

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
+1 -2
View File
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
@@ -8,20 +8,22 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
//RecyclerView 用のアダプタークラス
//アダプターはリストのデータを管理し、それを RecyclerView に表示する
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
// アダプターが保持するデータ
private ArrayList<ListItem> documentMetas;
private List<DocumentMeta> documentMetas;
public DocumentAdapter(List<DocumentMeta> documentMetas) {
// nullの場合に例外を発生させる
if (documentMetas == null) {
throw new IllegalArgumentException("DocumentMetas list cannot be null or empty");
}
this.documentMetas = documentMetas;
//documentMetas アダプターが表示するデータ
public DocumentAdapter(ArrayList<ListItem> documentMetas) {
// nullの場合でも例外を発生させない
this.documentMetas = documentMetas != null ? documentMetas : new ArrayList<>();
}
@NonNull
@@ -33,9 +35,11 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
@Override
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
DocumentMeta documentMeta = documentMetas.get(position);
ListItem documentMeta = documentMetas.get(position);
if (documentMeta != null) {
holder.title.setText(documentMeta.getTitle());
} else {
holder.title.setText("データがありません");
}
}
@@ -0,0 +1,38 @@
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.ListItem;
//フォルダ管理機能
public class LibraryFolderFragment extends Fragment {
private Map<String, List<ListItem>> folderMap;
public LibraryFolderFragment() {
folderMap = new HashMap<>();
}
public void addDocumentToFolder(String folderName, ListItem documentMeta) {
if (!folderMap.containsKey(folderName)) {
folderMap.put(folderName, new ArrayList<>());
}
List<ListItem> documents = folderMap.get(folderName);
documents.add(documentMeta);
}
//フォルダに関連するドキュメントを取得するためのメソッド
public List<ListItem> getDocumentsInFolder(String folderName) {
return folderMap.getOrDefault(folderName, new ArrayList<>());
}
public List<ListItem> getDocumentInFolder(String default_folder) {
return null;
}
}
@@ -1,5 +1,6 @@
package one.nem.lacerta.feature.library;
import android.os.Bundle;
import androidx.annotation.NonNull;
@@ -22,9 +23,16 @@ import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.impl.LacertaLibraryImpl;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
/**
* A simple {@link Fragment} subclass.
* Use the {@link LibraryTopFragment#newInstance} factory method to
@@ -36,6 +44,11 @@ public class LibraryTopFragment extends Fragment {
@Inject
Document document;
@Inject
LacertaLibrary lacertaLibrary;
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,31 +87,61 @@ public class LibraryTopFragment extends Fragment {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
folderManager = new LibraryFolderFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// レイアウトファイル(fragment_library_top.xml)をインフレートしてビューを作成
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
// レイアウトファイル内のRecyclerView要素を取得
// Use view.findViewById instead of findViewById
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
documentRecyclerView.setLayoutManager(layoutManager);
try {
LacertaLibrary lacertaLibrary = new LacertaLibraryImpl();
// Dagger Hiltを使用して依存性を注入
// ドキュメントのメタデータを取得
LibraryItemPage libraryItemPage = lacertaLibrary.getLibraryPage(100);
//データを取得
List<DocumentMeta> metas = document.getAllDocumentMetas(100);
if (libraryItemPage != null) {
// ドキュメントのメタデータが取得できた場合の処理
List<ListItem> metas = libraryItemPage.getListItems();
Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
// ドキュメントをデフォルトフォルダに追加
// フォルダごとにドキュメントを管理する
for (ListItem meta : metas) {
folderManager.addDocumentToFolder("Default Folder", meta);
}
// Create and set the adapter
DocumentAdapter adapter = new DocumentAdapter(metas);
documentRecyclerView.setAdapter(adapter);
// 特定のフォルダのドキュメントを取得
List<ListItem> folderDocuments = folderManager.getDocumentInFolder("Default Folder");
// Use a LinearLayoutManager to specify the layout
// トーストメッセージでドキュメントの数を表示
Toast.makeText(getActivity(), "ドキュメント数: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
// RecyclerViewのレイアウトマネージャーを設定
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
documentRecyclerView.setLayoutManager(layoutManager);
// LibraryItemPageを使用してadapterを設定
DocumentAdapter adapter = new DocumentAdapter((ArrayList<ListItem>) metas);
documentRecyclerView.setAdapter(adapter);
//RecyclerView の再描画
documentRecyclerView.invalidate();
} else {
// ドキュメントのメタデータが null の場合の処理
Toast.makeText(getContext(), "ドキュメントメタデータが取得できませんでした", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
// 例外処理
e.printStackTrace();
Toast.makeText(getContext(), "エラーが発生しました: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
return view;
}
}