拡張モデルを使うようにアダプタを修正

This commit is contained in:
r-ca 2024-01-29 00:14:02 +09:00
parent 425616c335
commit d562447777
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel;
import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.model.document.tag.DocumentTag;
public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTagAdapter.LacertaApplyTagViewHolder>{ public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTagAdapter.LacertaApplyTagViewHolder>{
@ -21,7 +22,7 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTag
} }
// Variables // Variables
private ArrayList<DocumentTag> documentTagArrayList; private ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList;
private LacertaApplyTagDialogListener listener; private LacertaApplyTagDialogListener listener;
// Setter // Setter
@ -30,14 +31,13 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTag
return this; return this;
} }
public LacertaApplyTagAdapter setDocumentTagArrayList(ArrayList<DocumentTag> documentTagArrayList) { public LacertaApplyTagAdapter setDocumentTagArrayList(ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList) {
this.documentTagArrayList = documentTagArrayList; this.documentTagArrayList = documentTagArrayList;
return this; return this;
} }
// Constructor // Empty constructor
public LacertaApplyTagAdapter(ArrayList<DocumentTag> documentTagArrayList) { public LacertaApplyTagAdapter() {
this.documentTagArrayList = documentTagArrayList;
} }
@NonNull @NonNull
@ -49,8 +49,9 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTag
@Override @Override
public void onBindViewHolder(@NonNull LacertaApplyTagAdapter.LacertaApplyTagViewHolder holder, int position) { public void onBindViewHolder(@NonNull LacertaApplyTagAdapter.LacertaApplyTagViewHolder holder, int position) {
DocumentTag documentTag = documentTagArrayList.get(position); DocumentTagApplyTagDialogExtendedModel documentTag = documentTagArrayList.get(position);
holder.checkBox.setText(documentTag.getName()); holder.checkBox.setText(documentTag.getName());
holder.checkBox.setChecked(documentTag.getIsChecked());
holder.checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> { holder.checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) { if (isChecked) {
listener.itemChecked(buttonView, position); listener.itemChecked(buttonView, position);