Shelving Parking

This commit is contained in:
Enrique Blasco 2020-05-12 13:30:57 +02:00
parent f29c4262c2
commit c0fae9e219
14 changed files with 497 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
@ -40,6 +41,11 @@ val viewModelModule = module{
FaltasViewModel()
}
// ShelvingParking
viewModel {
ShelvingParkingViewModel()
}
// Ajustes
viewModel {
AjustesViewModel()

View File

@ -0,0 +1,16 @@
package es.verdnatura.domain
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
import retrofit2.Call
class GetShelvingParkingUserCase : RestClient() {
fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String) : Call<List<ItemShelvingParkingVO>> {
val params:ArrayList<String> = ArrayList();
params.add(vShelvingFk)
params.add(vWarehouseFk)
params.add(vDayRange)
return restClient!!.shelvingParking_get("json","1",usuario,password,"application/json",params)!!
}
}

View File

@ -6,6 +6,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Header
@ -148,5 +149,15 @@ interface VerdnaturaService {
@Body params: List<String>):
Call<String>
//SHELVING PARKING ========================================================================>
@POST("almacenv2/shelvingParking_get")
fun shelvingParking_get(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>):
Call<List<ItemShelvingParkingVO>>
}

View File

@ -10,8 +10,6 @@ import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

View File

@ -3,7 +3,6 @@ package es.verdnatura.presentation.view.feature.inventario.fragment
import android.content.Context
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer

View File

@ -22,6 +22,7 @@ import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryFrag
import es.verdnatura.presentation.view.feature.main.model.ItemMenuVO
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@ -151,6 +152,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
"Faltas" -> {
addFragmentOnTop(FaltasFragment.newInstance())
}
"Shelving Parking"-> {
addFragmentOnTop(ShelvingParkingFragment.newInstance())
}
}
Log.i("Item: ",item.title)
}

View File

@ -30,6 +30,7 @@ class PasilleroViewModel : BaseViewModel() {
"Buscar item")
)
_pasillerositem.add(
PasillerosItemVO(3,
R.drawable.ic_spa_black_24dp,
@ -42,6 +43,12 @@ class PasilleroViewModel : BaseViewModel() {
"Faltas")
)
_pasillerositem.add(
PasillerosItemVO(5,
R.drawable.ic_send_black_24dp,
"Shelving Parking")
)
}
}

View File

@ -0,0 +1,37 @@
package es.verdnatura.presentation.view.feature.shelvingparking.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemShelvingparkingRowBinding
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
class ShelvingParkingAdapter (
private val items: List<ItemShelvingParkingVO>
): RecyclerView.Adapter<ShelvingParkingAdapter.ItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemShelvingparkingRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
}
inner class ItemHolder(
val binding: ItemShelvingparkingRowBinding
) : RecyclerView.ViewHolder(binding.root){
private val res = binding.root.context.resources
fun bind(item: ItemShelvingParkingVO) {
binding.apply {
this.item = item
}
}
}
}

View File

@ -0,0 +1,113 @@
package es.verdnatura.presentation.view.feature.shelvingparking.fragment
import android.content.SharedPreferences
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentShelvingParkingBinding
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.shelvingparking.adapter.ShelvingParkingAdapter
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_shelving_parking.*
import kotlinx.android.synthetic.main.toolbar.*
class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, ShelvingParkingViewModel>(
ShelvingParkingViewModel::class) {
private var user = ""
private var password = ""
private var sectorFk = ""
private var warehouseFk = ""
private var adapter : ShelvingParkingAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private var listInvetory:ArrayList<ItemInventaryVO> = ArrayList()
private var listInvetoryAux:ArrayList<ItemInventaryVO> = ArrayList()
private lateinit var customDialog: CustomDialog
companion object {
fun newInstance() = ShelvingParkingFragment()
}
override fun getLayoutId(): Int = R.layout.fragment_shelving_parking
override fun init() {
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
user = prefs.getString(USER,"").toString()
password = prefs.getString(PASSWORD,"").toString()
sectorFk = prefs.getInt(SECTORFK,1).toString()
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
toolbar_title.text = "shelvingParking_get"
setEvents()
super.init()
}
private fun setEvents(){
backButton.setOnClickListener {
activity!!.onBackPressed()
}
shelvingText.requestFocus()
shelvingText.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!shelvingText.text.toString().isNullOrEmpty()){
toolbar_title.text = shelvingText.text.toString()
splash_progress.visibility = View.VISIBLE
viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString())
}
shelvingText.setText("")
(activity as MainActivity).hideKeyboard(shelvingText)
return@setOnEditorActionListener true
}
return@setOnEditorActionListener false
}
dayrange.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!shelvingText.text.toString().isNullOrEmpty())
splash_progress.visibility = View.VISIBLE
else
shelvingText.requestFocus()
toolbar_title.text = shelvingText.text.toString()
viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString())
shelvingText.setText("")
(activity as MainActivity).hideKeyboard(dayrange)
return@setOnEditorActionListener true
}
return@setOnEditorActionListener false
}
}
override fun observeViewModel() {
with(viewModel){
loadShelvingList.observe(viewLifecycleOwner, Observer { event ->
event.getContentIfNotHandled().notNull {
splash_progress.visibility = View.GONE
adapter = ShelvingParkingAdapter(it.list)
location_recyclerview.adapter = adapter
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
})
}
}
}

