From 209eab07554ae3ef9abdf9636e075bb03f606d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 19 Jan 2024 18:28:26 +0900 Subject: [PATCH] =?UTF-8?q?ListItemAdapter=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/feature/home/ListItemAdapter.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java new file mode 100644 index 00000000..2a5547ea --- /dev/null +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java @@ -0,0 +1,59 @@ +package one.nem.lacerta.feature.home; + +import android.media.Image; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import one.nem.lacerta.model.ListItem; + +public class ListItemAdapter extends RecyclerView.Adapter{ + + ArrayList listItems; + + public ListItemAdapter(ArrayList listItems){ + this.listItems = listItems; + } + + @NonNull + @Override + public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.component.common.R.layout.common_library_list_item, parent, false); + return new ListItemViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) { + ListItem listItem = listItems.get(position); + holder.icon.setImageResource(listItem.getItemType().getIconId()); + holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnBackground); + holder.title.setText(listItem.getTitle()); + holder.description.setText(listItem.getDescription()); + } + + @Override + public int getItemCount() { + return 0; + } + + public static class ListItemViewHolder extends RecyclerView.ViewHolder{ + + ImageView icon; + TextView title; + TextView description; + public ListItemViewHolder(@NonNull View itemView) { + super(itemView); + + icon = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_icon); + title = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_title); + description = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_description); + } + } +}