From 13a2130df6d25857cba5ec6464e5ef6c5386edf3 Mon Sep 17 00:00:00 2001 From: nero Date: Wed, 17 Jan 2024 11:14:25 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=A8=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E5=B0=91?= =?UTF-8?q?=E3=81=97=E6=9B=B8=E3=81=8D=E6=8F=9B=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/DocumentAdapter.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 index d312f3d8..4c270dcd 100644 --- 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 @@ -13,23 +13,21 @@ 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 { - + // アダプターが保持するデータ private ArrayList documentMetas; - + //documentMetas アダプターが表示するデータ public DocumentAdapter(ArrayList documentMetas) { - // nullの場合に例外を発生させる - if (documentMetas == null) { - throw new IllegalArgumentException("DocumentMetas list cannot be null or empty"); - } - this.documentMetas = documentMetas; + // nullの場合でも例外を発生させないよう修正 + this.documentMetas = documentMetas != null ? documentMetas : new ArrayList<>(); } @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);// 適切な id に変更する + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_library_menu, parent, false); return new DocumentViewHolder(view); } @@ -38,7 +36,7 @@ public class DocumentAdapter extends RecyclerView.Adapter