refs #5135 feat: refactor animation

This commit is contained in:
Sergio De la torre 2024-01-10 09:39:33 +01:00
parent 11fc8ce52e
commit a5953a22f5
3 changed files with 32 additions and 63 deletions

View File

@ -229,7 +229,7 @@ interface SalixService {
fun expeditionLoadingAdd(
@Query("params") params: Any? = null,
@Query("schema") schema: String = "vn"
): Call<Any>
): Call<List<Map<String, Any>>>
@POST("Applications/expeditionState_addByPallet/execute-proc")
fun expeditionStateAddByPallet(

View File

@ -51,21 +51,16 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) {
}
fun expeditionLoadingAdd(vExpeditionFk: Int, vBufferFk: Int) {
salix.expeditionLoadingAdd(arrayListOf(vExpeditionFk, vBufferFk))
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_bufferloadresponse.value = ResponseItemVO(
isError = false,
response = response.body().toString()!!
)
salix.expeditionLoadingAdd(arrayListOf(vExpeditionFk, vBufferFk), schema = "srt")
.enqueue(object : SalixCallback<List<Map<String, Any>>>(context) {
override fun onSuccess(response: Response<List<Map<String, Any>>>) {
_bufferloadresponse.value =
ResponseItemVO(
isError = false,
response = response.body()!![0]["vMessage"].toString()
)
}
override fun onError(t: Throwable) {
_bufferloadresponse.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
})
}
}

View File

@ -1,15 +1,12 @@
package es.verdnatura.presentation.view.feature.buffer.fragment
import android.media.MediaPlayer
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentBufferLoadexpeditionBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnSmartTagRowClickListener
import es.verdnatura.presentation.view.component.CustomDialogList
@ -30,27 +27,19 @@ class BufferLoadFragment(
private var tagsAdapter: BufferAdapter? = null
private var itemScaned: Int = 0
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
companion object {
fun newInstance(entryPoint: String) = BufferLoadFragment(entryPoint)
}
override fun init() {
customDialogList = CustomDialogList(requireContext())
goBack = false
ma.hideBottomNavigation(GONE)
binding.splashProgress.visibility = GONE
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
mpok= MediaPlayer.create((activity as MainActivity),R.raw.ok)
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
setEvents()
setToolBar()
showExpeditionOrBufferScan()
super.init()
}
@ -66,28 +55,27 @@ class BufferLoadFragment(
}
private fun checkLoadExpedition(expeditionOrBuffer: Int) {
listTags.add(SmartTag(expeditionOrBuffer.toString(), getTextScaned(listTags.size + 1) + " $expeditionOrBuffer"))
listTags.add(
SmartTag(
expeditionOrBuffer.toString(),
getTextScaned(listTags.size + 1) + " $expeditionOrBuffer"
)
)
customDialogList.setTitle(getString(R.string.scanBuffer))
tagsAdapter!!.notifyDataSetChanged()
if (listTags.size==2) {
binding.splashProgress.visibility = VISIBLE
if (listTags.size == 2) {
viewModel.expeditionLoadingAdd(
vBufferFk = expeditionOrBuffer,
vExpeditionFk = listTags.first().code.toString().toInt())
vExpeditionFk = listTags.first().code.toString().toInt()
)
}
itemScaned = expeditionOrBuffer
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
@ -96,34 +84,21 @@ class BufferLoadFragment(
}
override fun observeViewModel() {
with(viewModel) {
binding.splashProgress.visibility = GONE
bufferloadresponse.observe(viewLifecycleOwner, Observer {
if (it.response == getString(R.string.registerAdded)) {
if (it.isError) {
ma.messageWithSound(it.errorMessage,it.isError,true)
it.response?.let { it1 -> ma.messageWithSound(it1, false, true) }
} else {
if (it.response == getString(R.string.registerAdded)){
it.response?.let { it1 -> ma.messageWithSound(it1,false,true) }
}else{
mperror?.start()
it.response.toast(requireContext())
}
listTags.clear()
tagsAdapter!!.notifyDataSetChanged()
showExpeditionOrBufferScan()
ma.messageWithSound(it.response,isError = true,true)
}
binding.splashProgress.visibility = GONE
listTags.clear()
tagsAdapter!!.notifyDataSetChanged()
showExpeditionOrBufferScan()
})
}
@ -132,14 +107,15 @@ class BufferLoadFragment(
private fun getTextScaned(tagScaned: Int): String {
return when (tagScaned) {
return when (tagScaned) {
1 -> getString(R.string.expedition)
2 -> getString(R.string.buffer)
else -> { ""}
else -> {
""
}
}
}
private fun showExpeditionOrBufferScan() {
@ -149,8 +125,8 @@ class BufferLoadFragment(
ma.hideKeyboard(customDialogList.getEditText())
listTags.clear()
customDialogList.dismiss()
requireActivity().onBackPressed()
customDialogList.dismiss()
requireActivity().onBackPressed()
}.setValue("").show()
@ -180,10 +156,8 @@ class BufferLoadFragment(
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
}