This commit is contained in:
Enrique Blasco 2020-06-11 13:34:00 +02:00
parent ddf18a59ce
commit fdf4e54e22
25 changed files with 841 additions and 22 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 5
versionName "5.0.5"
versionCode 7
versionName "5.0.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -3,6 +3,7 @@ package es.verdnatura.di
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel
import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoViewModel
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
@ -12,6 +13,7 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPa
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanViewModel
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListViewModel
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
@ -89,4 +91,13 @@ val viewModelModule = module{
viewModel {
ExpeditionScanViewModel()
}
// SACADOR
viewModel {
SacadorViewModel()
}
viewModel {
CollectionViewModel()
}
}

View File

@ -8,8 +8,8 @@ import java.util.concurrent.TimeUnit
class ApiUtils {
companion object {
//const val BASE_URL:String = "http://192.168.1.108:8008/"
const val BASE_URL:String = "https://app.verdnatura.es/"
const val BASE_URL:String = "http://192.168.1.108:8008/"
//const val BASE_URL:String = "https://app.verdnatura.es/"
fun getApiService():VerdnaturaService{
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)

View File

@ -0,0 +1,20 @@
package es.verdnatura.domain
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call
class GetSacadorControladorUserCase : RestClient() {
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String) : Call<CollectionVO> {
val params:ArrayList<String> = ArrayList();
params.add(collectionFk)
params.add(sectorFk)
return restClient!!.collectionTicketGet("json","1",usuario,password,"application/json",params)
}
fun collectionGet(usuario:String,password:String) : Call<List<CollectionVO>> {
val params:ArrayList<String> = ArrayList();
return restClient!!.collectionGet("json","1",usuario,password,"application/json")
}
}

View File

@ -9,6 +9,7 @@ import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.paletizador.model.*
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import retrofit2.Call
@ -50,6 +51,24 @@ interface VerdnaturaService {
Call<List<SectorItemVO>>
//SACADORES / CONTROLADORES ========================================================================>
@POST("almacennew/collectionGet")
fun collectionGet(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String):
Call<List<CollectionVO>>
@POST("almacennew/collectionTicketGet")
fun collectionTicketGet(@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<CollectionVO>
//PASILLEROS ========================================================================>
//CONSULTAR ARTICULO ========================================================================>

View File

@ -12,6 +12,7 @@ import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionT
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemScanVO
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
interface OnOptionsSelectedListener {
@ -77,4 +78,8 @@ interface OnComprobarPalletViewClickListener {
interface OnScanLongClickListener {
fun onScanLongClickListener(ItemExpeditionScanVO: ItemExpeditionScanVO)
}
interface OnCollectionSelectedListener {
fun onCollectionSelected(collection: CollectionVO)
}

View File

@ -15,6 +15,7 @@ import androidx.fragment.app.FragmentTransaction
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import java.util.*
inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) =
@ -65,8 +66,6 @@ fun View.setMargins(left: Int, top: Int, right: Int, bottom: Int) {
}
fun ImageView.loadUrl(url: String) {
// load(url)
// Glide.with(context).load(url).into(this)
Glide.with(context)
.asBitmap()
.load(url)
@ -81,4 +80,37 @@ fun ImageView.loadUrl(url: String) {
}
inline val <reified T> T.TAG: String
get() = T::class.java.canonicalName ?: T::class.simpleName ?: T::class.java.simpleName
get() = T::class.java.canonicalName ?: T::class.simpleName ?: T::class.java.simpleName
fun Calendar.convertToDateString(): String {
var dayOfWeek = ""
var dayOfMonth = ""
val day = this[Calendar.DATE]
when (this[Calendar.DAY_OF_WEEK]) {
1 -> dayOfWeek = "Dom"
2 -> dayOfWeek = "Lun"
3 -> dayOfWeek = "Mar"
4 -> dayOfWeek = "Mie"
5 -> dayOfWeek = "Jue"
6 -> dayOfWeek = "Vie"
7 -> dayOfWeek = "Sab"
}
when (this[Calendar.MONTH]) {
0 -> dayOfMonth = "Ene"
1 -> dayOfMonth = "Feb"
2 -> dayOfMonth = "Mar"
3 -> dayOfMonth = "Abr"
4 -> dayOfMonth = "May"
5 -> dayOfMonth = "Jun"
6 -> dayOfMonth = "Jul"
7 -> dayOfMonth = "Ago"
8 -> dayOfMonth = "Sep"
9 -> dayOfMonth = "Oct"
10 -> dayOfMonth = "Nov"
11 -> dayOfMonth = "Dic"
}
return dayOfWeek + " " + day + " " + dayOfMonth
}

View File

@ -0,0 +1,112 @@
package es.verdnatura.presentation.view.feature.collection.fragment
import android.content.Context
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import androidx.lifecycle.ViewModelProviders
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentCollectionBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.toolbar.*
class CollectionFragment(
var collection : CollectionVO = CollectionVO()
) : BaseFragment<FragmentCollectionBinding,CollectionViewModel>(CollectionViewModel::class){
private var user = ""
private var password = ""
private var sectorFk = ""
private var warehouseFk = ""
companion object {
fun newInstance(collection:CollectionVO) = CollectionFragment(collection)
}
override fun onAttach(context: Context) {
super.onAttach(context)
}
override fun getLayoutId(): Int = R.layout.fragment_collection
override fun onCreate(savedInstanceState: Bundle?) {
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()
if (collection.tickets.isEmpty()){
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
}else{
createCollectionList()
}
super.onCreate(savedInstanceState)
}
override fun init() {
activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.VISIBLE
toolbar_title.text = "collectionTicket_get"
setToolBar()
setEvents()
super.init()
}
private fun setToolBar(){
val listIcons:ArrayList<Drawable> = ArrayList()
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
listIcons.add(iconReload)
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){
splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
}
}
})
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun setEvents(){
backButton.setOnClickListener {
activity!!.onBackPressed()
}
}
override fun observeViewModel() {
with(viewModel){
collectionTicketList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if(it.tickets.isEmpty()){
if (R.id.collection_empty_text == collection_switcher.nextView.id){
collection_switcher.showNext()
}
}else{
collection = it
createCollectionList()
}
})
}
}
private fun createCollectionList(){
splash_progress.visibility = View.GONE
Log.i("Collection",collection.collectionFk)
}
}