View File

@ -0,0 +1,58 @@
package es.verdnatura.presentation.view.feature.shelvingparking.fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetShelvingParkingUserCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingListVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class ShelvingParkingViewModel : BaseViewModel() {
private val getShelvingParkingUserCase: GetShelvingParkingUserCase = GetShelvingParkingUserCase()
private val _shelvingList by lazy { MutableLiveData<ItemShelvingParkingListVO>() }
val shelvingList: LiveData<ItemShelvingParkingListVO>
get() = _shelvingList
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String){
getShelvingParkingUserCase.shelvingParking_get(usuario,password,vShelvingFk.toUpperCase(),vWarehouseFk,vDayRange).enqueue(object :
Callback<List<ItemShelvingParkingVO>> {
override fun onFailure(call: Call<List<ItemShelvingParkingVO>>, t: Throwable) {
val listError:ArrayList<ItemShelvingParkingVO> = ArrayList()
listError.add(ItemShelvingParkingVO(isError = true,errorMessage = t.message!!))
_shelvingList.value = ItemShelvingParkingListVO(listError)
}
override fun onResponse(
call: Call<List<ItemShelvingParkingVO>>,
response: Response<List<ItemShelvingParkingVO>>
) {
if (response.body() != null){
_shelvingList.value = response.body()?.let { ItemShelvingParkingListVO(it) }
}else{
val listError:ArrayList<ItemShelvingParkingVO> = ArrayList()
listError.add(ItemShelvingParkingVO(isError = true,errorMessage = "Error en la llamada de shelvingParking_get"))
_shelvingList.value = ItemShelvingParkingListVO(listError)
}
}
})
}
}

View File

@ -0,0 +1,14 @@
package es.verdnatura.presentation.view.feature.shelvingparking.model
class ItemShelvingParkingVO (
var itemFk:String = "0",
var concept:String = "",
var sinServir:String = "0",
var aparcado:String = "0",
var isError:Boolean = false,
var errorMessage:String = ""
)
class ItemShelvingParkingListVO(
var list:List<ItemShelvingParkingVO> = listOf()
)

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#F7931E"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#F7931E" android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:paddingTop="@dimen/toolbar_height">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/shelvingText"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Escanea shelving"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_dayrange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/dayrange"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Day Range"
android:inputType="number"
android:text="1"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/layout_margin_min"
android:layout_marginBottom="@dimen/layout_margin_1"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ItemFk"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Concept"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SinServir"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aoarcado"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/location_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
tools:listitem="@layout/item_shelvingparking_row"/>
</LinearLayout>
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/splash_progress"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/verdnatura_black_8_alpha_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_content"
android:layout_height="@dimen/verdnatura_logo_large_height"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/orange_loading"
app:lottie_speed="2" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools">
<data>
<variable
name="item"
type="es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/item_row_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min"
android:paddingTop="@dimen/pasilleros_margin_main_menu"
android:paddingBottom="@dimen/pasilleros_margin_main_menu">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.itemFk}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.concept}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.sinServir}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.aparcado}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/verdnatura_black_9"/>
</LinearLayout>
</layout>