feat: refs#8639 scanSpeed
This commit is contained in:
parent
009c221de3
commit
fbd7a8d95c
|
@ -4,7 +4,8 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
|
@ -16,6 +17,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentExpeditionLoadunloadDeliveryBinding
|
||||
import es.verdnatura.db.DeliveryDatabase
|
||||
import es.verdnatura.domain.ConstAndValues.HUMAN_CHARACTERS_SECOND
|
||||
import es.verdnatura.domain.ConstAndValues.SCANNER_THRESHOLD_SPEED
|
||||
import es.verdnatura.domain.toDateString
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
|
@ -44,9 +47,10 @@ class LoadUnloadFragment(
|
|||
private var title: String = "",
|
||||
private var state: String = "",
|
||||
private var entryPoint: String,
|
||||
private var clientTicketList: ArrayList<ClientTicketSalix>?
|
||||
private var clientTicketList: ArrayList<ClientTicketSalix>?,
|
||||
private var startInputTime: Long = 0L,
|
||||
|
||||
) : BaseFragment<FragmentExpeditionLoadunloadDeliveryBinding, DeliveryViewModel>(
|
||||
) : BaseFragment<FragmentExpeditionLoadunloadDeliveryBinding, DeliveryViewModel>(
|
||||
DeliveryViewModel::class
|
||||
), OnBackPressedListener {
|
||||
|
||||
|
@ -85,6 +89,24 @@ class LoadUnloadFragment(
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
binding.scanInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (before == 0 && count > 0) {
|
||||
startInputTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_expedition_loadunload_delivery
|
||||
|
@ -277,8 +299,12 @@ class LoadUnloadFragment(
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == EditorInfo.IME_ACTION_NEXT) {
|
||||
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
val totalTime = (System.currentTimeMillis() - startInputTime)
|
||||
val charsPerSecond = (binding.scanInput.text!!.length * 1000.0) / totalTime
|
||||
val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
charsPerSecond > HUMAN_CHARACTERS_SECOND && totalTime < SCANNER_THRESHOLD_SPEED
|
||||
|
||||
//Tarea 8152
|
||||
// showconfirmExpedition(binding.scanInput.text.toString().toInt(), isScanned)
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package es.verdnatura.presentation.view.feature.delivery.fragments
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.KeyEvent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
|
@ -11,6 +13,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.google.gson.Gson
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentExpeditionSummaryBinding
|
||||
import es.verdnatura.domain.ConstAndValues.HUMAN_CHARACTERS_SECOND
|
||||
import es.verdnatura.domain.ConstAndValues.SCANNER_THRESHOLD_SPEED
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.AdapterCallback
|
||||
|
@ -44,6 +48,7 @@ class SummaryFragment(
|
|||
private var routeSelected = 0
|
||||
private var isScanning = false
|
||||
private var positionSelected = -1
|
||||
private var startInputTime: Long = 0L
|
||||
|
||||
override fun getPosition(): Int {
|
||||
return positionSelected
|
||||
|
@ -67,6 +72,26 @@ class SummaryFragment(
|
|||
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.scanInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (before == 0 && count > 0) {
|
||||
startInputTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
if (binding.mainToolbar.toolbarTitle.text != getString(R.string.titleDeliverySummary)) {
|
||||
binding.scanInput.isEnabled = true
|
||||
|
@ -200,8 +225,12 @@ class SummaryFragment(
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
isScanning = true
|
||||
/* val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER*/
|
||||
val totalTime = (System.currentTimeMillis() - startInputTime)
|
||||
val charsPerSecond = (binding.scanInput.text!!.length * 1000.0) / totalTime
|
||||
val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
charsPerSecond > HUMAN_CHARACTERS_SECOND && totalTime < SCANNER_THRESHOLD_SPEED
|
||||
try {
|
||||
markExpedition(
|
||||
binding.scanInput.text.toString().toInt(),
|
||||
|
|
Loading…
Reference in New Issue