diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaFilePickerAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaFilePickerAdapter.java new file mode 100644 index 00000000..fa0163d2 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaFilePickerAdapter.java @@ -0,0 +1,33 @@ +package one.nem.lacerta.component.common.picker; + +import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase; +import one.nem.lacerta.model.ListItem; +import one.nem.lacerta.model.ListItemType; + +public class LacertaFilePickerAdapter extends LacertaFilePickerAdapterBase { + + // Listener + public interface LacertaFilePickerAdapterListener extends LacertaFilePickerAdapterBase.LacertaFilePickerAdapterListener { + void onDocumentSelected(String documentId); + } + + // Variables + LacertaFilePickerAdapterListener listener; + + // Setter + public LacertaFilePickerAdapter setListener(LacertaFilePickerAdapterListener listener) { + this.listener = listener; + return this; + } + + @Override + public void onBindViewHolder(LacertaFilePickerViewHolder holder, int position) { + super.onBindViewHolder(holder, position); + if (libraryItemPage.getListItems().get(position).getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) { + holder.itemView.setOnClickListener(v -> { + ListItem listItem = libraryItemPage.getListItems().get(position); + listener.onDocumentSelected(listItem.getItemId()); + }); + } + } +}