View File

@ -0,0 +1,41 @@
package es.verdnatura.presentation.view.feature.collection.fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class CollectionViewModel : BaseViewModel() {
val emptyMessage = "La colección no tiene tickets";
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk).enqueue(object :
Callback<CollectionVO> {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!)
}
override fun onResponse(
call: Call<CollectionVO>,
response: Response<CollectionVO>
) {
if (response.body() != null){
_collectionTicketList.value = response.body()?.let { it }
}else{
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get")
}
}
})
}
}

View File

@ -49,8 +49,4 @@ class HistoricoViewModel : BaseViewModel() {
})
}
}

View File

@ -15,6 +15,7 @@ import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesFragment
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardFragment
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemFragment
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragment
import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasFragment
import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoFragment
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryFragment
@ -27,6 +28,8 @@ import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionT
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorFragment
@ -37,7 +40,7 @@ import kotlinx.coroutines.launch
class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClickListener,
OnTruckClickListener, OnPalletClickListener,OnComprobarPalletViewClickListener {
OnTruckClickListener, OnPalletClickListener,OnComprobarPalletViewClickListener,OnCollectionSelectedListener {
private var lastBottomMenuItemSelected: ItemMenuVO? = null
private lateinit var customDialog: CustomDialog
@ -126,7 +129,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
true
}
"Sacadores" -> {
"Función Sacadores desactivada".toast(this@MainActivity)
fm.popBackStack(null,FragmentManager.POP_BACK_STACK_INCLUSIVE)
addFragment(SacadorFragment.newInstance(),R.id.main_frame_layout, SacadorFragment.TAG,false)
true
}
"Controladores" -> {
@ -225,4 +229,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
addFragmentOnTop(ExpeditionPalletDetailFragment.newInstance(itemTruck,itemPallet))
}
override fun onCollectionSelected(collection: CollectionVO) {
addFragmentOnTop(CollectionFragment.newInstance(collection))
}
}

