diff --git a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt index 5c2b79c8..c2b8d89f 100644 --- a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt +++ b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt @@ -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" } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/adapter/ItemShelvingLogAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/adapter/ItemShelvingLogAdapter.kt index 10fd2685..0a11ea1d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/adapter/ItemShelvingLogAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/adapter/ItemShelvingLogAdapter.kt @@ -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, + private var items: List, private val onPasillerosItemClickListener: OnPasillerosItemClickListener ) : RecyclerView.Adapter() { @@ -39,7 +39,11 @@ class ItemShelvingLogAdapter( } } + fun addList(list:List){ + items = list + notifyDataSetChanged() + } inner class ItemHolder( val binding: ItemShelvinglogRowBinding ) : RecyclerView.ViewHolder(binding.root) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogFragment.kt index 88e230ec..48a1e8b8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogFragment.kt @@ -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) + + } } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt index ba9aa8d2..34690514 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt @@ -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(context) { override fun onSuccess(response: Response) { - itemShelvingLogGet(response.body()!!.toString()) + itemShelvingLogGet(response.body()!!.toString(), records) } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt index 47466c38..6c43d1c7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt @@ -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,