From ffeb701b40c2d468fbea443f516f0f9f9c76a297 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 27 Jan 2024 15:26:18 +0900 Subject: [PATCH] =?UTF-8?q?RevDialogAdapter=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/SelectRevDialogItemAdapter.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/SelectRevDialogItemAdapter.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/SelectRevDialogItemAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/SelectRevDialogItemAdapter.java new file mode 100644 index 00000000..217bd929 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/SelectRevDialogItemAdapter.java @@ -0,0 +1,64 @@ +package one.nem.lacerta.component.common; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; + +import one.nem.lacerta.model.VcsRevModel; + +public class SelectRevDialogItemAdapter extends RecyclerView.Adapter{ + + ArrayList revList; + + LacertaSelectRevDialogListener listener; + + public SelectRevDialogItemAdapter(LacertaSelectRevDialogListener listener) { + this.listener = listener; + } + + public void setRevList(ArrayList revList) { + this.revList = revList; + } + + @NonNull + @Override + public SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_rev_list_item, parent, false); + return new SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder holder, int position) { + VcsRevModel rev = revList.get(position); + holder.title.setText(rev.getCommitMessage()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + holder.description.setText(simpleDateFormat.format(rev.getCreatedAt())); + holder.revId.setText("RevID: " + rev.getId()); + } + + @Override + public int getItemCount() { + return this.revList == null ? 0 : this.revList.size(); + } + + public class SelectRevDialogItemViewHolder extends RecyclerView.ViewHolder { + + TextView title; + TextView description; + TextView revId; + + public SelectRevDialogItemViewHolder(@NonNull View itemView) { + super(itemView); + title = itemView.findViewById(R.id.rev_item_title); + description = itemView.findViewById(R.id.rev_item_detail); + revId = itemView.findViewById(R.id.rev_item_id); + } + } +}