View File

@ -66,11 +66,11 @@ class ExpeditionPalletDetailViewModel: BaseViewModel() {
fun expeditionPalletPrintSet(usuario:String,password:String,vPalletFk:String){
getPaletizadoresUserCase.expeditionPalletPrintSet(usuario,password,vPalletFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al borrar pallet "+vPalletFk+ " Respuesta:"+t.message!!)
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al imprimir pallet "+vPalletFk+ " Respuesta:"+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_Del")
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_PrintSet")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}

View File

@ -41,8 +41,6 @@ class PasilleroFragment : BaseFragment<FragmentPasilleroBinding,PasilleroViewMod
}
override fun observeViewModel() {
with(viewModel){
pasilleros_items.adapter = PasillerosAdapter(pasillerositem,pasillerosItemClickListener!!)

View File

@ -0,0 +1,41 @@
package es.verdnatura.presentation.view.feature.sacador.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemCollectionRowBinding
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
class CollectionAdapter (
private val items: List<CollectionVO>,
private val onCollectionSelected: OnCollectionSelectedListener
): RecyclerView.Adapter<CollectionAdapter.AjustesItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
return AjustesItemHolder(
ItemCollectionRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
holder.bind(items[position])
holder.binding.root.setOnClickListener {
onCollectionSelected.onCollectionSelected(items[position])
}
}
class AjustesItemHolder(
val binding: ItemCollectionRowBinding
) : RecyclerView.ViewHolder(binding.root){
fun bind(item: CollectionVO) {
binding.apply {
this.item = item
}
}
}
}

View File

@ -0,0 +1,121 @@
package es.verdnatura.presentation.view.feature.sacador.fragment
import android.content.Context
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.sacador.adapter.CollectionAdapter
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import kotlinx.android.synthetic.main.fragment_sacador.*
import kotlinx.android.synthetic.main.toolbar.*
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(SacadorViewModel::class) {
private var user = ""
private var password = ""
private var sectorFk = ""
private var warehouseFk = ""
private var onCollectionSelectedListener : OnCollectionSelectedListener? = null
companion object {
fun newInstance() = SacadorFragment()
}
override fun onAttach(context: Context) {
super.onAttach(context)
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
}
override fun getLayoutId(): Int = R.layout.fragment_sacador
override fun onCreate(savedInstanceState: Bundle?) {
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()
viewModel.collectionGet(user,password)
super.onCreate(savedInstanceState)
}
override fun init() {
splash_progress.visibility = View.VISIBLE
toolbar_title.text = "collection_get"
setToolBar()
setEvents()
super.init()
}
private fun setToolBar(){
backButton.visibility = View.GONE
val listIcons:ArrayList<Drawable> = ArrayList()
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme())
listIcons.add(iconReload)
listIcons.add(iconAdd)
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){
splash_progress.visibility = View.VISIBLE
viewModel.collectionGet(user,password)
}else if(item == iconAdd){
splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,"",sectorFk)
}
}
})
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun setEvents(){
}
override fun observeViewModel() {
with(viewModel){
collectionList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if(it.list.isEmpty()){
if (R.id.sacador_empty_text == sacador_switcher.nextView.id){
sacador_switcher.showNext()
}
}else {
createCollectionList(it.list)
}
})
collectionTicketList.observe(viewLifecycleOwner, Observer {
navigateToCollectionList(it)
})
}
}
private fun createCollectionList(collections:List<CollectionVO>){
val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
val adapter = CollectionAdapter(collections,onCollectionSelectedListener!!)
fragment_sacador_collections.layoutManager = lm
fragment_sacador_collections.adapter = adapter
}
private fun navigateToCollectionList(collection:CollectionVO){
splash_progress.visibility = View.GONE
// onCollectionSelectedListener!!.onCollectionSelected(collection)
}
}

View File

@ -0,0 +1,75 @@
package es.verdnatura.presentation.view.feature.sacador.fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat
import es.verdnatura.presentation.view.feature.sacador.model.CollectionListVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class SacadorViewModel : BaseViewModel() {
val emptyMessage = "No tienes colecciones pendientes. Presiona sobre el + para crear colección";
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
private val _collectionList by lazy { MutableLiveData<CollectionListVO>() }
val collectionList: LiveData<CollectionListVO>
get() = _collectionList
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk).enqueue(object :
Callback<CollectionVO> {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!)
}
override fun onResponse(
call: Call<CollectionVO>,
response: Response<CollectionVO>
) {
if (response.body() != null){
_collectionTicketList.value = response.body()?.let { it }
}else{
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get")
}
}
})
}
fun collectionGet(usuario:String,password:String){
getSacadorControladorUserCase.collectionGet(usuario,password).enqueue(object :
Callback<List<CollectionVO>> {
override fun onFailure(call: Call<List<CollectionVO>>, t: Throwable) {
val listError:ArrayList<CollectionVO> = ArrayList()
listError.add(CollectionVO(isError = true,errorMessage = t.message!!))
_collectionList.value = CollectionListVO(listError)
}
override fun onResponse(
call: Call<List<CollectionVO>>,
response: Response<List<CollectionVO>>
) {
if (response.body() != null){
_collectionList.value = response.body()?.let { CollectionListVO(it.toDateFormat()) }
}else{
val listError:ArrayList<CollectionVO> = ArrayList()
listError.add(CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get"))
_collectionList.value = CollectionListVO(listError)
}
}
})
}
}

View File

@ -0,0 +1,27 @@
package es.verdnatura.presentation.view.feature.sacador.mapper
import es.verdnatura.presentation.common.convertToDateString
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
fun List<CollectionVO>.toDateFormat(): ArrayList<CollectionVO> {
val collections : ArrayList<CollectionVO> = ArrayList()
this.forEach {
collections.add(CollectionVO(
collectionFk = it.collectionFk,
created = getCalendarFromDate(it.created).convertToDateString()
))
}
return collections
}
private fun getCalendarFromDate(date:String): Calendar {
val sdf = SimpleDateFormat("yyyy-MM-dd")
val cal = Calendar.getInstance()
cal.setTime(sdf.parse(date))
return cal
}

View File

@ -0,0 +1,69 @@
package es.verdnatura.presentation.view.feature.sacador.model
class CollectionListVO(
var list: List<CollectionVO> = listOf()
)
class CollectionVO(
var collectionFk : String = "",
var created : String = "",
var tickets : List<TicketVO> = listOf(),
var isError : Boolean = false,
var errorMessage : String = ""
)
class TicketVO(
var ticketFk : String = "",
var level : String = "",
var agencyName : String = "",
var sales : List<SaleVO> = listOf()
)
class SaleVO(
var ticketFk : String = "",
var saleFk : String = "",
var itemFk : String = "",
var quantity : String = "",
var longName : String = "",
var size : String = "",
var reserved : String = "",
var isPreviousPrepared : String = "",
var isPrepared : String = "",
var isControlled : String = "",
var color : String = "",
var productor : String = "",
var discount : String = "",
var price : String = "",
var stems : String = "",
var category : String = "",
var origin : String = "",
var clientFk : String = "",
var originalQuantity : String = "",
var line1 : String = "",
var line2 : String = "",
var line3 : String = "",
var isAdded : String = "",
var startQuantity : String = "",
var workerFk : String = "",
var placements : List<PlacementVO> = listOf(),
var Barcodes : List<String> = listOf()
)
class PlacementVO(
var saleFk : String = "",
var itemFk : String = "",
var placement : String = "",
var shelving : String = "",
var created : String = "",
var visible : String = "",
var order : String = "",
var grouping : String = "",
var priority : String = "",
var saleOrder : String = "",
var isPreviousPrepared : String = "",
var itemShelvingSaleFk : String = "",
var ticketFk : String = "",
var id : String = ""
)

