This commit is contained in:
Sergio De la torre 2023-04-27 08:09:24 +02:00
parent 76f8fdc8b8
commit e000ca66bc
5 changed files with 157 additions and 1 deletions

View File

@ -0,0 +1,141 @@
package es.verdnatura.presentation.view.feature.category
import android.view.View
import android.view.inputmethod.EditorInfo
import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.packingHolland.fragment.PackingHollandViewModel
//Tarea #4940
class ChangeCategoryFragment(var entrypoint: String) :
BaseFragment<FragmentGeneralBlackBinding, PackingHollandViewModel>(
PackingHollandViewModel::class
) {
override fun getLayoutId(): Int = R.layout.fragment_general_black
private var shelvingScaned: Int = 0
private lateinit var customDialogInput: CustomDialogInput
companion object {
fun newInstance(entrypoint: String) = ChangeCategoryFragment(entrypoint = entrypoint)
}
override fun init() {
customDialogInput = CustomDialogInput(requireContext())
binding.mainToolbar.toolbarTitle.text = entrypoint
binding.splashProgress.visibility = View.GONE
binding.scanInput.visibility = View.VISIBLE
setEvents()
super.init()
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
binding.scanInput.requestFocus()
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.scanInput.text.isNullOrEmpty()) {
try {
binding.scanInput.setText(
itemScanValue(
binding.scanInput.text.toString(),
"buy",
"more"
).toString()
)
shelvingScaned = binding.scanInput.text.toString().toInt()
showQuantityPacking()
} catch (ex: Exception) {
ex.message!!.toast(requireActivity())
}
}
binding.scanInput.setText("")
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
}
}
override fun observeViewModel() {
with(viewModel) {
response.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false)
} else {
showQuantityPacking()
}
}
}
}
private fun showQuantityPacking() {
customDialogInput.setTitle(getString(R.string.titleChangeCategory))
customDialogInput.setDescription(getString(R.string.ubication) + shelvingScaned)
.setValue("")
.setOkButton(getString(R.string.modify)) {
if (customDialogInput.getValue().isNotEmpty()
) {
callPacking(customDialogInput.getValue())
}
}.setKoButton(getString(R.string.cancel)) {
customDialogInput.dismiss()
}.show()
//ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
if (customDialogInput.getValue().isNotEmpty()) {
callPacking(customDialogInput.getValue())
}
return@setOnEditorActionListener true
}
false
}
customDialogInput.setFocusText()
}
private fun callPacking(value: String) {
try {
binding.splashProgress.visibility = View.VISIBLE
viewModel.travel_updatePacking(
itemFk = shelvingScaned,
packingFk = value.toInt()
)
} catch (ex: Exception) {
getString(R.string.errorInput).toast(requireActivity())
}
customDialogInput.setValue("")
}
}

View File

@ -0,0 +1,9 @@
<!-- drawable/category.xml -->
<vector android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
android:height="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#F7931E" android:pathData="M6.5 5C5.67 5 5 5.67 5 6.5S5.67 8 6.5 8 8 7.33 8 6.5 7.33 5 6.5 5M6.5 5C5.67 5 5 5.67 5 6.5S5.67 8 6.5 8 8 7.33 8 6.5 7.33 5 6.5 5M21.41 11.58L12.41 2.58C12.04 2.21 11.53 2 11 2H4C2.9 2 2 2.9 2 4V11C2 11.53 2.21 12.04 2.59 12.42L3 12.82C3.64 12.44 4.35 12.19 5.08 12.08L4 11V4H11L20 13L13 20L11.92 18.92C11.82 19.66 11.56 20.36 11.18 21L11.59 21.41C11.96 21.79 12.47 22 13 22C13.53 22 14.04 21.79 14.41 21.41L21.41 14.41C21.79 14.04 22 13.53 22 13C22 12.47 21.79 11.96 21.41 11.58M6.5 5C5.67 5 5 5.67 5 6.5S5.67 8 6.5 8 8 7.33 8 6.5 7.33 5 6.5 5M8 18V14H6V18H4L7 21L10 18H8Z" />
</vector>

View File

@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFF" android:pathData="M2,10.96C1.5,10.68 1.35,10.07 1.63,9.59L3.13,7C3.24,6.8 3.41,6.66 3.6,6.58L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.66,6.72 20.82,6.88 20.91,7.08L22.36,9.6C22.64,10.08 22.47,10.69 22,10.96L21,11.54V16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V10.96C2.7,11.13 2.32,11.14 2,10.96M12,4.15V4.15L12,10.85V10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V12.69L14,15.59C13.67,15.77 13.3,15.76 13,15.6V19.29L19,15.91M13.85,13.36L20.13,9.73L19.55,8.72L13.27,12.35L13.85,13.36Z" />
<path android:fillColor="#F7931E" android:pathData="M2,10.96C1.5,10.68 1.35,10.07 1.63,9.59L3.13,7C3.24,6.8 3.41,6.66 3.6,6.58L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.66,6.72 20.82,6.88 20.91,7.08L22.36,9.6C22.64,10.08 22.47,10.69 22,10.96L21,11.54V16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V10.96C2.7,11.13 2.32,11.14 2,10.96M12,4.15V4.15L12,10.85V10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V12.69L14,15.59C13.67,15.77 13.3,15.76 13,15.6V19.29L19,15.91M13.85,13.36L20.13,9.73L19.55,8.72L13.27,12.35L13.85,13.36Z" />
</vector>

View File

@ -556,5 +556,8 @@
<string name="managerWagon">El número de carros ahora solo se puede modificar por los encargados</string>
<string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string>
<string name="quantityTake">Indica la cantidad que coges</string>
<string name="categoryChange">Cambiar a A2</string>
<string name="titleChangeCategory">Cambiar a A2</string>
<string name="ubication">Indica el carro donde está ubicado el item:</string>
</resources>

View File

@ -396,6 +396,7 @@
<string name="titleUbicator">Ubicator</string>
<string name="titlePackingHolland">Packing Holanda</string>
<string name="titleSelfConsumption">Self-autoconsumption</string>
<string name="titleChangeCategory">Change to A2</string>
<string name="titleSelfDescription">Self-autoconsumption from your warehouse</string>
<string name="titleReUbicator">Reubication</string>
<string name="titleAuto">Add Automatically items to shelving</string>
@ -550,10 +551,12 @@
<string name="errorQuantity">Insert the amount correctly</string>
<string name="operationSuccessful">Operación realizada correctamente</string>
<string name="selfConsumption">Self-consumption</string>
<string name="categoryChange">Change to A2</string>
<string name="adress">Address</string>
<string name="modify">Modify</string>
<string name="problemUpdate">It\'s not possible to update. Problem with the download of app</string>
<string name="packingQuantity">"Introduce new packing for the item : "</string>
<string name="ubication">"Introduce ubication for the item : "</string>
<string name="managerWagon">The number of wagons can now only be changed by managers</string>
</resources>