mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
コメントと例外が起こった際の処理を入れた
This commit is contained in:
parent
017748b4a6
commit
c35c4e829e
|
@ -16,7 +16,12 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
|||
|
||||
private List<DocumentMeta> documentMetas;
|
||||
|
||||
|
||||
public DocumentAdapter(List<DocumentMeta> documentMetas) {
|
||||
// nullの場合に例外を発生させる
|
||||
if (documentMetas == null) {
|
||||
throw new IllegalArgumentException("DocumentMetas list cannot be null");
|
||||
}
|
||||
this.documentMetas = documentMetas;
|
||||
}
|
||||
|
||||
|
@ -31,6 +36,11 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
|||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
||||
// DocumentMeta から適切な情報を取得してセット
|
||||
holder.title.setText(documentMetas.get(position).getTitle());
|
||||
|
||||
DocumentMeta documentMeta = documentMetas.get(position);
|
||||
if (documentMeta != null) {
|
||||
holder.title.setText(documentMeta.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -95,12 +95,6 @@ public class LibraryTopFragment extends Fragment {
|
|||
|
||||
Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
||||
|
||||
//仮データを取得
|
||||
// List<String> documentList = new ArrayList<>();
|
||||
// documentList.add("Document A");
|
||||
// documentList.add("Document B");
|
||||
// documentList.add("Document C");
|
||||
|
||||
// Create and set the adapter
|
||||
DocumentAdapter adapter = new DocumentAdapter(metas);
|
||||
documentRecyclerView.setAdapter(adapter);
|
||||
|
|
Loading…
Reference in New Issue
Block a user