View File

@ -23,7 +23,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_navigation_height"
app:itemBackground="@color/verdnatura_black_3"
app:itemTextColor="@drawable/selector_bottombar_text"
app:itemTextColor="@color/verdnatura_white"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -26,7 +26,8 @@
android:textStyle="bold"
android:visibility="gone"
tools:text="¿Estás seguro de que deseas eliminar el dispositivo de celia?"
tools:visibility="visible" />
tools:visibility="visible"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/custom_dialog_description"
@ -37,7 +38,8 @@
android:textSize="@dimen/body1"
android:visibility="gone"
tools:text="Este cambio no podrá deshacerse a no ser que vuelvas a vincular el dispositivo"
tools:visibility="visible" />
tools:visibility="visible"
android:gravity="center_horizontal" />
<Button
android:id="@+id/custom_dialog_button_ok"

View File

@ -0,0 +1,76 @@
<?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.collection.fragment.CollectionViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black">
<ViewSwitcher
android:id="@+id/collection_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_collection_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:paddingTop="@dimen/toolbar_height"
tools:listitem="@layout/item_collection_row" />
<TextView
android:id="@+id/collection_empty_text"
android:layout_width="match_parent"
android:layout_height="@dimen/navigation_item_height"
android:gravity="center"
android:text="@{viewModel.emptyMessage}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1" />
</ViewSwitcher>
<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="visible"
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,76 @@
<?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.sacador.fragment.SacadorViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black">
<ViewSwitcher
android:id="@+id/sacador_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_sacador_collections"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:paddingTop="@dimen/toolbar_height"
tools:listitem="@layout/item_collection_row" />
<TextView
android:id="@+id/sacador_empty_text"
android:layout_width="match_parent"
android:layout_height="@dimen/navigation_item_height"
android:gravity="center"
android:text="@{viewModel.emptyMessage}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1" />
</ViewSwitcher>
<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="visible"
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,31 @@
<?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.sacador.model.SaleVO" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/item_row_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5"
android:padding="@dimen/pasilleros_margin_main_menu">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/verdnatura_black_9"/>
</LinearLayout>
</layout>

View File

@ -0,0 +1,58 @@
<?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.sacador.model.CollectionVO" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5"
android:padding="@dimen/pasilleros_margin_main_menu">
<TextView
android:id="@+id/item_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@{item.collectionFk}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h7"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/pasilleros_margin_main_menu"
android:textStyle="bold"/>
<TextView
android:id="@+id/item_selected"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@{item.created}"
android:textColor="@color/verdnatura_pumpkin_orange"
android:textSize="@dimen/h7"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/pasilleros_margin_main_menu"/>
<ImageView
android:layout_marginLeft="@dimen/default_layout_margin"
android:id="@+id/item_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_chevron_right_black_24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/verdnatura_black_9"/>
</LinearLayout>
</layout>

View File

@ -7,7 +7,7 @@
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@drawable/background_gradient">
android:background="@color/verdnatura_black_8_alpha_6">
<LinearLayout
android:layout_width="match_parent"
@ -47,7 +47,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_1"
tool:listitem="@layout/item_toolbar_row"/>
tool:listitem="@layout/item_toolbar_row"
android:layout_marginRight="@dimen/layout_margin_1" />
</LinearLayout>