mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
保存されたデータを一覧表示できるようにした
This commit is contained in:
parent
c2ee49d274
commit
017748b4a6
|
@ -10,12 +10,14 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
|
||||
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
||||
|
||||
private List<String> documentList;
|
||||
private List<DocumentMeta> documentMetas;
|
||||
|
||||
public DocumentAdapter(List<String> documentList) {
|
||||
this.documentList = documentList;
|
||||
public DocumentAdapter(List<DocumentMeta> documentMetas) {
|
||||
this.documentMetas = documentMetas;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -27,12 +29,13 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
||||
holder.title.setText(documentList.get(position));
|
||||
// DocumentMeta から適切な情報を取得してセット
|
||||
holder.title.setText(documentMetas.get(position).getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return documentList.size();
|
||||
return documentMetas.size();
|
||||
}
|
||||
|
||||
class DocumentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
@ -40,7 +43,7 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
|||
|
||||
DocumentViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.debug_menu_item_title);
|
||||
title = itemView.findViewById(R.id.debug_menu_item_title); // 適切な id に変更する
|
||||
}
|
||||
}
|
||||
}
|
|
@ -88,20 +88,21 @@ public class LibraryTopFragment extends Fragment {
|
|||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||
documentRecyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
//ダミーデータを取得
|
||||
List<DocumentMeta> metas = new ArrayList<>();
|
||||
|
||||
metas = document.getAllDocumentMetas(100);
|
||||
|
||||
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");
|
||||
//仮データを取得
|
||||
// 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(documentList);
|
||||
DocumentAdapter adapter = new DocumentAdapter(metas);
|
||||
documentRecyclerView.setAdapter(adapter);
|
||||
|
||||
// Use a LinearLayoutManager to specify the layout
|
||||
|
|
Loading…
Reference in New Issue
Block a user