navigate beetwen views

This commit is contained in:
Enrique Blasco 2020-05-12 12:21:11 +02:00
parent 780c6d01e1
commit f29c4262c2
10 changed files with 81 additions and 23 deletions

View File

@ -14,7 +14,7 @@ interface OnOptionsSelectedListener {
} }
interface OnPasillerosItemClickListener { interface OnPasillerosItemClickListener {
fun onPasillerosItemClickListener(item: PasillerosItemVO) fun onPasillerosItemClickListener(item: PasillerosItemVO,entryPoint:String)
} }
interface OnAjustesItemClickListener { interface OnAjustesItemClickListener {

View File

@ -29,21 +29,22 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_item_card.* import kotlinx.android.synthetic.main.fragment_item_card.*
import kotlinx.android.synthetic.main.toolbar.* import kotlinx.android.synthetic.main.toolbar.*
class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>(ItemCardViewModel::class) { class ItemCardFragment(
var itemFk:String = ""
) : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>(ItemCardViewModel::class) {
private var urlLarge:String = "" private var urlLarge:String = ""
private var titleImage:String = "" private var titleImage:String = ""
private var user = "" private var user = ""
private var password = "" private var password = ""
private var warehouseFk = "" private var warehouseFk = ""
private var itemFk = ""
private var adapter : ItemCardAdapter? = null private var adapter : ItemCardAdapter? = null
private var barcodeAdapter : BarcodeAdapter? = null private var barcodeAdapter : BarcodeAdapter? = null
private var listItemsRow:ArrayList<ItemCardRowVO> = ArrayList() private var listItemsRow:ArrayList<ItemCardRowVO> = ArrayList()
private var listBarcodes:ArrayList<BarcodeVO> = ArrayList() private var listBarcodes:ArrayList<BarcodeVO> = ArrayList()
companion object { companion object {
fun newInstance() = ItemCardFragment() fun newInstance(entryPoint:String) = ItemCardFragment(entryPoint)
} }
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
private lateinit var customDialogInput: CustomDialogInput private lateinit var customDialogInput: CustomDialogInput
@ -61,6 +62,9 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
customDialogInput = CustomDialogInput(requireContext()) customDialogInput = CustomDialogInput(requireContext())
customDialogList = CustomDialogList(requireContext()) customDialogList = CustomDialogList(requireContext())
customDialogTwo = CustomDialogTwoButtons(requireContext()) customDialogTwo = CustomDialogTwoButtons(requireContext())
if (!itemFk.isNullOrEmpty()){
getItemCard(itemFk)
}
super.init() super.init()
} }

View File

@ -18,17 +18,18 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_buscar_item.* import kotlinx.android.synthetic.main.fragment_buscar_item.*
import kotlinx.android.synthetic.main.toolbar.* import kotlinx.android.synthetic.main.toolbar.*
class BuscarItemFragment : BaseFragment<FragmentBuscarItemBinding,BuscarItemViewModel>(BuscarItemViewModel::class) { class BuscarItemFragment(
var itemFk:String = ""
) : BaseFragment<FragmentBuscarItemBinding,BuscarItemViewModel>(BuscarItemViewModel::class) {
private var user = "" private var user = ""
private var password = "" private var password = ""
private var warehouseFk = "" private var warehouseFk = ""
private var itemFk = ""
private var adapter : LocationAdapter? = null private var adapter : LocationAdapter? = null
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
companion object { companion object {
fun newInstance() = BuscarItemFragment() fun newInstance(entryPoint:String) = BuscarItemFragment(entryPoint)
} }
override fun getLayoutId(): Int = R.layout.fragment_buscar_item override fun getLayoutId(): Int = R.layout.fragment_buscar_item
@ -38,6 +39,9 @@ class BuscarItemFragment : BaseFragment<FragmentBuscarItemBinding,BuscarItemView
toolbar_title.text = "getItemUbication" toolbar_title.text = "getItemUbication"
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
setEvents() setEvents()
if (!itemFk.isNullOrEmpty()){
getLocations(itemFk)
}
super.init() super.init()
} }

View File

@ -7,12 +7,15 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemFaltasRowBinding import es.verdnatura.databinding.ItemFaltasRowBinding
import es.verdnatura.presentation.common.OnFaltasNichoClickListener import es.verdnatura.presentation.common.OnFaltasNichoClickListener
import es.verdnatura.presentation.common.OnFaltasReviewClickListener import es.verdnatura.presentation.common.OnFaltasReviewClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
class FaltasAdapter ( class FaltasAdapter (
private val items: List<ItemFaltasVO>, private val items: List<ItemFaltasVO>,
private val onFaltasNichoClickListener: OnFaltasNichoClickListener, private val onFaltasNichoClickListener: OnFaltasNichoClickListener,
private val onFaltasReviewClickListener:OnFaltasReviewClickListener private val onFaltasReviewClickListener:OnFaltasReviewClickListener,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
): RecyclerView.Adapter<FaltasAdapter.ItemHolder> () { ): RecyclerView.Adapter<FaltasAdapter.ItemHolder> () {
@ -46,6 +49,15 @@ class FaltasAdapter (
itemFaltas.setOnClickListener { itemFaltas.setOnClickListener {
onFaltasReviewClickListener.onFaltasReviewClickListener(item) onFaltasReviewClickListener.onFaltasReviewClickListener(item)
} }
itemFk.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk)
}
itemUp.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}
itemDown.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
package es.verdnatura.presentation.view.feature.faltas.fragment package es.verdnatura.presentation.view.feature.faltas.fragment
import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.View import android.view.View
@ -14,6 +15,7 @@ import es.verdnatura.presentation.common.OnFaltasNichoClickListener
import es.verdnatura.presentation.common.OnFaltasReviewClickListener import es.verdnatura.presentation.common.OnFaltasReviewClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.faltas.adapter.FaltasAdapter import es.verdnatura.presentation.view.feature.faltas.adapter.FaltasAdapter
@ -36,16 +38,23 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
private var listInvetory:ArrayList<ItemFaltasVO> = ArrayList() private var listInvetory:ArrayList<ItemFaltasVO> = ArrayList()
private var listInvetoryAux:ArrayList<ItemFaltasVO> = ArrayList() private var listInvetoryAux:ArrayList<ItemFaltasVO> = ArrayList()
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
companion object { companion object {
fun newInstance() = FaltasFragment() fun newInstance() = FaltasFragment()
} }
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun getLayoutId(): Int = R.layout.fragment_faltas override fun getLayoutId(): Int = R.layout.fragment_faltas
override fun init() { override fun init() {
splash_progress.visibility = View.VISIBLE
activity!!.main_bottom_navigation.visibility = View.GONE activity!!.main_bottom_navigation.visibility = View.GONE
toolbar_title.text = "itemShelvingRadar" toolbar_title.text = "faultsReview"
setToolBar() setToolBar()
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
user = prefs.getString(USER,"").toString() user = prefs.getString(USER,"").toString()
@ -109,8 +118,9 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel){ with(viewModel){
loadFaltasList.observe(viewLifecycleOwner, Observer { event -> loadFaltasList.observe(viewLifecycleOwner, Observer { event ->
splash_progress.visibility = View.GONE
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
splash_progress.visibility = View.GONE
listInvetory = ArrayList() listInvetory = ArrayList()
listInvetoryAux = ArrayList() listInvetoryAux = ArrayList()
it.list.forEach { it.list.forEach {
@ -150,7 +160,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
changeOfflineValue(item) changeOfflineValue(item)
} }
}) },pasillerosItemClickListener!!)
location_recyclerview.adapter = adapter location_recyclerview.adapter = adapter
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
} }

View File

@ -6,11 +6,14 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemInventaryRowBinding import es.verdnatura.databinding.ItemInventaryRowBinding
import es.verdnatura.presentation.common.OnInvetoryNichoClickListener import es.verdnatura.presentation.common.OnInvetoryNichoClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
class InventoryAdapter ( class InventoryAdapter (
private val items: List<ItemInventaryVO>, private val items: List<ItemInventaryVO>,
private val onInvetoryNichoClickListener: OnInvetoryNichoClickListener private val onInvetoryNichoClickListener: OnInvetoryNichoClickListener,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
): RecyclerView.Adapter<InventoryAdapter.ItemHolder> () { ): RecyclerView.Adapter<InventoryAdapter.ItemHolder> () {
@ -41,6 +44,15 @@ class InventoryAdapter (
itemNicho.setOnClickListener { itemNicho.setOnClickListener {
onInvetoryNichoClickListener.onInvetoryNichoClickListener(item) onInvetoryNichoClickListener.onInvetoryNichoClickListener(item)
} }
itemFk.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk)
}
itemUp.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}
itemDown.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}
} }
} }
} }

