feat: refs #5443 refactor
This commit is contained in:
parent
02306e8351
commit
abab532379
|
@ -146,7 +146,7 @@ class CollectionFragment(
|
||||||
|
|
||||||
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
|
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
|
||||||
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
|
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
|
||||||
if (type.equals(CONTROLADOR)) {
|
if (type.equals(CONTROLADOR) && collection.collectionFk != 0) {
|
||||||
//sergio: comprueba si viene de la pantalla de controlador
|
//sergio: comprueba si viene de la pantalla de controlador
|
||||||
//Tarea #4280
|
//Tarea #4280
|
||||||
viewModel.ticketIsOutClosureZone(
|
viewModel.ticketIsOutClosureZone(
|
||||||
|
@ -162,7 +162,7 @@ class CollectionFragment(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collection.tickets.isEmpty()) {
|
if (collection.tickets.isEmpty() && collection.collectionFk != 0) {
|
||||||
viewModel.collectionTicketGet(
|
viewModel.collectionTicketGet(
|
||||||
collection.collectionFk,
|
collection.collectionFk,
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||||
|
@ -179,7 +179,6 @@ class CollectionFragment(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
|
|
||||||
customDialogList = CustomDialogList(requireContext())
|
customDialogList = CustomDialogList(requireContext())
|
||||||
customDialogInput = CustomDialogInput(requireContext())
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
customDialog = CustomDialog(requireContext())
|
customDialog = CustomDialog(requireContext())
|
||||||
|
@ -204,12 +203,15 @@ class CollectionFragment(
|
||||||
|
|
||||||
private fun setToolBar() {
|
private fun setToolBar() {
|
||||||
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
|
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
|
||||||
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
|
binding.mainToolbar.toolbarIcons.visibility =
|
||||||
|
if (type == CONTROLADOR && collection.collectionFk == 0) GONE else VISIBLE
|
||||||
binding.mainToolbar.backButton.visibility = VISIBLE
|
binding.mainToolbar.backButton.visibility = VISIBLE
|
||||||
collection.collectionFk.let {
|
collection.collectionFk.let {
|
||||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
binding.mainToolbar.toolbarTitle.text =
|
||||||
|
if (collection.collectionFk != 0) collection.collectionFk.toString() else {
|
||||||
|
getString(R.string.controlticket)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
val iconPrint = ImageView(context)
|
val iconPrint = ImageView(context)
|
||||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||||
|
@ -406,7 +408,7 @@ class CollectionFragment(
|
||||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
|
||||||
if (!binding.scanInput.text.toString().isNullOrEmpty()) {
|
if (!binding.scanInput.text.toString().isNullOrEmpty()) {
|
||||||
|
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
|
||||||
//sergio:para ver si ha marcado dos veces el mismo ticket
|
//sergio:para ver si ha marcado dos veces el mismo ticket
|
||||||
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
|
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
|
||||||
|
|
||||||
|
@ -438,7 +440,6 @@ class CollectionFragment(
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonPushedGetCollection = false
|
buttonPushedGetCollection = false
|
||||||
|
|
||||||
}
|
}
|
||||||
binding.scanInput.setText("")
|
binding.scanInput.setText("")
|
||||||
hideKeyboards()
|
hideKeyboards()
|
||||||
|
@ -525,18 +526,19 @@ class CollectionFragment(
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
responseParking.observe(viewLifecycleOwner, Observer {
|
loadParking.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
if (!goBack) {
|
if (!goBack) {
|
||||||
|
|
||||||
ma.messageWithSound(
|
ma.messageWithSound(
|
||||||
if (it.isError) it.errorMessage else getString(R.string.Aparcado),
|
if (it.isError) it.errorMessage else getString(R.string.Aparcado),
|
||||||
it.isError,
|
it.isError,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
|
||||||
|
|
||||||
responsePrint.observe(viewLifecycleOwner, Observer {
|
responsePrint.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
||||||
|
@ -575,22 +577,24 @@ class CollectionFragment(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
responseSaleGroup.observe(viewLifecycleOwner, Observer {
|
loadResponseSaleGroup.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
if (it.isError) {
|
if (it.isError) {
|
||||||
|
|
||||||
ma.messageWithSound(it.errorMessage, true, true)
|
ma.messageWithSound(it.errorMessage, true, true)
|
||||||
} else {
|
} else {
|
||||||
ma.messageWithSound(getString(R.string.previousCollected), false, true)
|
ma.messageWithSound(getString(R.string.previousCollected), false, true)
|
||||||
|
|
||||||
viewModel.collectionTicketGet(
|
viewModel.collectionTicketGet(
|
||||||
collection.collectionFk,
|
collection.collectionFk,
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||||
print = "0",
|
print = "0",
|
||||||
type
|
type
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
placementSuppleyList.observe(viewLifecycleOwner, Observer {
|
placementSuppleyList.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
||||||
if (!goBack) printShelvingResult(it)
|
if (!goBack) printShelvingResult(it)
|
||||||
|
@ -603,33 +607,34 @@ class CollectionFragment(
|
||||||
goBack = false
|
goBack = false
|
||||||
})
|
})
|
||||||
|
|
||||||
responseNew.observe(viewLifecycleOwner, Observer {
|
loadAddNew.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
// if (!goBack) {
|
// if (!goBack) {
|
||||||
if (it.isError) {
|
if (it.isError) {
|
||||||
customDialog.setTitle(getString(R.string.disponibility))
|
customDialog.setTitle(getString(R.string.disponibility))
|
||||||
.setDescription(getString(R.string.errorCollectionNew) + it.errorMessage)
|
.setDescription(getString(R.string.errorCollectionNew) + it.errorMessage)
|
||||||
.setKoButton(getString(R.string.close)) {
|
.setKoButton(getString(R.string.close)) {
|
||||||
scanRequest()
|
scanRequest()
|
||||||
customDialog.dismiss()
|
customDialog.dismiss()
|
||||||
}.show()
|
}.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!goBack) {
|
if (!goBack) {
|
||||||
|
|
||||||
viewModel.collectionTicketGet(
|
viewModel.collectionTicketGet(
|
||||||
collection.collectionFk,
|
collection.collectionFk,
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||||
print = "0",
|
print = "0",
|
||||||
type
|
type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goBack = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goBack = false
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
responseCode.observe(viewLifecycleOwner, Observer {
|
responseCode.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
||||||
|
@ -655,71 +660,76 @@ class CollectionFragment(
|
||||||
goBack2 = false
|
goBack2 = false
|
||||||
|
|
||||||
})
|
})
|
||||||
responseTicketState.observe(viewLifecycleOwner) {
|
loadTicketState.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
if (!goBack) {
|
if (!goBack) {
|
||||||
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
|
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
|
||||||
var customDialogWarningChecking = CustomDialog(requireContext())
|
var customDialogWarningChecking = CustomDialog(requireContext())
|
||||||
customDialogWarningChecking.setTitle(getString(R.string.info))
|
customDialogWarningChecking.setTitle(getString(R.string.info))
|
||||||
customDialogWarningChecking.setDescription(
|
customDialogWarningChecking.setDescription(
|
||||||
if (it.code == "ON_CHECKING") {
|
if (it.code == "ON_CHECKING") {
|
||||||
getString(R.string.checkingByUser, it.user.username)
|
getString(R.string.checkingByUser, it.user.username)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.checkedByUser, it.user.username)
|
getString(R.string.checkedByUser, it.user.username)
|
||||||
}
|
}
|
||||||
).setOkButton(getString(R.string.aware)) {
|
).setOkButton(getString(R.string.aware)) {
|
||||||
customDialogWarningChecking.dismiss()
|
customDialogWarningChecking.dismiss()
|
||||||
}.show()
|
}.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
responseTicketClosure.observe(viewLifecycleOwner, Observer {
|
loadTicketClousure.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
if (!goBack) {
|
|
||||||
if (it.response.toBoolean()) {
|
|
||||||
var customDialogWarning = CustomDialog(requireContext())
|
|
||||||
customDialogWarning.setTitle(getString(R.string.urgentWarning))
|
|
||||||
customDialogWarning.setDescription(getString(R.string.ticketWarning))
|
|
||||||
.setOkButton(getString(R.string.aware)) {
|
|
||||||
customDialogWarning.dismiss()
|
|
||||||
}.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
responseIncQuantity.observe(viewLifecycleOwner, Observer {
|
|
||||||
|
|
||||||
if (it.isError) {
|
|
||||||
ma.messageWithSound(it.errorMessage, isError = true, true)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (!goBack) {
|
if (!goBack) {
|
||||||
incresaseSuccesful()
|
if (it.response.toBoolean()) {
|
||||||
} else {
|
var customDialogWarning = CustomDialog(requireContext())
|
||||||
goBack = false
|
customDialogWarning.setTitle(getString(R.string.urgentWarning))
|
||||||
|
customDialogWarning.setDescription(getString(R.string.ticketWarning))
|
||||||
|
.setOkButton(getString(R.string.aware)) {
|
||||||
|
customDialogWarning.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})
|
loadIncQuantity.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer {
|
|
||||||
|
|
||||||
if (!goBack) {
|
|
||||||
if (it.isError) {
|
if (it.isError) {
|
||||||
ma.messageWithSound(it.errorMessage, isError = true, true)
|
ma.messageWithSound(it.errorMessage, isError = true, true)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ma.messageWithSound(
|
if (!goBack) {
|
||||||
getString(R.string.errorRegistered), isError = false, false
|
incresaseSuccesful()
|
||||||
)
|
} else {
|
||||||
goBack = true
|
goBack = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
loadSaleMistakeAdd.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
|
if (!goBack) {
|
||||||
|
if (it.isError) {
|
||||||
|
ma.messageWithSound(it.errorMessage, isError = true, true)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.errorRegistered), isError = false, false
|
||||||
|
)
|
||||||
|
goBack = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mistakeList.observe(viewLifecycleOwner, Observer {
|
mistakeList.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
|
@ -6,6 +6,8 @@ import android.graphics.drawable.Drawable
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -123,6 +125,7 @@ class CollectionFragmentPicker(
|
||||||
private var itemShelvingTracking_mark: Int = 0
|
private var itemShelvingTracking_mark: Int = 0
|
||||||
private var recylerViewState: Parcelable? = null
|
private var recylerViewState: Parcelable? = null
|
||||||
private var isScanned: Boolean? = null
|
private var isScanned: Boolean? = null
|
||||||
|
private var myPosition: Int = 0
|
||||||
|
|
||||||
private lateinit var myGroupList: List<SaleVO>
|
private lateinit var myGroupList: List<SaleVO>
|
||||||
private var canChangeState = true
|
private var canChangeState = true
|
||||||
|
@ -288,6 +291,9 @@ class CollectionFragmentPicker(
|
||||||
when (type) {
|
when (type) {
|
||||||
CONTROLADOR -> markLine(indice, type)
|
CONTROLADOR -> markLine(indice, type)
|
||||||
SACADOR -> {
|
SACADOR -> {
|
||||||
|
//jose antonio
|
||||||
|
myPosition = myGroupList.indexOfFirst { it.saleGroupFk == saleGroupScanned }
|
||||||
|
println("previa $saleGroupScanned posicion $myPosition")
|
||||||
viewModel.saleTrackingAddPreparedSaleGroup(
|
viewModel.saleTrackingAddPreparedSaleGroup(
|
||||||
saleGroupScanned.toInt()
|
saleGroupScanned.toInt()
|
||||||
)
|
)
|
||||||
|
@ -546,7 +552,7 @@ class CollectionFragmentPicker(
|
||||||
ma.messageWithSound(it.errorMessage, true, true)
|
ma.messageWithSound(it.errorMessage, true, true)
|
||||||
} else {
|
} else {
|
||||||
ma.messageWithSound(getString(R.string.previousCollected), false, true)
|
ma.messageWithSound(getString(R.string.previousCollected), false, true)
|
||||||
|
|
||||||
viewModel.collectionTicketGet(
|
viewModel.collectionTicketGet(
|
||||||
collection.collectionFk,
|
collection.collectionFk,
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||||
|
@ -835,6 +841,7 @@ class CollectionFragmentPicker(
|
||||||
} else {
|
} else {
|
||||||
// pintar línea
|
// pintar línea
|
||||||
saleAdapter!!.notifyDataSetChanged()
|
saleAdapter!!.notifyDataSetChanged()
|
||||||
|
myPosition = storedPosition
|
||||||
|
|
||||||
ReviewQuantityForRefreshingAndSorting(
|
ReviewQuantityForRefreshingAndSorting(
|
||||||
sales[storedPosition].quantity!!.toInt(),
|
sales[storedPosition].quantity!!.toInt(),
|
||||||
|
@ -1378,6 +1385,13 @@ class CollectionFragmentPicker(
|
||||||
}
|
}
|
||||||
isMarking = true
|
isMarking = true
|
||||||
setTotalLines()
|
setTotalLines()
|
||||||
|
|
||||||
|
val handler = Handler(Looper.getMainLooper())
|
||||||
|
handler.postDelayed({
|
||||||
|
val inputMethodManager =
|
||||||
|
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(binding.scanInput.windowToken, 0)
|
||||||
|
}, 300L)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkStateParent() {
|
private fun checkStateParent() {
|
||||||
|
@ -1415,7 +1429,7 @@ class CollectionFragmentPicker(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setListPosition(position: Int, isFromBack: Boolean) {
|
private fun setListPosition(position: Int, isFromBack: Boolean) {
|
||||||
lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
|
lm!!.scrollToPositionWithOffset(myPosition, 0)
|
||||||
// lm!!.scrollToPositionWithOffset(position, 0)
|
// lm!!.scrollToPositionWithOffset(position, 0)
|
||||||
|
|
||||||
/* storedPosition = position
|
/* storedPosition = position
|
||||||
|
@ -1523,6 +1537,7 @@ class CollectionFragmentPicker(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storedBackPosition = position
|
storedBackPosition = position
|
||||||
|
myPosition = position
|
||||||
setListPosition(position, false)
|
setListPosition(position, false)
|
||||||
if (type != PRECHECKER) {
|
if (type != PRECHECKER) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue