feat: refs#6413 refactorUbicador
This commit is contained in:
parent
18ebdfc92a
commit
611e6d2993
|
@ -26,9 +26,6 @@ class AutomaticAdapter(
|
|||
|
||||
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
holder.binding.root.setOnClickListener {
|
||||
onAutomaticItemClickListener.onAutomaticItemClickListener(position)
|
||||
}
|
||||
}
|
||||
|
||||
inner class ItemHolder(
|
||||
|
@ -37,10 +34,12 @@ class AutomaticAdapter(
|
|||
private val res = binding.root.context.resources
|
||||
fun bind(item: Long) {
|
||||
binding.itemfkText.text = item.toString()
|
||||
binding.deleteItem.setOnClickListener {
|
||||
onAutomaticItemClickListener.onAutomaticItemClickListener(
|
||||
layoutPosition
|
||||
)
|
||||
}
|
||||
|
||||
/* binding.apply {
|
||||
this.item = item
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,10 +24,8 @@ class AutomaticAddItemFragment(
|
|||
) : BaseFragment<FragmentAutomaticAddItemBinding, UbicadorViewModel>(
|
||||
UbicadorViewModel::class
|
||||
) {
|
||||
|
||||
private var adapter: AutomaticAdapter? = null
|
||||
private var listItems: ArrayList<Long> = ArrayList()
|
||||
private var contador = 0
|
||||
private lateinit var customDialogList: CustomDialogList
|
||||
private var listShelvings: ArrayList<BarcodeVO> = ArrayList()
|
||||
private var listShelvingsAdapter: BarcodeAdapter? = null
|
||||
|
@ -54,19 +52,22 @@ class AutomaticAddItemFragment(
|
|||
|
||||
private fun setSubtitle() {
|
||||
binding.mainToolbar.toolbarSubtitle.text =
|
||||
getString(R.string.doubleText, getString(R.string.labels), contador.toString())
|
||||
getString(
|
||||
R.string.doubleText,
|
||||
getString(R.string.labels),
|
||||
(listItems.size).toString()
|
||||
)
|
||||
}
|
||||
|
||||
private fun setViews() {
|
||||
adapter = AutomaticAdapter(listItems, object : OnAutomaticItemClickListener {
|
||||
override fun onAutomaticItemClickListener(position: Int) {
|
||||
contador -= 1
|
||||
setSubtitle()
|
||||
|
||||
if (listItems.size > position) {
|
||||
listItems.removeAt(position)
|
||||
adapter!!.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
setSubtitle()
|
||||
}
|
||||
})
|
||||
binding.itemsRecyclerview.adapter = adapter
|
||||
|
@ -80,8 +81,6 @@ class AutomaticAddItemFragment(
|
|||
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.editMatricula.text.toString().isNotEmpty()) {
|
||||
contador += 1
|
||||
setSubtitle()
|
||||
try {
|
||||
listItems.add(
|
||||
0,
|
||||
|
@ -92,6 +91,7 @@ class AutomaticAddItemFragment(
|
|||
).toString().toLong()
|
||||
|
||||
)
|
||||
setSubtitle()
|
||||
adapter!!.notifyItemInserted(0)
|
||||
binding.itemsRecyclerview.scrollToPosition(0)
|
||||
} catch (ex: Exception) {
|
||||
|
|
Loading…
Reference in New Issue