View File

@ -1,7 +1,9 @@
package es.verdnatura.presentation.view.feature.inventario.fragment package es.verdnatura.presentation.view.feature.inventario.fragment
import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@ -12,6 +14,7 @@ import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnInvetoryNichoClickListener import es.verdnatura.presentation.common.OnInvetoryNichoClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.inventario.adapter.InventoryAdapter import es.verdnatura.presentation.view.feature.inventario.adapter.InventoryAdapter
@ -35,6 +38,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
private var listInvetory:ArrayList<ItemInventaryVO> = ArrayList() private var listInvetory:ArrayList<ItemInventaryVO> = ArrayList()
private var listInvetoryAux:ArrayList<ItemInventaryVO> = ArrayList() private var listInvetoryAux:ArrayList<ItemInventaryVO> = ArrayList()
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
companion object { companion object {
fun newInstance() = InventaryFragment() fun newInstance() = InventaryFragment()
@ -42,10 +46,13 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
override fun getLayoutId(): Int = R.layout.fragment_inventary override fun getLayoutId(): Int = R.layout.fragment_inventary
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun init() { override fun init() {
activity!!.main_bottom_navigation.visibility = View.GONE
toolbar_title.text = "itemShelvingRadar"
setToolBar()
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
user = prefs.getString(USER,"").toString() user = prefs.getString(USER,"").toString()
password = prefs.getString(PASSWORD,"").toString() password = prefs.getString(PASSWORD,"").toString()
@ -54,11 +61,19 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
viewModel.getInventory(user,password,sectorFk) viewModel.getInventory(user,password,sectorFk)
customDialogInput = CustomDialogInput(requireContext()) customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.VISIBLE
toolbar_title.text = "itemShelvingRadar"
setToolBar()
setEvents() setEvents()
super.init() super.init()
} }
private fun setToolBar(){ private fun setToolBar(){
val listIcons:ArrayList<Drawable> = ArrayList() val listIcons:ArrayList<Drawable> = ArrayList()
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
@ -108,8 +123,9 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel){ with(viewModel){
loadInventaryList.observe(viewLifecycleOwner, Observer { event -> loadInventaryList.observe(viewLifecycleOwner, Observer { event ->
splash_progress.visibility = View.GONE
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
splash_progress.visibility = View.GONE
listInvetory = ArrayList() listInvetory = ArrayList()
listInvetoryAux = ArrayList() listInvetoryAux = ArrayList()
it.list.forEach { it.list.forEach {
@ -145,7 +161,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
} }
} }
}) },onPasillerosItemClickListener = pasillerosItemClickListener!!)
location_recyclerview.adapter = adapter location_recyclerview.adapter = adapter
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
} }

View File

@ -137,13 +137,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
} }
} }
override fun onPasillerosItemClickListener(item: PasillerosItemVO) { override fun onPasillerosItemClickListener(item: PasillerosItemVO, entryPoint: String) {
when (item.title){ when (item.title){
"Consultar artículo" -> { "Consultar artículo" -> {
addFragmentOnTop(ItemCardFragment.newInstance()) addFragmentOnTop(ItemCardFragment.newInstance(entryPoint))
} }
"Buscar item" -> { "Buscar item" -> {
addFragmentOnTop(BuscarItemFragment.newInstance()) addFragmentOnTop(BuscarItemFragment.newInstance(entryPoint))
} }
"Inventario" -> { "Inventario" -> {
addFragmentOnTop(InventaryFragment.newInstance()) addFragmentOnTop(InventaryFragment.newInstance())

View File

@ -24,7 +24,7 @@ class PasillerosAdapter (
override fun onBindViewHolder(holder: PasillerosItemHolder, position: Int) { override fun onBindViewHolder(holder: PasillerosItemHolder, position: Int) {
holder.bind(items[position]) holder.bind(items[position])
holder.binding.root.setOnClickListener { holder.binding.root.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(items[position]) onPasillerosItemClickListener.onPasillerosItemClickListener(items[position],"")
} }
} }

View File

@ -1,7 +1,7 @@
package es.verdnatura.presentation.view.feature.pasillero.model package es.verdnatura.presentation.view.feature.pasillero.model
class PasillerosItemVO ( class PasillerosItemVO (
var id: Int, var id: Int = 0,
var iconResource: Int, var iconResource: Int = 0,
val title: String = "" val title: String = ""
) )