This commit is contained in:
Enrique Blasco 2020-10-26 06:43:17 +01:00
parent 0221d9b6c3
commit d45e713166
7 changed files with 98 additions and 50 deletions

View File

@ -14,8 +14,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 39
versionName "5.2.9"
versionCode 42
versionName "5.3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -210,7 +210,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
override fun onError(error: Int) {
Log.i("Speech", "onError "+error)
mSpeechRecognizer!!.destroy()
if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
initialize()
}

View File

@ -125,7 +125,7 @@ class CollectionFragment(
customDialog = CustomDialog(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
toolbar_title.text = "collectionTicket_get"
setToolBar()
setEvents()
@ -201,7 +201,7 @@ class CollectionFragment(
//LISTA =========
collection_swipe.setOnRefreshListener {
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
collection_swipe.isRefreshing = false
}
@ -217,7 +217,7 @@ class CollectionFragment(
with(viewModel){
collectionTicketList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!it.isError){
if(it.tickets.isNotEmpty()){
collection = it
@ -228,7 +228,7 @@ class CollectionFragment(
}else{
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
customDialog.dismiss()
activity!!.onBackPressed()
if (activity != null) activity!!.onBackPressed()
}.show()
}
@ -236,19 +236,19 @@ class CollectionFragment(
})
placementSuppleyList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!goBack) printShelvingResult(it)
goBack = false
})
item.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!goBack) toastDisponibility(it)
goBack = false
})
responseNew.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!goBack){
if (it.isError){
customDialog.setTitle("Disponibilidad").setDescription(it.errorMessage).setKoButton("Cerrar"){
@ -256,7 +256,7 @@ class CollectionFragment(
customDialog.dismiss()
}.show()
}else{
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
}
}
@ -266,7 +266,7 @@ class CollectionFragment(
})
responseCode.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!goBack2){
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setKoButton("Cerrar"){
@ -282,7 +282,7 @@ class CollectionFragment(
}else{
customDialogList.setValueTwo("")
showErrorMessage("El resultado del procedimiento barcodeToItem de la etiqueta escaneada es: " +it.response)
mperror?.start()
if (mperror != null) mperror?.start()
}
}
}
@ -297,7 +297,7 @@ class CollectionFragment(
})
mistakeList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
if (!goBack) showMistakeList(it.list)
goBack = false
})
@ -314,9 +314,10 @@ class CollectionFragment(
}
toolbar_title.text = collection.collectionFk
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
var salesList:ArrayList<SaleVO> = ArrayList()
tickets = ArrayList()
var observations = ""
collection.tickets.forEach { ticket ->
ticket.sales.forEach {saleVO ->
if (type == SACADOR && saleVO.quantity != "0"){
@ -328,8 +329,9 @@ class CollectionFragment(
if (tickets.firstOrNull { it == saleVO.ticketFk}.isNullOrEmpty())
tickets.add(saleVO.ticketFk)
}
}
observations = observations + " " + ticket.observations
}
sales = salesList.sortedWith(compareBy({ it.saleOrder }))
@ -364,7 +366,7 @@ class CollectionFragment(
},object: OnMistakeClickListener{
override fun onMistakeClickListener(sale: SaleVO) {
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
mistakeSale = sale
viewModel.mistakeType(usuario = user, password = password)
}
@ -381,6 +383,7 @@ class CollectionFragment(
setScrollListener(lm!!)
changeInitTicketState()
printObservations(observations)
}
private fun setScrollListener(lm: LinearLayoutManager){
@ -393,6 +396,14 @@ class CollectionFragment(
}
private fun printObservations(observations: String){
if (observations.trim().isNotEmpty()){
customDialog.setTitle("Observaciones").setDescription(observations).setOkButton("Aceptar"){
customDialog.hide()
customDialog.dismiss()
}.show()
}
}
//SEARCH AND MARK
private fun findSale(txtscan:String){
@ -400,6 +411,9 @@ class CollectionFragment(
var index = 0
var isBreak = false
var isOk = false
goBack = false
goBack2 = false
if (type == SACADOR){
for (saleVO in sales) {
if(saleVO.isPrepared != "1" && saleVO.isPreviousPrepared != "1"){
@ -415,7 +429,7 @@ class CollectionFragment(
var shelvingIndex = 0
for (placementVO in saleVO.placements){
if (placementVO.shelving != null && placementVO.visible != null && txtscan.toUpperCase() == placementVO.shelving.toUpperCase() && placementVO.visible != "(0)"){
mpok!!.start()
if (mpok != null) mpok!!.start()
isOk = true
showShelving(index,shelvingIndex)
isBreak = true
@ -449,10 +463,10 @@ class CollectionFragment(
parking = txtscan
)
}
mpok!!.start()
if (mpok != null) mpok!!.start()
"Ticket aparcado".toast(requireContext())
}else{
mperror!!.start()
if (mperror != null) mperror!!.start()
}
}
@ -461,7 +475,7 @@ class CollectionFragment(
if(saleVO.isControlled == "0"){
//1- Por itemFk
if (txtscan == saleVO.itemFk){
mpok!!.start()
if (mpok != null) mpok!!.start()
isOk = true
markLine(index,type)
break
@ -469,7 +483,7 @@ class CollectionFragment(
//2- Por barcode
saleVO.Barcodes.forEach { barcode ->
if (txtscan == barcode){
mpok!!.start()
if (mpok != null) mpok!!.start()
isOk = true
markLine(index,type)
isBreak = true
@ -490,10 +504,10 @@ class CollectionFragment(
parking = txtscan
)
}
mpok!!.start()
if (mpok != null) mpok!!.start()
getString(R.string.Ticketaparcado).toast(requireContext())
}else{
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
storedPosition = 0
storedBackPosition = 0
viewModel.collectionTicketGet(user,password,txtscan,sectorFk)
@ -510,18 +524,18 @@ class CollectionFragment(
if(saleVO.isPrepared != "1" && saleVO.isPreviousPrepared != "1"){
//1- Por itemFk
if (txtscan == saleVO.itemFk){
mpok!!.start()
/*if (txtscan == saleVO.itemFk){
if (mpok != null) mpok!!.start()
isOk = true
markLine(position,type)
}
}*/
if (!isOk){
//2- Por carro
var shelvingIndex = 0
for (placementVO in saleVO.placements){
if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase()){
mpok!!.start()
if (mpok != null) mpok!!.start()
isOk = true
showShelving(position,shelvingIndex)
break
@ -529,17 +543,17 @@ class CollectionFragment(
shelvingIndex+=1
}
}
/*
if (!isOk){
//3- Por barcode
saleVO.Barcodes.forEach { barcode ->
if (txtscan == barcode){
mpok!!.start()
if (mpok != null) mpok!!.start()
isOk = true
markLine(position,type)
}
}
}
}*/
}
if (!isOk) {
if (txtscan.contains("-")){
@ -551,10 +565,10 @@ class CollectionFragment(
parking = txtscan
)
}
mpok!!.start()
if (mpok != null) mpok!!.start()
"Ticket aparcado".toast(requireContext())
}else{
mperror!!.start()
if (mperror != null) mperror!!.start()
}
}
@ -640,7 +654,7 @@ class CollectionFragment(
private fun showShelving(position:Int,shelvingPosition:Int){
storedShelvingPosition = shelvingPosition
storedPosition = position
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
var quantityGet = "0"
try{
quantityGet = (sales[position].quantity.toInt() - sales[position].pickedQuantity.toInt()).toString()
@ -692,7 +706,7 @@ class CollectionFragment(
customDialogList.dismiss()
} else {
itemShelvingFkStored = itemShelvingFk
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.getIdFromCode(
usuario = user,
password = password,
@ -721,9 +735,12 @@ class CollectionFragment(
try{
customDialogList.getEditTextTwo().post(Runnable {
customDialogList.getEditTextTwo().requestFocusFromTouch()
val lManager: InputMethodManager =
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
lManager.hideSoftInputFromWindow(customDialogList.getEditTextTwo().windowToken, InputMethodManager.SHOW_FORCED)
if (activity != null) {
val lManager: InputMethodManager =
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
lManager.hideSoftInputFromWindow(customDialogList.getEditTextTwo().windowToken, InputMethodManager.SHOW_FORCED)
}
})
}catch (e:Exception){}
try {
@ -875,7 +892,7 @@ class CollectionFragment(
}else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo().isNullOrEmpty()) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
}else{
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.collectionAddItem(
usuario = user,
password = password,
@ -916,7 +933,7 @@ class CollectionFragment(
}else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo().isNullOrEmpty()) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
}else{
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.collectionAddItem(
usuario = user,
password = password,
@ -984,7 +1001,7 @@ class CollectionFragment(
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
viewModel.itemGetAvailable(
usuario = user,
password = password,
@ -1029,7 +1046,7 @@ class CollectionFragment(
}
}
//toolbar_title.text = "" + totalMark + "/" + sales.size
toolbar_title.text = if (collection.collectionFk != null )collection.collectionFk else ""
if (toolbar_title != null) toolbar_title.text = if (collection.collectionFk != null )collection.collectionFk else ""
toolbar_subtitle.text = "" +totalMark + "/" + sales.size
if (totalMark == sales.size) {
getString(R.string.Coleccióncompleta).toast(this.context,Toast.LENGTH_SHORT)
@ -1311,7 +1328,7 @@ class CollectionFragment(
}
private fun showMistakeList(list:List<MistakeTypeVO>){
splash_progress.visibility = View.GONE
if (splash_progress != null) splash_progress.visibility = View.GONE
listPlacementSupply = ArrayList()
list.forEach {
listPlacementSupply.add(BarcodeVO(code = it.description))

View File

@ -214,8 +214,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
override fun onBackPressed() {
try{
fm.executePendingTransactions()
}catch (e:Exception){}
if (fm.backStackEntryCount > 0) {
fm.popBackStackImmediate()
}else {
customDialog.setTitle("Cerrar sesión").setDescription("¿Estás seguro de cerrar la sesión?").setOkButton("Salir"){

View File

@ -17,7 +17,8 @@ class TicketVO(
var level : String = "",
var agencyName : String = "",
var salesPersonFk : String = "",
var sales : List<SaleVO> = listOf()
var sales : List<SaleVO> = listOf(),
var observations: String = ""
)
class SaleVO(
var ticketFk : String = "",

View File

@ -1,6 +1,7 @@
package es.verdnatura.presentation.view.feature.ubicador.fragment
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
@ -9,9 +10,11 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentAutomaticAddItemBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnAutomaticItemClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogUbicador
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapter
import es.verdnatura.presentation.view.feature.ubicador.model.ItemEscanerVO
@ -33,6 +36,7 @@ class AutomaticAddItemFragment(
private var listItems:ArrayList<ItemEscanerVO> = ArrayList()
private lateinit var customDialog: CustomDialog
private var deep:Int = 1
private var contador = 0
companion object {
fun newInstance(entryPoint:String) = AutomaticAddItemFragment(entryPoint)
@ -54,12 +58,23 @@ class AutomaticAddItemFragment(
toolbar_title.text = "itemShelvingMake"
setEvents()
setViews()
setToolBar()
super.init()
}
private fun setToolBar(){
toolbar_subtitle.visibility = View.VISIBLE
}
private fun setSubtitle(){
toolbar_subtitle.text = "Etiquetas: "+contador
}
private fun setViews(){
adapter = AutomaticAdapter(listItems,object: OnAutomaticItemClickListener{
override fun onAutomaticItemClickListener(position: Int) {
contador -= 1
setSubtitle()
listItems.removeAt(position)
adapter!!.notifyDataSetChanged()
}
@ -73,7 +88,9 @@ class AutomaticAddItemFragment(
edit_matricula.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!edit_matricula.text.toString().isNullOrEmpty()){
listItems.add(ItemEscanerVO(edit_matricula.text.toString()))
contador += 1
setSubtitle()
listItems.add(0,ItemEscanerVO(edit_matricula.text.toString()))
adapter!!.notifyDataSetChanged()
}
edit_matricula.setText("")

View File

@ -29,7 +29,9 @@ import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.fragment_ubicador.*
import kotlinx.android.synthetic.main.fragment_ubicador.splash_progress
import kotlinx.android.synthetic.main.toolbar.*
class UbicadorFragment(
@ -417,7 +419,7 @@ class UbicadorFragment(
}
private fun changeOfflineValue(item:ItemUbicadorVO){
splash_progress.visibility = View.VISIBLE
if (splash_progress != null) splash_progress.visibility = View.VISIBLE
/*listItems.add(item)
adapter?.notifyDataSetChanged()*/
}
@ -425,10 +427,17 @@ class UbicadorFragment(
private fun showMoreOptions(item:ItemUbicadorVO){
customDialogTwoButtons.setTitle(item.item).setDescription("Selecciona una acción").setOkButton("Transferir"){
customDialogInput.setTitle("Nueva matrícula").setDescription("Introduce el destino para item: "+item.item).setValue("").setOkButton("Transferir"){
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue())
listItems.remove(item)
adapter!!.notifyDataSetChanged()
customDialogInput.dismiss()
if (customDialogInput.getValue().isNotEmpty()){
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue())
listItems.remove(item)
adapter!!.notifyDataSetChanged()
customDialogInput.dismiss()
}else{
"Carro incorrecto".toast(requireContext())
}
}.setKoButton("Cancelar"){
customDialogInput.dismiss()
}.show()