feat onBack #refs 6530
This commit is contained in:
parent
fcf91a18d8
commit
915aad5a32
|
@ -3,10 +3,13 @@ package es.verdnatura.presentation.view.feature.delivery.fragments
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -69,22 +72,20 @@ class LoadUnloadFragment(
|
|||
}
|
||||
}
|
||||
|
||||
/* override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
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 {*//*
|
||||
println("backk UnLoadLoadFragment")
|
||||
// }
|
||||
if (!onBackPressedHandled()) {
|
||||
isEnabled = false
|
||||
requireActivity().onBackPressedDispatcher
|
||||
}
|
||||
}
|
||||
})
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_expedition_loadunload_delivery
|
||||
|
||||
|
@ -185,7 +186,7 @@ class LoadUnloadFragment(
|
|||
"LOST"
|
||||
} else {
|
||||
l.code
|
||||
}
|
||||
}, isScanned = l.isScanned
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -244,11 +245,12 @@ class LoadUnloadFragment(
|
|||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
|
||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == EditorInfo.IME_ACTION_NEXT) {
|
||||
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
try {
|
||||
markExpedition(
|
||||
binding.scanInput.text.toString().toInt(),
|
||||
|
@ -257,8 +259,8 @@ class LoadUnloadFragment(
|
|||
} else {
|
||||
"FOUND"
|
||||
},
|
||||
|
||||
)
|
||||
isScanned = if (isScanned) 1 else 0
|
||||
)
|
||||
if (state != "DELIVERED") {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
|
@ -283,7 +285,7 @@ class LoadUnloadFragment(
|
|||
binding.scanInput.requestFocus()
|
||||
}
|
||||
|
||||
private fun markExpedition(expedNumber: Int, state: String) {
|
||||
private fun markExpedition(expedNumber: Int, state: String, isScanned: Int) {
|
||||
|
||||
var found = false
|
||||
|
||||
|
@ -294,6 +296,7 @@ class LoadUnloadFragment(
|
|||
if (exped.id == expedNumber) {
|
||||
found = true
|
||||
exped.code = state
|
||||
exped.isScanned = isScanned
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +317,7 @@ class LoadUnloadFragment(
|
|||
counterCalls = 1
|
||||
val pendingExpeditionSend = myList.map { l ->
|
||||
ExpeditionSalix(
|
||||
expeditionFk = l.id, stateCode = l.code
|
||||
expeditionFk = l.id, stateCode = l.code, isScanned = l.isScanned
|
||||
)
|
||||
}
|
||||
viewModel.expeditionStateAddSalix(hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == state }))
|
||||
|
@ -527,6 +530,6 @@ class LoadUnloadFragment(
|
|||
} else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -28,15 +28,20 @@
|
|||
android:text="@string/itemData"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/bodyPicker"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scan_input"/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/scan_input"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/itemDetails"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="40dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
Loading…
Reference in New Issue