mirror of
				https://github.com/lacerta-doc/Lacerta.git
				synced 2025-11-04 00:40:49 +00:00 
			
		
		
		
	メタデータを取得できるようになった
(LacertaLibraryを使用して。)
This commit is contained in:
		
							parent
							
								
									23668c50e6
								
							
						
					
					
						commit
						391c093437
					
				@ -24,6 +24,7 @@ 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;
 | 
			
		||||
 | 
			
		||||
@ -105,43 +106,39 @@ public class LibraryTopFragment extends Fragment {
 | 
			
		||||
        documentRecyclerView.setLayoutManager(layoutManager);
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            LacertaLibrary lacertaLibrary = new LacertaLibraryImpl();
 | 
			
		||||
            // ドキュメントのメタデータを取得
 | 
			
		||||
            List<ListItem> metas = (List<ListItem>) LacertaLibrary.getLibraryPage(100);
 | 
			
		||||
            LibraryItemPage libraryItemPage = lacertaLibrary.getLibraryPage(100);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (metas != null) {
 | 
			
		||||
            if (libraryItemPage != null) {
 | 
			
		||||
                // ドキュメントのメタデータが取得できた場合の処理
 | 
			
		||||
                LibraryItemPage libraryItemPage = new LibraryItemPage("Page Title", "Page ID", convertToLibraryItems(metas));
 | 
			
		||||
                List<ListItem> metas = libraryItemPage.getListItems();
 | 
			
		||||
 | 
			
		||||
                // ドキュメントをデフォルトフォルダに追加
 | 
			
		||||
                // フォルダごとにドキュメントを管理する
 | 
			
		||||
                for (ListItem meta : metas) {
 | 
			
		||||
                    folderManager.addDocumentToFolder("Default Folder", meta);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            // ドキュメントをデフォルトフォルダに追加
 | 
			
		||||
            // フォルダごとにドキュメントを管理する
 | 
			
		||||
            for (ListItem meta : metas) {
 | 
			
		||||
                folderManager.addDocumentToFolder("Default Folder", meta);
 | 
			
		||||
            }
 | 
			
		||||
                // 特定のフォルダのドキュメントを取得
 | 
			
		||||
                List<ListItem> folderDocuments = folderManager.getDocumentInFolder("Default Folder");
 | 
			
		||||
 | 
			
		||||
                // トーストメッセージでドキュメントの数を表示
 | 
			
		||||
                Toast.makeText(getActivity(), "ドキュメント数: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
 | 
			
		||||
 | 
			
		||||
            // 特定のフォルダのドキュメントを取得
 | 
			
		||||
            List<ListItem> folderDocuments = folderManager.getDocumentInFolder("Default Folder");
 | 
			
		||||
 | 
			
		||||
            // トーストメッセージでドキュメントの数を表示
 | 
			
		||||
            Toast.makeText(getContext(), "ドキュメント数: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
 | 
			
		||||
 | 
			
		||||
//LibraryItemPageを使用してadapterを設定
 | 
			
		||||
            DocumentAdapter adapter = new DocumentAdapter(libraryItemPage.getListItems());
 | 
			
		||||
            documentRecyclerView.setAdapter(adapter);
 | 
			
		||||
 | 
			
		||||
                // LibraryItemPageを使用してadapterを設定
 | 
			
		||||
                DocumentAdapter adapter = new DocumentAdapter((ArrayList<ListItem>) metas);
 | 
			
		||||
                documentRecyclerView.setAdapter(adapter);
 | 
			
		||||
            } else {
 | 
			
		||||
                // ドキュメントのメタデータが null の場合の処理
 | 
			
		||||
                Toast.makeText(getContext(), "ドキュメントメタデータが取得できませんでした", Toast.LENGTH_LONG).show();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            // 例外処理
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
// Use a LinearLayoutManager to specify the layout
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
            return view;
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5,18 +5,20 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import one.nem.lacerta.model.ListItem;
 | 
			
		||||
import one.nem.lacerta.model.document.DocumentMeta;
 | 
			
		||||
//ListItemとTopを結びつけるためのクラス
 | 
			
		||||
 | 
			
		||||
// DocumentMeta クラスのリストを ListItem クラスのリストに変換するためのユーティリティクラスの一部
 | 
			
		||||
public class LibraryUtils {
 | 
			
		||||
 | 
			
		||||
        public static ArrayList<ListItem> convertToLibraryItems(List<ListItem> metas) {
 | 
			
		||||
            ArrayList<ListItem> libraryItems = new ArrayList<>();
 | 
			
		||||
            for (DocumentMeta meta : metas) {
 | 
			
		||||
                ListItem listItem = new ListItem();
 | 
			
		||||
                listItem.setTitle(meta.getTitle());
 | 
			
		||||
                listItem.setDescription(meta.getTitle());
 | 
			
		||||
                // 他の必要な情報もListItemに設定する
 | 
			
		||||
                libraryItems.add(listItem);
 | 
			
		||||
            }
 | 
			
		||||
            return libraryItems;
 | 
			
		||||
    public static ArrayList<ListItem> convertToLibraryItems(List<DocumentMeta> metas) {
 | 
			
		||||
        ArrayList<ListItem> libraryItems = new ArrayList<>();
 | 
			
		||||
        for (DocumentMeta meta : metas) {
 | 
			
		||||
            ListItem listItem = new ListItem();
 | 
			
		||||
            listItem.setTitle(meta.getTitle());
 | 
			
		||||
 | 
			
		||||
            listItem.setDescription(meta.getId());
 | 
			
		||||
 | 
			
		||||
            libraryItems.add(listItem);
 | 
			
		||||
        }
 | 
			
		||||
        return libraryItems;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user