From 9a56846e3a02243987a5e7aab37e70330a5451ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 12 Jan 2024 12:24:30 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0=E3=83=AD?= =?UTF-8?q?=E3=82=B8=E3=83=83=E3=82=AF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DebugMenuLibraryItemListPageFragment.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuLibraryItemListPageFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuLibraryItemListPageFragment.java index 26d07e91..c58cacf1 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuLibraryItemListPageFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuLibraryItemListPageFragment.java @@ -2,19 +2,38 @@ package one.nem.lacerta.feature.debug; import android.os.Bundle; +import androidx.annotation.AnimatorRes; import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.ArrayList; + +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.data.LacertaLibrary; + +import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.model.ListItem; +import one.nem.lacerta.model.ListItemType; /** * A simple {@link Fragment} subclass. * Use the {@link DebugMenuLibraryItemListPageFragment#newInstance} factory method to * create an instance of this fragment. */ +@AndroidEntryPoint public class DebugMenuLibraryItemListPageFragment extends Fragment { + @Inject + LacertaLibrary lacertaLibrary; + public DebugMenuLibraryItemListPageFragment() { // Required empty public constructor } @@ -37,7 +56,61 @@ public class DebugMenuLibraryItemListPageFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false); + LibraryItemPage libraryItemPage = lacertaLibrary.getLibraryPage(10); + for (ListItem listItem : libraryItemPage.getListItems()) { + System.out.println(listItem.getTitle()); + } + + RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view); + + ArrayList listItems = libraryItemPage.getListItems(); + + ItemAdapter itemAdapter = new ItemAdapter(listItems); + recyclerView.setAdapter(itemAdapter); return view; } + + private class ItemAdapter extends RecyclerView.Adapter { + private ArrayList listItems; + + public ItemAdapter(ArrayList listItems) { + this.listItems = listItems; + } + + @Override + public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_debug_menu_document, parent, false); + return new ItemViewHolder(view); + } + + @Override + public void onBindViewHolder(ItemViewHolder holder, int position) { + ListItem listItem = listItems.get(position); + holder.document_list_item_title.setText(listItem.getTitle()); + holder.document_list_item_description.setText(listItem.getDescription()); + holder.document_list_item_updated_at.setText(listItem.getItemType().toString()); + } + + @Override + public int getItemCount() { + return listItems.size(); + } + + public class ItemViewHolder extends RecyclerView.ViewHolder { + + TextView document_list_item_title; + TextView document_list_item_description; + TextView document_list_item_updated_at; + + + public ItemViewHolder(View itemView) { + super(itemView); + document_list_item_title = itemView.findViewById(R.id.document_list_item_title); + document_list_item_description = itemView.findViewById(R.id.document_list_item_description); + document_list_item_updated_at = itemView.findViewById(R.id.document_list_item_updated_at); + } + } + } + } \ No newline at end of file