feat isScanned #refs 7276
This commit is contained in:
parent
c34a52bde1
commit
c4258e9056
|
@ -1,6 +1,7 @@
|
||||||
package es.verdnatura.presentation.view.feature.delivery.fragments
|
package es.verdnatura.presentation.view.feature.delivery.fragments
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
@ -28,30 +29,13 @@ class LogExpeditionFragment(
|
||||||
|
|
||||||
private var adapter: ExpeditionLogAdapter? = null
|
private var adapter: ExpeditionLogAdapter? = null
|
||||||
private var originalItem: Int = 0
|
private var originalItem: Int = 0
|
||||||
|
private var isScanned: Boolean = false
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(title: String) = LogExpeditionFragment(title)
|
fun newInstance(title: String) = LogExpeditionFragment(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_expedition_log_delivery
|
override fun getLayoutId(): Int = R.layout.fragment_expedition_log_delivery
|
||||||
/*override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(
|
|
||||||
viewLifecycleOwner,
|
|
||||||
object : OnBackPressedCallback(true) {
|
|
||||||
override fun handleOnBackPressed() {
|
|
||||||
*//* if (!onBackListenerPressed()) {
|
|
||||||
isEnabled = true
|
|
||||||
requireActivity().onBackPressedDispatcher
|
|
||||||
} else {*//*
|
|
||||||
ma.onMyBackPressed()
|
|
||||||
//println("backk LogExpeditionFragment")
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
|
|
||||||
|
@ -98,10 +82,11 @@ class LogExpeditionFragment(
|
||||||
ma.onMyBackPressed()
|
ma.onMyBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
|
binding.scanInput.setOnEditorActionListener { _, actionId, event ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == EditorInfo.IME_ACTION_NEXT) {
|
||||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||||
|
isScanned =
|
||||||
|
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||||
try {
|
try {
|
||||||
viewModel.expeditionGetLog(binding.scanInput.toInt())
|
viewModel.expeditionGetLog(binding.scanInput.toInt())
|
||||||
originalItem = binding.scanInput.toInt()
|
originalItem = binding.scanInput.toInt()
|
||||||
|
@ -116,10 +101,11 @@ class LogExpeditionFragment(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener false
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun observeViewModel() {
|
override fun observeViewModel() {
|
||||||
|
@ -128,7 +114,6 @@ class LogExpeditionFragment(
|
||||||
|
|
||||||
createList(it.list)
|
createList(it.list)
|
||||||
setSwitchButon()
|
setSwitchButon()
|
||||||
setSwitchButon()
|
|
||||||
viewModel.getRoutesFromExpedition(originalItem)
|
viewModel.getRoutesFromExpedition(originalItem)
|
||||||
}
|
}
|
||||||
routeInfoList.observe(viewLifecycleOwner) {
|
routeInfoList.observe(viewLifecycleOwner) {
|
||||||
|
@ -143,6 +128,7 @@ class LogExpeditionFragment(
|
||||||
binding.mainToolbar.toolbarIcons.visibility = View.GONE
|
binding.mainToolbar.toolbarIcons.visibility = View.GONE
|
||||||
binding.mainToolbar.switchButton.visibility = View.GONE
|
binding.mainToolbar.switchButton.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
binding.scanInput.requestFocus()
|
||||||
}
|
}
|
||||||
responseStateAdd.observe(viewLifecycleOwner) {
|
responseStateAdd.observe(viewLifecycleOwner) {
|
||||||
viewModel.expeditionGetLog(originalItem)
|
viewModel.expeditionGetLog(originalItem)
|
||||||
|
@ -160,7 +146,11 @@ class LogExpeditionFragment(
|
||||||
viewModel.expeditionStateAddSalix(
|
viewModel.expeditionStateAddSalix(
|
||||||
Expeditions(
|
Expeditions(
|
||||||
listOf(
|
listOf(
|
||||||
ExpeditionSalix(expeditionFk = originalItem, stateCode = "FOUND")
|
ExpeditionSalix(
|
||||||
|
expeditionFk = originalItem,
|
||||||
|
stateCode = "FOUND",
|
||||||
|
isScanned = if (isScanned) 1 else 0
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -168,7 +158,11 @@ class LogExpeditionFragment(
|
||||||
viewModel.expeditionStateAddSalix(
|
viewModel.expeditionStateAddSalix(
|
||||||
Expeditions(
|
Expeditions(
|
||||||
listOf(
|
listOf(
|
||||||
ExpeditionSalix(expeditionFk = originalItem, stateCode = "LOST")
|
ExpeditionSalix(
|
||||||
|
expeditionFk = originalItem,
|
||||||
|
stateCode = "LOST",
|
||||||
|
isScanned = if (isScanned) 1 else 0
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue