feat itemShelvingLog refs #7168
This commit is contained in:
parent
c87707a0ca
commit
ec6b61b414
|
@ -64,7 +64,7 @@ object ConstAndValues {
|
|||
const val MENUBYDEFAULTSELECTED = "MENUBYDEFAULTSELECTED"
|
||||
const val INVENTORYPARKINGTO = "INVENTORYPARKINGTO"
|
||||
const val INVENTORYPARKINGFROM = "INVENTORYPARKINGFROM"
|
||||
const val LIMITRECORDSSHELVINGLOG = 25
|
||||
const val LIMITRECORDSSHELVINGLOG = 50
|
||||
const val RESERVATIONMODE = "operatorReservationMode"
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelv
|
|||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
class ItemShelvingLogAdapter(
|
||||
private val items: List<ItemShelvingLog>,
|
||||
private var items: List<ItemShelvingLog>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||
) : RecyclerView.Adapter<ItemShelvingLogAdapter.ItemHolder>() {
|
||||
|
||||
|
@ -39,7 +39,11 @@ class ItemShelvingLogAdapter(
|
|||
|
||||
}
|
||||
}
|
||||
fun addList(list:List<ItemShelvingLog>){
|
||||
items = list
|
||||
notifyDataSetChanged()
|
||||
|
||||
}
|
||||
inner class ItemHolder(
|
||||
val binding: ItemShelvinglogRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelving.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -23,6 +25,8 @@ class ItemShelvingLogFragment(
|
|||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var records: Int = LIMITRECORDSSHELVINGLOG
|
||||
private var shelving: String = ""
|
||||
private var positionScroll = 0
|
||||
private var positionToReturn = 0
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint)
|
||||
|
@ -37,10 +41,25 @@ class ItemShelvingLogFragment(
|
|||
customDialog = CustomDialog(requireContext())
|
||||
setEvents()
|
||||
setToolBar(getString(R.string.itemShelvingLog))
|
||||
setAdapter()
|
||||
super.init()
|
||||
|
||||
}
|
||||
|
||||
private fun setAdapter() {
|
||||
binding.itemshelvinglogRecyclerview.layoutManager =
|
||||
LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
adapter = ItemShelvingLogAdapter(
|
||||
listOf(),
|
||||
onPasillerosItemClickListener = pasillerosItemClickListener!!
|
||||
)
|
||||
binding.itemshelvinglogRecyclerview.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||
super.onAttach(context)
|
||||
|
@ -51,11 +70,18 @@ class ItemShelvingLogFragment(
|
|||
}
|
||||
|
||||
private fun setEvents() {
|
||||
val scrollView = binding.scrollView
|
||||
scrollView.setOnScrollChangeListener { _, _, scrollY, _, _->
|
||||
positionScroll = scrollY
|
||||
}
|
||||
|
||||
|
||||
binding.scanInput.requestFocus()
|
||||
binding.loadMoreButton.setOnClickListener {
|
||||
positionToReturn = positionScroll
|
||||
records += LIMITRECORDSSHELVINGLOG
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(shelving.toLong().toString())
|
||||
viewModel.getIdFromCodeSalix(shelving.toLong().toString(), records)
|
||||
} catch (ex: Exception) {
|
||||
|
||||
viewModel.itemShelvingLogGet(
|
||||
|
@ -71,7 +97,7 @@ class ItemShelvingLogFragment(
|
|||
shelving = binding.scanInput.text.toString()
|
||||
records = LIMITRECORDSSHELVINGLOG
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString())
|
||||
viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString(), records)
|
||||
} catch (ex: Exception) {
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
|
@ -103,24 +129,22 @@ class ItemShelvingLogFragment(
|
|||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
adapter = ItemShelvingLogAdapter(
|
||||
it.list,
|
||||
onPasillerosItemClickListener = pasillerosItemClickListener!!
|
||||
)
|
||||
|
||||
//TAREA 7168
|
||||
if (it.list.size == records) {
|
||||
binding.loadMoreButton.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.loadMoreButton.visibility = View.GONE
|
||||
}
|
||||
binding.itemshelvinglogRecyclerview.adapter = adapter
|
||||
binding.itemshelvinglogRecyclerview.layoutManager =
|
||||
LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
adapter!!.addList(it.list)
|
||||
setToolBar(getString(R.string.itemShelvingLog) + ":" + itemScan)
|
||||
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
binding.scrollView.smoothScrollTo(0, positionToReturn)
|
||||
}, 1000)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
fun getIdFromCodeSalix(code: String, records: Int) {
|
||||
getItemFromBarcodeUseCase.execute (code)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
itemShelvingLogGet(response.body()!!.toString())
|
||||
itemShelvingLogGet(response.body()!!.toString(), records)
|
||||
|
||||
}
|
||||
})
|
||||
|
|
|
@ -28,6 +28,8 @@ class ItemUbicador(
|
|||
var packing: Int? = null,
|
||||
var grouping: Int? = null,
|
||||
var code: String? = "",
|
||||
var created:String? = null,
|
||||
var shelvingFk: String? = null,
|
||||
var id: Int = 0,
|
||||
var priority: Int = 0,
|
||||
var isError: Boolean = false,
|
||||
|
|
Loading…
Reference in New Issue