feat embalajes #refs 4021

This commit is contained in:
Sergio De la torre 2024-06-18 12:31:05 +02:00
parent ed88d17566
commit 2695a96f39
2 changed files with 22 additions and 31 deletions

View File

@ -3,21 +3,23 @@ package es.verdnatura.presentation.view.feature.packaging.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemItemsupplierRowBinding
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.common.OnEditSubQuantityListener
import es.verdnatura.presentation.common.OnImageTrashClickListener
import es.verdnatura.presentation.common.OnImageUpdateClickListener
import es.verdnatura.presentation.common.OnItemClickListener
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
class ItemSupplierAdapter(
private val items: List<ItemSupplier>,
private val onImageUpdateClickListener: OnImageUpdateClickListener? ,
private val onImageUpdateClickListener: OnImageUpdateClickListener?,
private val onImageTrashClickListener: OnImageTrashClickListener?,
private val onEditSubQuantityListener: OnEditSubQuantityListener?,
private val onItemClickListener: OnItemClickListener? = null,
private var showItems: Boolean = true
) : RecyclerView.Adapter<ItemSupplierAdapter.ItemHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemItemsupplierRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
@ -34,7 +36,6 @@ class ItemSupplierAdapter(
}
inner class ItemHolder(
val binding: ItemItemsupplierRowBinding
) : RecyclerView.ViewHolder(binding.root) {
@ -42,9 +43,9 @@ class ItemSupplierAdapter(
binding.apply {
this.item = item
if (!showItems){
itemAdd.visibility= View.GONE
itemRemove.visibility=View.GONE
if (!showItems) {
itemAdd.visibility = View.GONE
itemRemove.visibility = View.GONE
}
itemAdd.setOnClickListener {
onImageUpdateClickListener!!.OnImageUpdateClickListener(
@ -52,23 +53,15 @@ class ItemSupplierAdapter(
)
}
itemRemove.setOnClickListener {
onImageTrashClickListener!!.OnImageTrashClickListener(item)
onImageTrashClickListener!!.onImageTrashClickListener(item)
}
itemTitle.setOnClickListener {
onItemClickListener?.onItemClickListener(item)
}
/* itemSubquantity.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
onEditSubQuantityListener.OnEditSubQuantityListener(
item,
binding.itemSubquantity.text.toString()
)
v.clearFocus()
}
return@setOnEditorActionListener false
}*/
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package es.verdnatura.presentation.view.feature.packaging.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.esafirm.imagepicker.model.Image
@ -8,8 +9,6 @@ import es.verdnatura.databinding.ItemImageRowBinding
import es.verdnatura.presentation.common.OnImageTrashClickListener
import es.verdnatura.presentation.common.OnImageUpdateClickListener
class ListImageAdapter(
private val items: List<Image>,
private val onImageUpdateClickListener: OnImageUpdateClickListener,
@ -17,7 +16,6 @@ class ListImageAdapter(
) : RecyclerView.Adapter<ListImageAdapter.ItemHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemImageRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
@ -26,8 +24,6 @@ class ListImageAdapter(
override fun getItemCount() = items.size
inner class ItemHolder(
val binding: ItemImageRowBinding
) : RecyclerView.ViewHolder(binding.root) {
@ -37,13 +33,15 @@ class ListImageAdapter(
itemImage.setImageURI(item.uri)
itemName.text = item.name
itemImageUpdate.setOnClickListener {
itemImageUpdate.setOnClickListener {
onImageUpdateClickListener.OnImageUpdateClickListener(
item
)
itemImageTrash.setOnClickListener {
onImageTrashClickListener.OnImageTrashClickListener(item)
}
}
binding.itemImageTrash.visibility = View.GONE
itemImageTrash.setOnClickListener {
onImageTrashClickListener.onImageTrashClickListener(item)
}
}