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( fun expeditionLoadingAdd(
@Query("params") params: Any? = null, @Query("params") params: Any? = null,
@Query("schema") schema: String = "vn" @Query("schema") schema: String = "vn"
): Call<Any> ): Call<List<Map<String, Any>>>
@POST("Applications/expeditionState_addByPallet/execute-proc") @POST("Applications/expeditionState_addByPallet/execute-proc")
fun expeditionStateAddByPallet( fun expeditionStateAddByPallet(

View File

@ -51,21 +51,16 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) {
} }
fun expeditionLoadingAdd(vExpeditionFk: Int, vBufferFk: Int) { fun expeditionLoadingAdd(vExpeditionFk: Int, vBufferFk: Int) {
salix.expeditionLoadingAdd(arrayListOf(vExpeditionFk, vBufferFk)) salix.expeditionLoadingAdd(arrayListOf(vExpeditionFk, vBufferFk), schema = "srt")
.enqueue(object : SalixCallback<Any>(context) { .enqueue(object : SalixCallback<List<Map<String, Any>>>(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<List<Map<String, Any>>>) {
_bufferloadresponse.value = ResponseItemVO( _bufferloadresponse.value =
ResponseItemVO(
isError = false, isError = false,
response = response.body().toString()!! 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 package es.verdnatura.presentation.view.feature.buffer.fragment
import android.media.MediaPlayer import android.media.MediaPlayer
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentBufferLoadexpeditionBinding import es.verdnatura.databinding.FragmentBufferLoadexpeditionBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnSmartTagRowClickListener import es.verdnatura.presentation.common.OnSmartTagRowClickListener
import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.component.CustomDialogList
@ -30,27 +27,19 @@ class BufferLoadFragment(
private var tagsAdapter: BufferAdapter? = null private var tagsAdapter: BufferAdapter? = null
private var itemScaned: Int = 0 private var itemScaned: Int = 0
var mperror: MediaPlayer? = null var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
companion object { companion object {
fun newInstance(entryPoint: String) = BufferLoadFragment(entryPoint) fun newInstance(entryPoint: String) = BufferLoadFragment(entryPoint)
} }
override fun init() { override fun init() {
customDialogList = CustomDialogList(requireContext()) customDialogList = CustomDialogList(requireContext())
goBack = false goBack = false
ma.hideBottomNavigation(GONE) ma.hideBottomNavigation(GONE)
binding.splashProgress.visibility = GONE mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
mpok= MediaPlayer.create((activity as MainActivity),R.raw.ok)
setEvents() setEvents()
setToolBar() setToolBar()
showExpeditionOrBufferScan() showExpeditionOrBufferScan()
super.init() super.init()
} }
@ -66,28 +55,27 @@ class BufferLoadFragment(
} }
private fun checkLoadExpedition(expeditionOrBuffer: Int) { 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)) customDialogList.setTitle(getString(R.string.scanBuffer))
tagsAdapter!!.notifyDataSetChanged() tagsAdapter!!.notifyDataSetChanged()
if (listTags.size == 2) {
if (listTags.size==2) {
binding.splashProgress.visibility = VISIBLE
viewModel.expeditionLoadingAdd( viewModel.expeditionLoadingAdd(
vBufferFk = expeditionOrBuffer, vBufferFk = expeditionOrBuffer,
vExpeditionFk = listTags.first().code.toString().toInt()) vExpeditionFk = listTags.first().code.toString().toInt()
)
} }
itemScaned = expeditionOrBuffer itemScaned = expeditionOrBuffer
} }
private fun setEvents() { private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener { binding.mainToolbar.backButton.setOnClickListener {
@ -96,34 +84,21 @@ class BufferLoadFragment(
} }
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
binding.splashProgress.visibility = GONE
bufferloadresponse.observe(viewLifecycleOwner, Observer { bufferloadresponse.observe(viewLifecycleOwner, Observer {
if (it.response == getString(R.string.registerAdded)) {
if (it.isError) { it.response?.let { it1 -> ma.messageWithSound(it1, false, true) }
ma.messageWithSound(it.errorMessage,it.isError,true)
} else { } else {
ma.messageWithSound(it.response,isError = true,true)
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() listTags.clear()
tagsAdapter!!.notifyDataSetChanged() tagsAdapter!!.notifyDataSetChanged()
showExpeditionOrBufferScan() showExpeditionOrBufferScan()
}
binding.splashProgress.visibility = GONE
}) })
} }
@ -135,10 +110,11 @@ class BufferLoadFragment(
return when (tagScaned) { return when (tagScaned) {
1 -> getString(R.string.expedition) 1 -> getString(R.string.expedition)
2 -> getString(R.string.buffer) 2 -> getString(R.string.buffer)
else -> { ""} else -> {
""
} }
}
} }
@ -180,10 +156,8 @@ class BufferLoadFragment(
customDialogList.getRecyclerView().layoutManager = customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
} }
} }