mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-30 03:23:16 +00:00
ListItemPageを宣言
ListItemのコードを削除
This commit is contained in:
parent
87e734332c
commit
341b694298
|
@ -8,15 +8,17 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
|
|
||||||
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
||||||
|
|
||||||
private List<DocumentMeta> documentMetas;
|
private ArrayList<ListItem> documentMetas;
|
||||||
|
|
||||||
public DocumentAdapter(List<DocumentMeta> documentMetas) {
|
public DocumentAdapter(ArrayList<ListItem> documentMetas) {
|
||||||
// nullの場合に例外を発生させる
|
// nullの場合に例外を発生させる
|
||||||
if (documentMetas == null) {
|
if (documentMetas == null) {
|
||||||
throw new IllegalArgumentException("DocumentMetas list cannot be null or empty");
|
throw new IllegalArgumentException("DocumentMetas list cannot be null or empty");
|
||||||
|
@ -33,7 +35,7 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
||||||
DocumentMeta documentMeta = documentMetas.get(position);
|
ListItem documentMeta = documentMetas.get(position);
|
||||||
if (documentMeta != null) {
|
if (documentMeta != null) {
|
||||||
holder.title.setText(documentMeta.getTitle());
|
holder.title.setText(documentMeta.getTitle());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package one.nem.lacerta.feature.library;
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
import static one.nem.lacerta.feature.library.LibraryUtils.convertToLibraryItems;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -117,14 +119,13 @@ public class LibraryTopFragment extends Fragment {
|
||||||
// トーストメッセージでドキュメントの数を表示
|
// トーストメッセージでドキュメントの数を表示
|
||||||
Toast.makeText(getContext(), "ドキュメント数: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), "ドキュメント数: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
// Create and set the adapter
|
//LibraryItemPageを使用してadapterを設定
|
||||||
DocumentAdapter adapter = new DocumentAdapter(metas);
|
LibraryItemPage libraryItemPage = new LibraryItemPage("Page Title", "Page ID", convertToLibraryItems(metas));
|
||||||
|
DocumentAdapter adapter = new DocumentAdapter(libraryItemPage.getListItems());
|
||||||
documentRecyclerView.setAdapter(adapter);
|
documentRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
// Use a LinearLayoutManager to specify the layout
|
// Use a LinearLayoutManager to specify the layout
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
private ArrayList<ListItem> convertToLibraryItems(List<DocumentMeta> metas) {
|
|
||||||
return LibraryUtils.convertToLibraryItems(metas);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user