refs #6560 refactor:settings
This commit is contained in:
parent
24fd2152bb
commit
0f4ed51427
|
@ -11,10 +11,10 @@ import es.verdnatura.databinding.ItemAjustesRowBinding
|
|||
import es.verdnatura.presentation.common.OnAjustesItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||
|
||||
class AjustesAdapter (
|
||||
class SettingsAdapter (
|
||||
private val items: List<AjustesItemVO>,
|
||||
private val onAjustesItemClickListener: OnAjustesItemClickListener
|
||||
): RecyclerView.Adapter<AjustesAdapter.AjustesItemHolder> () {
|
||||
): RecyclerView.Adapter<SettingsAdapter.AjustesItemHolder> () {
|
||||
|
||||
var context: Context? = null
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||
|
@ -43,7 +43,6 @@ class AjustesAdapter (
|
|||
binding.apply {
|
||||
|
||||
this.item = item
|
||||
|
||||
if (item.title==context!!.getString(R.string.closeSession)){
|
||||
binding.itemTitle.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context.CLIPBOARD_SERVICE
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.TooltipCompat.setTooltipText
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
|
@ -20,17 +15,14 @@ import es.verdnatura.domain.ConstAndValues.PRINTERFK
|
|||
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
||||
import es.verdnatura.domain.ConstAndValues.SERIALNUMBER
|
||||
import es.verdnatura.domain.ConstAndValues.TRAINFK
|
||||
import es.verdnatura.domain.ConstAndValues.TRAINNAME
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnAjustesItemClickListener
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter
|
||||
import es.verdnatura.presentation.view.feature.ajustes.adapter.SettingsAdapter
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||
|
@ -39,29 +31,22 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
|||
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class AjustesFragment :
|
||||
BaseFragment<FragmentAjustesBinding, AjustesViewModel>(AjustesViewModel::class) {
|
||||
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private var sectorListVO: List<SectorItemVO> = listOf()
|
||||
private var printersList: List<Printers> = listOf()
|
||||
private var trainsList: List<Train> = listOf()
|
||||
private var ajustesAdapter: AjustesAdapter? = null
|
||||
private var settingsAdapter: SettingsAdapter? = null
|
||||
private var isWorkerAllowed: Boolean = false
|
||||
private var itemPackingList: List<ItemPackingType> = listOf()
|
||||
private var messagePrinter: String? = null
|
||||
private lateinit var loginViewModel: LoginViewModel
|
||||
private lateinit var pasilleroViewModel: PasilleroViewModel
|
||||
|
||||
//añadido
|
||||
private var wagonList: List<String> = listOf()
|
||||
private var tagsList: List<String> = listOf()
|
||||
|
||||
companion object {
|
||||
fun newInstance() = AjustesFragment()
|
||||
}
|
||||
|
@ -69,8 +54,8 @@ class AjustesFragment :
|
|||
override fun getLayoutId(): Int = R.layout.fragment_ajustes
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
customDialog = CustomDialog(requireContext())
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
}
|
||||
|
@ -79,231 +64,155 @@ class AjustesFragment :
|
|||
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.settings)
|
||||
hideBackButton(binding.mainToolbar)
|
||||
|
||||
viewModel.worker_isF11Allowed()
|
||||
|
||||
viewModel.workerIsF11Allowed()
|
||||
binding.userText.text = mobileApplication.userName
|
||||
val versionName = requireActivity().packageManager.getPackageInfo(
|
||||
binding.itemVersion.text = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
).versionName!!
|
||||
binding.itemVersion.text = versionName
|
||||
binding.androididText.text =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ANDROID_ID)
|
||||
|
||||
// Tarea 4815
|
||||
binding.serialNumber.text = mobileApplication.serialNumber
|
||||
// binding.txtserver.setText(getData(getString(R.string.baseurl)))
|
||||
setEvents()
|
||||
|
||||
super.init()
|
||||
|
||||
}
|
||||
|
||||
fun setEvents() {
|
||||
binding.androididText.setOnClickListener { copyanddrag(binding.androididText.text.toString()) }
|
||||
binding.androididText.setOnLongClickListener { copyanddrag(binding.androididText.text.toString()) }
|
||||
binding.serialText.setOnLongClickListener {
|
||||
customDialogInput.setTitle(getString(R.string.serialNumberDescrip))
|
||||
.setDescription(getString(R.string.serialNumber))
|
||||
.setOkButton(getString(R.string.save)) {
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
SERIALNUMBER, customDialogInput.getValue()
|
||||
)
|
||||
}
|
||||
binding.serialNumber.text = customDialogInput.getValue()
|
||||
ma.hideKeyboard()
|
||||
customDialogInput.dismiss()
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
customDialogInput.dismiss()
|
||||
}.show()
|
||||
customDialogInput.setFocusText()
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
ajustesAdapter = AjustesAdapter(ajustesitem, object : OnAjustesItemClickListener {
|
||||
settingsAdapter = SettingsAdapter(settingsItem, object : OnAjustesItemClickListener {
|
||||
override fun onAjustesItemClickListener(item: AjustesItemVO) {
|
||||
|
||||
if (item.action) {
|
||||
|
||||
if (item.id == 0) {
|
||||
viewModel.getSectorsSalix()
|
||||
} else if (item.id == 5) {
|
||||
ma.onMyBackPressed()
|
||||
} else if (item.id == 1) {
|
||||
|
||||
ma.messageWithSound(
|
||||
getString(R.string.managerWagon), true, true, "Información", false
|
||||
)
|
||||
|
||||
} else if (item.id == 2) {
|
||||
messagePrinter = getString(R.string.Selecccionaimpresoara)
|
||||
viewModel.printer_get()
|
||||
|
||||
} else if (item.id == 4) {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleUserControlVehicle)
|
||||
), mobileApplication.userId.toString()
|
||||
)
|
||||
|
||||
} else if (item.id == 6) {
|
||||
viewModel.train_get()
|
||||
} else if (item.id == 7) {
|
||||
viewModel.getItemPackingTypeSalix()
|
||||
} else if (item.title == getString(R.string.menuByDefault)) {
|
||||
showMenuByDefault()
|
||||
when (item.title) {
|
||||
getString(R.string.sector) -> viewModel.getSectorsSalix()
|
||||
getString(R.string.closeSession) -> ma.onMyBackPressed()
|
||||
getString(R.string.printerLabel) -> {
|
||||
messagePrinter = getString(R.string.SelectPrinter)
|
||||
viewModel.printerGet()
|
||||
}
|
||||
|
||||
getString(R.string.vehicleControl) -> ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleUserControlVehicle)
|
||||
), mobileApplication.userId.toString()
|
||||
)
|
||||
|
||||
getString(R.string.menuByDefault) -> showMenuByDefault()
|
||||
getString(R.string.settingsTitleItemPacking) -> viewModel.getItemPackingTypeSalix()
|
||||
getString(R.string.settingsTitleTrain) -> viewModel.trainGet()
|
||||
|
||||
else -> {}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
workerAllowedResponse.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(it.errorMessage, it.isError, true)
|
||||
|
||||
} else {
|
||||
isWorkerAllowed = it.response.toBoolean()
|
||||
loginViewModel = LoginViewModel(context as MobileApplication)
|
||||
loginViewModel.operator_getDataSalix(mobileApplication.userId!!)
|
||||
loginViewModel.workerOperator.observe(this@AjustesFragment) { it ->
|
||||
|
||||
if (!it.isError) {
|
||||
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(it) }
|
||||
} else {
|
||||
ma.messageWithSound(it.errorMessage, it.isError, true)
|
||||
}
|
||||
isWorkerAllowed = it.response.toBoolean()
|
||||
loginViewModel = LoginViewModel(context as MobileApplication)
|
||||
loginViewModel.operator_getDataSalix(mobileApplication.userId!!)
|
||||
loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
|
||||
if (!iti.isError) {
|
||||
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
|
||||
} else {
|
||||
ma.messageWithSound(it.errorMessage, isError = true, isPlayed = true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setSettings(isWorkerAllowed)
|
||||
|
||||
}
|
||||
|
||||
actionUpdate.observe(viewLifecycleOwner) {
|
||||
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else {
|
||||
getString(R.string.itemUpdated)
|
||||
}, it.isError, false
|
||||
)
|
||||
|
||||
messagePrinter =
|
||||
getString(R.string.Selecccionaimpresoara) + "\n" + getString(R.string.printerRemoved)
|
||||
viewModel.printer_get()
|
||||
|
||||
}
|
||||
loadUpdatePacking.observe(viewLifecycleOwner) { event ->
|
||||
loadActionUpdate.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else {
|
||||
getString(R.string.itemUpdated)
|
||||
}, it.isError, false
|
||||
)
|
||||
|
||||
messagePrinter =
|
||||
getString(R.string.SelectPrinter) + "\n" + getString(R.string.printerRemoved)
|
||||
viewModel.printerGet()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
actionUpdatePacking.observe(viewLifecycleOwner) {
|
||||
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else {
|
||||
getString(R.string.itemUpdated)
|
||||
}, it.isError, false
|
||||
)
|
||||
}
|
||||
|
||||
binding.setttingsItems.adapter = ajustesAdapter
|
||||
binding.setttingsItems.adapter = settingsAdapter
|
||||
binding.setttingsItems.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
loadSectorList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
if (it.list.isNotEmpty() && it.list.get(0).isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.list.get(0).errorMessage)
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
|
||||
if (it.list.isNotEmpty()) {
|
||||
val listSectores: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listSectores.add(it.description)
|
||||
}
|
||||
// modificar
|
||||
listSectores.sort()
|
||||
val array = arrayOfNulls<String>(listSectores.size)
|
||||
sectorListVO = it.list
|
||||
showDialogForAll(
|
||||
listSectores.toArray(array), getString(R.string.selectSector)
|
||||
)
|
||||
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.sectors))
|
||||
.setDescription(getString(R.string.Noexistessectores))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
if (it.list.size > 0) {
|
||||
val listSectores: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listSectores.add(it.description)
|
||||
}
|
||||
// modificar
|
||||
listSectores.sort()
|
||||
val array = arrayOfNulls<String>(listSectores.size)
|
||||
sectorListVO = it.list
|
||||
showDialogSector(listSectores.toArray(array))
|
||||
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.sectors))
|
||||
.setDescription(getString(R.string.Noexistessectores))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
loadItemPackingList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
if (it.list.isNotEmpty() && it.list.get(0).isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.list.get(0).errorMessage)
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
|
||||
if (it.list.isNotEmpty()) {
|
||||
val listItemsPacking: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listItemsPacking.add(it.description)
|
||||
}
|
||||
val array = arrayOfNulls<String>(listItemsPacking.size)
|
||||
itemPackingList = it.list
|
||||
showDialogForAll(
|
||||
listItemsPacking.toArray(array),
|
||||
getString(R.string.settingsTitleItemPacking)
|
||||
)
|
||||
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.settingsTitleItemPacking))
|
||||
.setDescription(getString(R.string.NoItemPackingType))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
if (it.list.size > 0) {
|
||||
val listItemsPacking: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listItemsPacking.add(it.description)
|
||||
}
|
||||
val array = arrayOfNulls<String>(listItemsPacking.size)
|
||||
itemPackingList = it.list
|
||||
showDialog(listItemsPacking.toArray(array))
|
||||
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.settingsTitleItemPacking))
|
||||
.setDescription(getString(R.string.NoItemPackingType))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
loadPrintersList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
if (it.list.isNotEmpty() && it.list.get(0).isError) {
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
if (it.list.isNotEmpty() && it.list[0].isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.list.get(0).errorMessage)
|
||||
.setDescription(it.list[0].errorMessage)
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
if (it.list.size > 0) {
|
||||
if (it.list.isNotEmpty()) {
|
||||
val listPrinters: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listPrinters.add(it.name)
|
||||
}
|
||||
val array = arrayOfNulls<String>(listPrinters.size)
|
||||
printersList = it.list
|
||||
showDialogPrinters(listPrinters.toArray(array))
|
||||
showDialogForAll(listPrinters.toArray(array), messagePrinter ?: "")
|
||||
|
||||
} else {
|
||||
viewModel.settingsItem[2].selected = getString(R.string.noprinter)
|
||||
settingsAdapter!!.notifyItemChanged(2)
|
||||
customDialog.setTitle(getString(R.string.printers))
|
||||
.setDescription(getString(R.string.Noprinters))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
|
@ -315,34 +224,21 @@ class AjustesFragment :
|
|||
}
|
||||
}
|
||||
loadTrainList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
|
||||
if (it.list.isNotEmpty() && it.list.get(0).isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.list.get(0).errorMessage)
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
if (it.list.size > 0) {
|
||||
val listTrain: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listTrain.add(it.name)
|
||||
}
|
||||
val array = arrayOfNulls<String>(listTrain.size)
|
||||
trainsList = it.list
|
||||
showDialogTrains(listTrain.toArray(array))
|
||||
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.printers))
|
||||
.setDescription(getString(R.string.Noprinters))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
if (it.list.isNotEmpty()) {
|
||||
val listTrain: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listTrain.add(it.name)
|
||||
}
|
||||
val array = arrayOfNulls<String>(listTrain.size)
|
||||
trainsList = it.list
|
||||
showDialogForAll(
|
||||
listTrain.toArray(array), getString(R.string.selectTrain)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -352,63 +248,26 @@ class AjustesFragment :
|
|||
private fun showMenuByDefault() {
|
||||
pasilleroViewModel = PasilleroViewModel(mobileApplication)
|
||||
pasilleroViewModel.inititializeDefaultDataInit()
|
||||
var arrayList: ArrayList<String> = arrayListOf()
|
||||
val arrayList: ArrayList<String> = arrayListOf()
|
||||
|
||||
pasilleroViewModel.pasillerositem.forEach {
|
||||
arrayList.add(it.title)
|
||||
}
|
||||
arrayList.add(getString(R.string.all))
|
||||
arrayList.sorted()
|
||||
val builder = AlertDialog.Builder(this.context)
|
||||
builder.setTitle(getString(R.string.menuByDefault))
|
||||
builder.setItems((arrayList).toTypedArray()) { _, which ->
|
||||
val selected = arrayList[which]
|
||||
arrayList.forEach {
|
||||
if (it == selected) {
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
MENUBYDEFAULTSELECTED, if (it != getString(R.string.all)) {
|
||||
it
|
||||
} else {
|
||||
""
|
||||
}
|
||||
)
|
||||
}
|
||||
viewModel.ajustesitem[6].selected = it
|
||||
ajustesAdapter!!.notifyDataSetChanged()
|
||||
|
||||
return@forEach
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.show()
|
||||
|
||||
showDialogForAll((arrayList).toTypedArray(), getString(R.string.menuByDefault))
|
||||
}
|
||||
|
||||
private fun setSettings(actionIsAllowed: Boolean = false) {
|
||||
|
||||
runBlocking {
|
||||
|
||||
println(
|
||||
"key FK ${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERFK) as Int
|
||||
}"
|
||||
)
|
||||
println(
|
||||
"key NAME ${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERNAME) as String
|
||||
}"
|
||||
)
|
||||
|
||||
viewModel.inititializeDefaultAjusts(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORDESCRIP),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK),
|
||||
(mobileApplication.dataStoreApp.readDataStoreKey(NUMBEROFWAGONS) as Int).toString(),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERFK),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME).toString(),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERNAME),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(TRAINNAME),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
||||
actionIsAllowed = actionIsAllowed,
|
||||
|
@ -421,140 +280,135 @@ class AjustesFragment :
|
|||
binding.splashProgress.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun showDialogPrinters(array: Array<String>) {
|
||||
private fun showDialogForAll(array: Array<String>, title: String) {
|
||||
val builder = AlertDialog.Builder(this.context)
|
||||
builder.setTitle(title)
|
||||
|
||||
builder.setTitle(messagePrinter)
|
||||
|
||||
// builder.setMessage("La impresora que tenía se ha eliminado ")
|
||||
builder.setItems(array) { _, which ->
|
||||
val selected = array[which]
|
||||
printersList.forEach {
|
||||
if (it.name.equals(selected)) {
|
||||
when (title) {
|
||||
getString(R.string.settingsTitleItemPacking) -> {
|
||||
itemPackingList.forEach {
|
||||
if (it.description == selected) {
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERNAME, it.name)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, it.id!!)
|
||||
}
|
||||
|
||||
viewModel.ajustesitem.get(2).selected = it.name
|
||||
viewModel.worker_updateOperatorSalix(
|
||||
entity = "printer",
|
||||
workerFk = mobileApplication.userId!!,
|
||||
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
labelerFk = it.id!!
|
||||
)
|
||||
ajustesAdapter!!.notifyDataSetChanged()
|
||||
ajustesAdapter
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showDialogTrains(array: Array<String>) {
|
||||
val builder = AlertDialog.Builder(this.context)
|
||||
|
||||
|
||||
builder.setTitle(getString(R.string.selectTrain))
|
||||
builder.setItems(array) { _, which ->
|
||||
val selected = array[which]
|
||||
trainsList.forEach {
|
||||
if (it.name.equals(selected)) {
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(TRAINNAME, it.name)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(TRAINFK, it.id)
|
||||
}
|
||||
|
||||
viewModel.ajustesitem[3].selected = it.name
|
||||
viewModel.operatorUpdateTrain(
|
||||
workerId = mobileApplication.userId!!, trainFk = it.id!!
|
||||
)
|
||||
ajustesAdapter!!.notifyDataSetChanged()
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showDialogSector(array: Array<String>) {
|
||||
val builder = AlertDialog.Builder(this.context)
|
||||
builder.setTitle(getString(R.string.Seleccionaunsector))
|
||||
builder.setItems(array) { _, which ->
|
||||
val selected = array[which]
|
||||
sectorListVO.forEach {
|
||||
if (it.description.equals(selected)) {
|
||||
|
||||
//borra la impresora
|
||||
viewModel.ajustesitem.get(2).selected = getString(R.string.noprinter)
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
PRINTERNAME, getString(R.string.noprinter)
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, -1)
|
||||
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
SECTORDESCRIP, it.description
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
SECTORFK, it.id
|
||||
)
|
||||
it.warehouseFk?.let { it1 ->
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
WAREHOUSEFK, it1
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ITEMPACKING, it.description
|
||||
)
|
||||
}
|
||||
viewModel.settingsItem[4].selected = it.description
|
||||
viewModel.operatorUpdate(
|
||||
workerId = mobileApplication.userId!!,
|
||||
hashMapOf("itemPackingTypeFk" to it.description)
|
||||
)
|
||||
settingsAdapter!!.notifyItemChanged(4)
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.ajustesitem.get(0).sectorFk = it.id
|
||||
viewModel.ajustesitem.get(0).warehouse = it.warehouseFk
|
||||
viewModel.ajustesitem.get(0).selected = it.description
|
||||
|
||||
viewModel.worker_updateOperatorSalix(
|
||||
"sector", mobileApplication.userId!!, it.id, null
|
||||
)
|
||||
|
||||
ajustesAdapter!!.notifyDataSetChanged()
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.show()
|
||||
}
|
||||
getString(R.string.selectSector) -> {
|
||||
sectorListVO.forEach {
|
||||
if (it.description == selected) {
|
||||
|
||||
private fun showDialog(array: Array<String>) {
|
||||
val builder = AlertDialog.Builder(this.context)
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
PRINTERNAME, getString(R.string.noprinter)
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, -1)
|
||||
|
||||
builder.setTitle(getString(R.string.settingsTitleItemPacking))
|
||||
builder.setItems(array) { _, which ->
|
||||
val selected = array[which]
|
||||
itemPackingList.forEach {
|
||||
if (it.description.equals(selected)) {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
SECTORDESCRIP, it.description
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
SECTORFK, it.id
|
||||
)
|
||||
it.warehouseFk?.let { it1 ->
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
WAREHOUSEFK, it1
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ITEMPACKING, it.description
|
||||
)
|
||||
viewModel.settingsItem[0].sectorFk = it.id
|
||||
viewModel.settingsItem[0].selected = it.description
|
||||
viewModel.workerUpdateOperatorSalix(
|
||||
"sector", mobileApplication.userId!!, it.id, null
|
||||
)
|
||||
|
||||
settingsAdapter!!.notifyItemChanged(0)
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
viewModel.ajustesitem[4].selected = it.description
|
||||
viewModel.operator_updateItemPackingType(
|
||||
it.code
|
||||
)
|
||||
ajustesAdapter!!.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
return@forEach
|
||||
getString(R.string.selectTrain) -> {
|
||||
trainsList.forEach {
|
||||
if (it.name == selected) {
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(TRAINNAME, it.name)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(TRAINFK, it.id)
|
||||
}
|
||||
|
||||
viewModel.settingsItem[3].selected = it.name
|
||||
viewModel.operatorUpdate(
|
||||
workerId = mobileApplication.userId!!,
|
||||
hashMapOf("trainFk" to it.id.toString())
|
||||
)
|
||||
settingsAdapter!!.notifyItemChanged(3)
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getString(R.string.menuByDefault) -> {
|
||||
array.forEach {
|
||||
if (it == selected) {
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
MENUBYDEFAULTSELECTED, if (it != getString(R.string.all)) {
|
||||
it
|
||||
} else {
|
||||
""
|
||||
}
|
||||
)
|
||||
}
|
||||
viewModel.settingsItem[6].selected = it
|
||||
settingsAdapter!!.notifyItemChanged(6)
|
||||
|
||||
return@forEach
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
printersList.forEach {
|
||||
if (it.name == selected) {
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
PRINTERNAME, it.name
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, it.id)
|
||||
}
|
||||
|
||||
viewModel.settingsItem[2].selected = it.name
|
||||
viewModel.workerUpdateOperatorSalix(
|
||||
entity = "printer",
|
||||
workerFk = mobileApplication.userId!!,
|
||||
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
labelerFk = it.id
|
||||
)
|
||||
settingsAdapter!!.notifyItemChanged(2)
|
||||
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,13 +417,4 @@ class AjustesFragment :
|
|||
dialog.show()
|
||||
}
|
||||
|
||||
private fun copyanddrag(string: String): Boolean {
|
||||
val clipboard = getActivity()?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip: ClipData = ClipData.newPlainText(getString(R.string.androidid), string)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
setTooltipText(binding.androididText, getString(R.string.copied))
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import es.verdnatura.presentation.base.BaseViewModel
|
|||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ResponseItemNumber
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
|
||||
|
@ -28,9 +27,9 @@ import retrofit2.Response
|
|||
|
||||
class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _ajustesitem by lazy { ArrayList<AjustesItemVO>() }
|
||||
val ajustesitem: List<AjustesItemVO>
|
||||
get() = _ajustesitem
|
||||
private val _settingsItem by lazy { ArrayList<AjustesItemVO>() }
|
||||
val settingsItem: List<AjustesItemVO>
|
||||
get() = _settingsItem
|
||||
|
||||
private val _sectorList by lazy { MutableLiveData<SectorListVO>() }
|
||||
val sectorList: LiveData<SectorListVO>
|
||||
|
@ -40,30 +39,10 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val actionUpdate: LiveData<ResponseItemVO>
|
||||
get() = _actionUpdate
|
||||
|
||||
private val _actionUpdateTrain by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val actionUpdateTrain: LiveData<ResponseItemVO>
|
||||
get() = _actionUpdateTrain
|
||||
|
||||
private val _actionUpdatePacking by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val actionUpdatePacking: LiveData<ResponseItemVO>
|
||||
get() = _actionUpdatePacking
|
||||
|
||||
private val _actionUpdatePackingTicket by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val actionUpdatePackingTicket: LiveData<ResponseItemVO>
|
||||
get() = _actionUpdatePackingTicket
|
||||
|
||||
private val _printerList by lazy { MutableLiveData<PrintersList>() }
|
||||
val printerList: LiveData<PrintersList>
|
||||
get() = _printerList
|
||||
|
||||
private val _operatorGetNumberOfWagons by lazy { MutableLiveData<ResponseItemNumber>() }
|
||||
val operatorGetNumberOfWagons: LiveData<ResponseItemNumber>
|
||||
get() = _operatorGetNumberOfWagons
|
||||
|
||||
private val _operatorGetTrainResponse by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val operatorGetTrainResponse: LiveData<ResponseItemVO>
|
||||
get() = _operatorGetTrainResponse
|
||||
|
||||
private val _workerAllowedResponse by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val workerAllowedResponse: LiveData<ResponseItemVO>
|
||||
get() = _workerAllowedResponse
|
||||
|
@ -76,26 +55,17 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val trainList: LiveData<TrainList>
|
||||
get() = _trainList
|
||||
|
||||
//val loadSectorList = Transformations.map(_sectorList) { Event(it) }
|
||||
val loadActionUpdate: LiveData<Event<ResponseItemVO>> = _actionUpdate.map { Event(it) }
|
||||
val loadSectorList: LiveData<Event<SectorListVO>> = _sectorList.map { Event(it) }
|
||||
|
||||
//val loadPrintersList = Transformations.map(_printerList) { Event(it) }
|
||||
val loadPrintersList: LiveData<Event<PrintersList>> = _printerList.map { Event(it) }
|
||||
|
||||
//val loadItemPackingList = Transformations.map(_itemspackinglist) { Event(it) }
|
||||
val loadItemPackingList: LiveData<Event<ItemPackingTypeList>> = _itemspackinglist.map { Event(it) }
|
||||
|
||||
//val loadTrainList = Transformations.map(_trainList) { Event(it) }
|
||||
val loadItemPackingList: LiveData<Event<ItemPackingTypeList>> =
|
||||
_itemspackinglist.map { Event(it) }
|
||||
val loadTrainList: LiveData<Event<TrainList>> = _trainList.map { Event(it) }
|
||||
|
||||
//val loadUpdatePacking = Transformations.map(_actionUpdatePackingTicket) { Event(it) }
|
||||
val loadUpdatePacking: LiveData<Event<ResponseItemVO>> = _actionUpdatePackingTicket.map { Event(it) }
|
||||
|
||||
fun inititializeDefaultAjusts(
|
||||
sectorDescrip: String,
|
||||
sectorFk: Int,
|
||||
warehouseFk: Int,
|
||||
carroDescrip: String,
|
||||
wagoonDescrip: String,
|
||||
printerFk: Int,
|
||||
printerSelected: String,
|
||||
train: String?,
|
||||
|
@ -103,109 +73,80 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
actionIsAllowed: Boolean,
|
||||
menuDefault: String
|
||||
) {
|
||||
_ajustesitem.clear()
|
||||
_ajustesitem.add(
|
||||
_settingsItem.clear()
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
0,
|
||||
context.getString(R.string.sector),
|
||||
sectorDescrip,
|
||||
sectorFk,
|
||||
warehouseFk,
|
||||
0,
|
||||
printerSelected,
|
||||
true
|
||||
action = true
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
1,
|
||||
context.getString(R.string.wagoons),
|
||||
carroDescrip,
|
||||
0,
|
||||
0,
|
||||
0, context.getString(R.string.printerWithout),
|
||||
false
|
||||
wagoonDescrip,
|
||||
action = false
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
2,
|
||||
context.getString(R.string.printerLabel),
|
||||
printerSelected,
|
||||
0,
|
||||
0,
|
||||
printerFk,
|
||||
printerSelected,
|
||||
true
|
||||
printerFk = printerFk,
|
||||
printerSelected = printerSelected,
|
||||
action = true
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
6,
|
||||
context.getString(R.string.settingsTitleTrain),
|
||||
train,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
action = actionIsAllowed
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
7,
|
||||
context.getString(R.string.settingsTitleItemPacking),
|
||||
itemPackingType,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
action = actionIsAllowed
|
||||
)
|
||||
)
|
||||
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
4,
|
||||
context.getString(R.string.vehicleControl),
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0, context.getString(R.string.printerWithout),
|
||||
true
|
||||
action = true
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
9,
|
||||
context.getString(R.string.menuByDefault),
|
||||
selected = menuDefault,
|
||||
0,
|
||||
0,
|
||||
0, "",
|
||||
true
|
||||
action = true
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
AjustesItemVO(
|
||||
9,
|
||||
"Iniciar parada",
|
||||
selected = "",
|
||||
0,
|
||||
0,
|
||||
0, "",
|
||||
false
|
||||
)
|
||||
)
|
||||
_ajustesitem.add(
|
||||
/* _ajustesitem.add(
|
||||
AjustesItemVO(
|
||||
9,
|
||||
"Iniciar parada",
|
||||
action = false
|
||||
)
|
||||
)*/
|
||||
_settingsItem.add(
|
||||
AjustesItemVO(
|
||||
5,
|
||||
context.getString(R.string.closeSession),
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0, context.getString(R.string.printerWithout),
|
||||
true
|
||||
action = true
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -214,36 +155,9 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
fun getItemPackingTypeSalix() {
|
||||
salix.get_ItemPackingType().enqueue(object :
|
||||
SalixCallback<List<ItemPackingType>>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
val listError: ArrayList<ItemPackingType> = ArrayList()
|
||||
listError.add(
|
||||
ItemPackingType(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
)
|
||||
_itemspackinglist.value = ItemPackingTypeList(listError)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<List<ItemPackingType>>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
_itemspackinglist.value = response.body()?.let { ItemPackingTypeList(it) }
|
||||
|
||||
} else {
|
||||
val listError: ArrayList<ItemPackingType> = ArrayList()
|
||||
listError.add(
|
||||
ItemPackingType(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this),
|
||||
response.message()
|
||||
)
|
||||
)
|
||||
)
|
||||
_itemspackinglist.value = ItemPackingTypeList(listError)
|
||||
}
|
||||
_itemspackinglist.value = response.body()?.let { ItemPackingTypeList(it) }
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -251,51 +165,21 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
fun getSectorsSalix() {
|
||||
salix.getSectors("""{"fields":["id","description","warehouseFk"],"order":"description"}""")
|
||||
// salix.getSectorsSalix()
|
||||
.enqueue(object : SalixCallback<List<SectorItemVO>>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
.enqueue(object : SalixCallback<List<SectorItemVO>>(context) {
|
||||
|
||||
val listError: ArrayList<SectorItemVO> = ArrayList()
|
||||
listError.add(SectorItemVO(0, "", 0, true, t.message!!))
|
||||
_sectorList.value = SectorListVO(listError)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<List<SectorItemVO>>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
override fun onSuccess(response: Response<List<SectorItemVO>>) {
|
||||
_sectorList.value = response.body()?.let { SectorListVO(it) }
|
||||
} else {
|
||||
val listError: ArrayList<SectorItemVO> = ArrayList()
|
||||
listError.add(
|
||||
SectorItemVO(
|
||||
0, "", 0, true,
|
||||
getMessageFromAllResponse(nameofFunction(this), response.message())
|
||||
)
|
||||
)
|
||||
_sectorList.value = SectorListVO(listError)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fun printer_get() {
|
||||
fun printerGet() {
|
||||
//Tarea 6276
|
||||
//salix.getprinters().enqueue(object : SalixCallback<List<Printers>>(context) {
|
||||
silex.printer_get().enqueue(object : SalixCallback<List<Printers>>(context) {
|
||||
override fun onSuccess(response: Response<List<Printers>>) {
|
||||
if (response.body() != null) {
|
||||
_printerList.value = response.body()?.let { PrintersList(it) }
|
||||
} else {
|
||||
val listError: ArrayList<Printers> = ArrayList()
|
||||
listError.add(
|
||||
Printers(
|
||||
0, "", true,
|
||||
getMessageFromAllResponse(nameofFunction(this), response.message())
|
||||
)
|
||||
)
|
||||
_printerList.value = PrintersList(listError)
|
||||
}
|
||||
_printerList.value = response.body()?.let { PrintersList(it) }
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
|
@ -308,48 +192,16 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun train_get() {
|
||||
fun trainGet() {
|
||||
salix.getTrain().enqueue(object : SalixCallback<List<Train>>(context) {
|
||||
override fun onSuccess(response: Response<List<Train>>) {
|
||||
_trainList.value = response.body()?.let { TrainList(it) }
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
val listError: ArrayList<Train> = ArrayList()
|
||||
listError.add(Train(0, "", true, t.message!!))
|
||||
_trainList.value = TrainList(listError)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun operator_updateItemPackingType(itemPackingTypeFk: String) {
|
||||
|
||||
silex.operator_updateItemPackingType(itemPackingTypeFk)
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
_actionUpdatePacking.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<Unit>) {
|
||||
|
||||
_actionUpdatePacking.value = ResponseItemVO(
|
||||
response = response.message(),
|
||||
isError = false,
|
||||
errorMessage = ""
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun worker_isF11Allowed() {
|
||||
fun workerIsF11Allowed() {
|
||||
salix.worker_isF11Allowed("""{"where":{"id":${(context as MobileApplication).userId}},"fields":{"isF11Allowed":true}}""")
|
||||
.enqueue(object : SalixCallback<JsonObject>(context) {
|
||||
override fun onSuccess(response: Response<JsonObject>) {
|
||||
|
@ -362,7 +214,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun worker_updateOperatorSalix(entity: String, workerFk: Int, sectorFk: Int?, labelerFk: Int?) {
|
||||
fun workerUpdateOperatorSalix(entity: String, workerFk: Int, sectorFk: Int?, labelerFk: Int?) {
|
||||
salix.update_operator(id = workerFk, Operator(sectorFk, labelerFk))
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
@ -389,19 +241,12 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun operatorUpdateTrain(workerId: Int, trainFk: Int) {
|
||||
fun operatorUpdate(workerId: Int, update: HashMap<String, String>) {
|
||||
|
||||
salix.update_operator(id = workerId, params = hashMapOf("trainFk" to trainFk))
|
||||
salix.update_operator(id = workerId, params = update)
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
override fun onSuccess(response: Response<Unit>) {
|
||||
super.onSuccess(response)
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
throw t
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package es.verdnatura.presentation.view.feature.ajustes.model
|
|||
class AjustesItemVO(
|
||||
var id: Int,
|
||||
var title: String = "",
|
||||
var selected: String? = "",
|
||||
var sectorFk: Int?,
|
||||
var warehouse: Int?,
|
||||
var printerFk: Int?,
|
||||
var printerSelected: String = "",
|
||||
var selected: String? = null,
|
||||
var sectorFk: Int? = null,
|
||||
var printerFk: Int? = null,
|
||||
var printerSelected: String? = null,
|
||||
var action: Boolean
|
||||
)
|
||||
|
||||
|
|
|
@ -1,46 +1,38 @@
|
|||
<?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"
|
||||
>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/verdnatura_black">
|
||||
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/verdnatura_white"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/main_toolbar"/>
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="@+id/main_toolbar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/pasilleros_margin_main_menu"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/navigation_row_min_padding"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/divider"
|
||||
android:layout_marginStart="@dimen/pasilleros_margin_main_menu"
|
||||
android:padding="@dimen/navigation_row_min_padding"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
|
||||
app:layout_constraintTop_toBottomOf="@id/divider">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="120dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"
|
||||
android:text="@string/Versión"
|
||||
|
@ -52,10 +44,10 @@
|
|||
android:id="@+id/item_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/layout_margin_3"
|
||||
android:text=""
|
||||
android:layout_marginStart="@dimen/layout_margin_4"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"/>
|
||||
android:textSize="@dimen/body1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -65,55 +57,57 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="120dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"
|
||||
android:text="@string/Usuario"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/layout_margin_3"
|
||||
android:text=""
|
||||
android:layout_marginStart="@dimen/layout_margin_4"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"/>
|
||||
android:textSize="@dimen/body1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="120dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"
|
||||
android:text="@string/Androidid"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/androidid_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/layout_margin_3"
|
||||
android:text=""
|
||||
android:layout_marginStart="@dimen/layout_margin_4"
|
||||
android:tooltipText="@string/copied"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"/>
|
||||
android:textSize="@dimen/body1"
|
||||
android:tooltipText="@string/copied" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/serial_text"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"
|
||||
android:text="@string/serialNumber"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
|
@ -124,47 +118,11 @@
|
|||
android:id="@+id/serial_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/layout_margin_3"
|
||||
android:text=""
|
||||
android:layout_marginStart="@dimen/layout_margin_4"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"/>
|
||||
android:textSize="@dimen/body1" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginEnd="@dimen/default_layout_margin"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtserver"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/verdnatura_white"
|
||||
android:padding="5dp"
|
||||
android:ems="10"
|
||||
android:inputType="text"
|
||||
android:hint="@string/server"
|
||||
android:autofillHints="name"
|
||||
android:layout_marginTop="4dp"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -187,17 +145,16 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/splash_progress"
|
||||
android:visibility="visible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/verdnatura_black_8_alpha_6"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:gravity="center">
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
|
||||
|
|
Loading…
Reference in New Issue