From 866b8270fe57cc6d6b907b54ec0cbbc06f67deac Mon Sep 17 00:00:00 2001 From: nero Date: Tue, 19 Dec 2023 12:45:41 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BB=AE=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E5=87=BA=E5=8A=9B=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E8=AA=BF=E6=95=B4=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/DocumentAdapter.java | 46 +++++++++++++++++++ .../feature/library/LibraryTopFragment.java | 44 ++---------------- .../main/res/layout/fragment_library_top.xml | 15 +++--- .../res/layout/list_item_library_menu.xml | 26 +++++++++++ 4 files changed, 83 insertions(+), 48 deletions(-) create mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/DocumentAdapter.java create mode 100644 feature/library/src/main/res/layout/list_item_library_menu.xml diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/DocumentAdapter.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/DocumentAdapter.java new file mode 100644 index 00000000..12b4fdef --- /dev/null +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/DocumentAdapter.java @@ -0,0 +1,46 @@ +package one.nem.lacerta.feature.library; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +public class DocumentAdapter extends RecyclerView.Adapter { + + private List documentList; + + public DocumentAdapter(List documentList) { + this.documentList = documentList; + } + + @NonNull + @Override + public DocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_library_menu, parent, false); + return new DocumentViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) { + holder.title.setText(documentList.get(position)); + } + + @Override + public int getItemCount() { + return documentList.size(); + } + + class DocumentViewHolder extends RecyclerView.ViewHolder { + TextView title; + + DocumentViewHolder(View itemView) { + super(itemView); + title = itemView.findViewById(R.id.debug_menu_item_title); + } + } +} \ No newline at end of file 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 1af45258..866b2521 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 @@ -65,45 +65,6 @@ public class LibraryTopFragment extends Fragment { } - public class DocumentAdapter extends RecyclerView.Adapter { - - private List documentList; - - public DocumentAdapter(List documentList) { - this.documentList = documentList; - } - - @NonNull - @Override - public DocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, parent, false); - return new DocumentViewHolder(view); - } - - @Override - public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) { - holder.bind(documentList.get(position)); - } - - @Override - public int getItemCount() { - return documentList.size(); - } - - class DocumentViewHolder extends RecyclerView.ViewHolder { - private final TextView textView; - - DocumentViewHolder(View itemView) { - super(itemView); - textView = itemView.findViewById(android.R.id.text1); - } - - void bind(String document) { - textView.setText(document); - } - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment @@ -112,6 +73,9 @@ public class LibraryTopFragment extends Fragment { // Use view.findViewById instead of findViewById RecyclerView documentRecyclerView = view.findViewById(R.id.document_list); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + documentRecyclerView.setLayoutManager(layoutManager); + List documentList = new ArrayList<>(); documentList.add("Document A"); documentList.add("Document B"); @@ -122,8 +86,6 @@ public class LibraryTopFragment extends Fragment { documentRecyclerView.setAdapter(adapter); // Use a LinearLayoutManager to specify the layout - LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext()); - documentRecyclerView.setLayoutManager(layoutManager); return view; } } diff --git a/feature/library/src/main/res/layout/fragment_library_top.xml b/feature/library/src/main/res/layout/fragment_library_top.xml index dcb7edf9..b0d824e5 100644 --- a/feature/library/src/main/res/layout/fragment_library_top.xml +++ b/feature/library/src/main/res/layout/fragment_library_top.xml @@ -1,23 +1,24 @@ - + app:layout_constraintTop_toTopOf="parent" + app:title="Library" + app:titleTextColor="@color/colorOnPrimaryContainer" /> + app:layout_constraintTop_toBottomOf="@+id/tool_bar" /> - \ No newline at end of file + \ No newline at end of file diff --git a/feature/library/src/main/res/layout/list_item_library_menu.xml b/feature/library/src/main/res/layout/list_item_library_menu.xml new file mode 100644 index 00000000..277da422 --- /dev/null +++ b/feature/library/src/main/res/layout/list_item_library_menu.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file