mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c49062618e | ||
|
|
000a26645e |
No files matched your search
Generated
-1
@@ -4,7 +4,6 @@
|
||||
<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">
|
||||
|
||||
Generated
+2
-1
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -116,7 +116,6 @@ public class DocumentImpl implements Document{
|
||||
|
||||
documentDetail.setMeta(documentMeta);
|
||||
documentDetail.setAuthor(documentEntity.author);
|
||||
documentDetail.setPath(documentPath);
|
||||
documentDetail.setDefaultBranch(documentEntity.defaultBranch);
|
||||
|
||||
return documentDetail;
|
||||
@@ -133,7 +132,6 @@ public class DocumentImpl implements Document{
|
||||
|
||||
documentDetail.setMeta(meta);
|
||||
documentDetail.setAuthor("author"); // TODO-rca: SharedPrefを扱う機能を作ってそこから取得するようにする or Gitの設定を参照するようにする
|
||||
documentDetail.setPath(new DocumentPath(deviceInfoUtils.getExternalStorageDirectoryString(), meta.getId()));
|
||||
documentDetail.setDefaultBranch("master"); // TODO-rca: SharedPrefを扱う機能を作ってそこから取得するようにする?
|
||||
|
||||
return documentDetail;
|
||||
|
||||
@@ -8,22 +8,20 @@ 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;
|
||||
|
||||
//documentMetas アダプターが表示するデータ
|
||||
public DocumentAdapter(ArrayList<ListItem> documentMetas) {
|
||||
// nullの場合でも例外を発生させない
|
||||
this.documentMetas = documentMetas != null ? documentMetas : new ArrayList<>();
|
||||
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;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -35,11 +33,9 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
||||
ListItem documentMeta = documentMetas.get(position);
|
||||
DocumentMeta documentMeta = documentMetas.get(position);
|
||||
if (documentMeta != null) {
|
||||
holder.title.setText(documentMeta.getTitle());
|
||||
} else {
|
||||
holder.title.setText("データがありません");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
+9
-52
@@ -1,6 +1,5 @@
|
||||
package one.nem.lacerta.feature.library;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,16 +22,9 @@ 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
|
||||
@@ -44,11 +36,6 @@ 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";
|
||||
@@ -87,61 +74,31 @@ 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);
|
||||
|
||||
try {
|
||||
LacertaLibrary lacertaLibrary = new LacertaLibraryImpl();
|
||||
// Dagger Hiltを使用して依存性を注入
|
||||
// ドキュメントのメタデータを取得
|
||||
LibraryItemPage libraryItemPage = lacertaLibrary.getLibraryPage(100);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||
documentRecyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
//データを取得
|
||||
|
||||
if (libraryItemPage != null) {
|
||||
// ドキュメントのメタデータが取得できた場合の処理
|
||||
List<ListItem> metas = libraryItemPage.getListItems();
|
||||
List<DocumentMeta> metas = document.getAllDocumentMetas(100);
|
||||
|
||||
// ドキュメントをデフォルトフォルダに追加
|
||||
// フォルダごとにドキュメントを管理する
|
||||
for (ListItem meta : metas) {
|
||||
folderManager.addDocumentToFolder("Default Folder", meta);
|
||||
}
|
||||
Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
||||
|
||||
// 特定のフォルダのドキュメントを取得
|
||||
List<ListItem> folderDocuments = folderManager.getDocumentInFolder("Default Folder");
|
||||
// Create and set the adapter
|
||||
DocumentAdapter adapter = new DocumentAdapter(metas);
|
||||
documentRecyclerView.setAdapter(adapter);
|
||||
|
||||
// トーストメッセージでドキュメントの数を表示
|
||||
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();
|
||||
}
|
||||
// Use a LinearLayoutManager to specify the layout
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.nio.file.Path;
|
||||
import java.util.Date;
|
||||
|
||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
|
||||
/**
|
||||
@@ -19,9 +20,9 @@ public class DocumentDetail {
|
||||
DocumentMeta meta;
|
||||
|
||||
/**
|
||||
* ドキュメントのパス(DocumentPathインスタンス)
|
||||
* ユーザーが扱うパス
|
||||
*/
|
||||
DocumentPath path;
|
||||
PublicPath publicPath;
|
||||
|
||||
/**
|
||||
* ドキュメントの作者(String)
|
||||
@@ -39,9 +40,9 @@ public class DocumentDetail {
|
||||
public DocumentDetail() {
|
||||
}
|
||||
|
||||
public DocumentDetail(DocumentMeta meta, DocumentPath path, String author, String defaultBranch) {
|
||||
public DocumentDetail(DocumentMeta meta, PublicPath publicPath, String author, String defaultBranch) {
|
||||
this.meta = meta;
|
||||
this.path = path;
|
||||
this.publicPath = publicPath;
|
||||
this.author = author;
|
||||
this.defaultBranch = defaultBranch;
|
||||
}
|
||||
@@ -56,10 +57,10 @@ public class DocumentDetail {
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントのパス(DocumentPathインスタンス)を取得する
|
||||
* ユーザーが扱うパスを取得する
|
||||
*/
|
||||
public DocumentPath getPath() {
|
||||
return path;
|
||||
public PublicPath getPublicPath() {
|
||||
return publicPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,11 +96,11 @@ public class DocumentDetail {
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントのパス(DocumentPathインスタンス)を設定する
|
||||
* @param path DocumentPathインスタンス
|
||||
* ユーザーが扱うパスを設定する
|
||||
* @param publicPath ユーザーが扱うパス
|
||||
*/
|
||||
public void setPath(DocumentPath path) {
|
||||
this.path = path;
|
||||
public void setPublicPath(PublicPath publicPath) {
|
||||
this.publicPath = publicPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user