refs #5135: refactor animation
This commit is contained in:
parent
f950dd0bd7
commit
c1d281348b
|
@ -12,7 +12,7 @@ import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewM
|
|||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.fragment.HistoricoArticuloViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.fragment.ItemShelvingLogViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.shelvingLogViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.ShelvingLogViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
|
||||
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||
|
@ -174,7 +174,7 @@ val viewModelModule = module {
|
|||
ItemShelvingLogViewModel(androidContext())
|
||||
}
|
||||
viewModel {
|
||||
shelvingLogViewModel(androidContext())
|
||||
ShelvingLogViewModel(androidContext())
|
||||
}
|
||||
viewModel {
|
||||
ClaimViewModel(androidContext())
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent
|
|||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.view.feature.login.activity.LoginActivity
|
||||
import org.json.JSONObject
|
||||
|
@ -14,7 +15,6 @@ import retrofit2.Callback
|
|||
import retrofit2.Response
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
||||
|
||||
override fun onResponse(call: Call<T>, response: Response<T>) {
|
||||
|
@ -61,7 +61,11 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
|
||||
open fun onSuccess(response: Response<T>) {
|
||||
// (nameofFunction((this)) + context.getString(R.string.operationSuccessful)).toast(context)
|
||||
//(context as MobileApplication).playSoundIsOK(true)
|
||||
|
||||
(context as MobileApplication).messageToast(
|
||||
isError = false,
|
||||
message = context.getString(R.string.operationSuccessful)
|
||||
)
|
||||
}
|
||||
|
||||
open fun onError(t: Throwable) {
|
||||
|
|
|
@ -14,17 +14,17 @@ import es.verdnatura.presentation.view.feature.historicoshelvinglog.adapter.Shel
|
|||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class shelvingLogFragment(
|
||||
class ShelvingLogFragment(
|
||||
var entryPoint: String = ""
|
||||
|
||||
) : BaseFragment<FragmentShelvinglogBinding, shelvingLogViewModel>(
|
||||
shelvingLogViewModel::class
|
||||
) : BaseFragment<FragmentShelvinglogBinding, ShelvingLogViewModel>(
|
||||
ShelvingLogViewModel::class
|
||||
) {
|
||||
private var adapter: ShelvingLogAdapter? = null
|
||||
private var itemScan = ""
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = shelvingLogFragment(entryPoint)
|
||||
fun newInstance(entryPoint: String) = ShelvingLogFragment(entryPoint)
|
||||
}
|
||||
|
||||
private lateinit var customDialog: CustomDialog
|
||||
|
@ -51,8 +51,7 @@ class shelvingLogFragment(
|
|||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (!binding.scanInput.text.toString().isNullOrEmpty()) {
|
||||
shelvingLog_get(binding.scanInput.text.toString())
|
||||
|
||||
viewModel.shelvings((binding.scanInput.text.toString()))
|
||||
itemScan = binding.scanInput.text.toString()
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
|
@ -62,39 +61,21 @@ class shelvingLogFragment(
|
|||
false
|
||||
}
|
||||
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
requireActivity().onBackPressed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun shelvingLog_get(vShelvingFK: String) {
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.Shelvings(setFilter(vShelvingFK))
|
||||
|
||||
}
|
||||
|
||||
private fun setFilter(vShlevingFK: String): String {
|
||||
|
||||
return "{\"where\": {\"code\": \"$vShlevingFK\"}}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
loadShelvingLogSalixList.observe(viewLifecycleOwner, Observer { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
//adapter = ShelvingLogAdapter(it.list)
|
||||
binding.itemshelvinglogRecyclerview.adapter = adapter
|
||||
binding.itemshelvinglogRecyclerview.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
setToolBar(getString(R.string.shelvingLog) + ":" + itemScan)
|
||||
|
||||
if (it.list.isEmpty()) {
|
||||
customDialog.setTitle(getString(R.string.noResults))
|
||||
.setDescription(getString(R.string.noDataLabelScanned))
|
||||
|
@ -102,17 +83,6 @@ class shelvingLogFragment(
|
|||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
if (it.list.get(0).isError == true) {
|
||||
it.list.get(0).errorMessage?.let { it1 ->
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it1)
|
||||
.setOkButton(getString(R.string.close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
} else {
|
||||
|
||||
val itemId = it.list[0].id
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
|
@ -128,13 +98,9 @@ class shelvingLogFragment(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,59 +1,27 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Transformations
|
||||
import es.verdnatura.domain.SilexCallback
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalixList
|
||||
import retrofit2.Response
|
||||
|
||||
|
||||
class shelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
||||
class ShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _itemShelvingLogSalixList by lazy { MutableLiveData<ShelvingLogSalixList>() }
|
||||
val loadShelvingLogSalixList = Transformations.map(_itemShelvingLogSalixList) { Event(it) }
|
||||
|
||||
fun Shelvings(vShelvingFK: String) {
|
||||
salix.Shelvings(vShelvingFK).enqueue(object :
|
||||
SilexCallback<List<ShelvingLogSalix>>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
val listError: ArrayList<ShelvingLogSalix> = ArrayList()
|
||||
listError.add(
|
||||
ShelvingLogSalix(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
)
|
||||
_itemShelvingLogSalixList.value = ShelvingLogSalixList(listError)
|
||||
}
|
||||
|
||||
fun shelvings(vShelvingFK: String) {
|
||||
salix.Shelvings("""{"where": {"code": "$vShelvingFK"}}""").enqueue(object :
|
||||
SalixCallback<List<ShelvingLogSalix>>(context) {
|
||||
override fun onSuccess(response: Response<List<ShelvingLogSalix>>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
_itemShelvingLogSalixList.value = response.body()?.let {
|
||||
ShelvingLogSalixList(it)
|
||||
}
|
||||
} else {
|
||||
val listError: ArrayList<ShelvingLogSalix> = ArrayList()
|
||||
listError.add(
|
||||
ShelvingLogSalix(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this),
|
||||
response.message()
|
||||
)
|
||||
)
|
||||
)
|
||||
_itemShelvingLogSalixList.value = ShelvingLogSalixList(listError)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package es.verdnatura.presentation.view.feature.workermistake.adapter
|
||||
package es.verdnatura.presentation.view.feature.workermistake.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -7,6 +7,7 @@ import androidx.core.widget.addTextChangedListener
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentWorkermistakeBinding
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
|
@ -18,6 +19,7 @@ import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.SearchDepartmentModel
|
||||
import es.verdnatura.presentation.view.feature.workermistake.adapter.WorkermistakeAdapter
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
|
||||
|
@ -30,7 +32,6 @@ class WorkermistakeFragment(
|
|||
) : BaseFragment<FragmentWorkermistakeBinding, InventaryViewModel>(
|
||||
InventaryViewModel::class
|
||||
) {
|
||||
|
||||
private var adapterworker: WorkermistakeAdapter? = null
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private var listWorker: MutableList<WorkerFromMistake> = ArrayList()
|
||||
|
@ -42,7 +43,6 @@ class WorkermistakeFragment(
|
|||
private var listMistakes: ArrayList<BarcodeVO> = ArrayList()
|
||||
private var listMistakesAdapter: BarcodeAdapter? = null
|
||||
private var workerMistakeName: WorkerFromMistake? = null
|
||||
|
||||
private val departments = ArrayList<SearchDepartmentModel>()
|
||||
private lateinit var departmentId: String
|
||||
|
||||
|
@ -58,61 +58,51 @@ class WorkermistakeFragment(
|
|||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
viewModel.department_getHasMistake()
|
||||
|
||||
viewModel.departmentGetHasMistake()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
||||
binding.filterDepartment.setText(getData(DEPARTMENTMISTAKE))
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
binding.filterDepartment.text = getData(DEPARTMENTMISTAKE)
|
||||
departmentId = getData(DEPARTMENTMISTAKEID)
|
||||
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
|
||||
if (!departmentId.isEmpty()) {
|
||||
if (departmentId.isNotEmpty()) {
|
||||
viewModel.workerGetFromHasMistake(
|
||||
getData(DEPARTMENTMISTAKEID).toInt()
|
||||
)
|
||||
}
|
||||
|
||||
binding.filterDepartment.setOnClickListener {
|
||||
SimpleSearchDialogCompat(context,
|
||||
SimpleSearchDialogCompat(
|
||||
context,
|
||||
getString(R.string.departamentos),
|
||||
getString(R.string.escribirparteNombre),
|
||||
null,
|
||||
departments,
|
||||
{ baseSearchDialogCompat, nombre, position ->
|
||||
|
||||
binding.filterDepartment.setText((nombre.title))
|
||||
departments
|
||||
) { baseSearchDialogCompat, nombre, position ->
|
||||
|
||||
binding.filterDepartment.text = (nombre.title)
|
||||
saveData(DEPARTMENTMISTAKE, nombre.getDepartmentName())
|
||||
saveData(DEPARTMENTMISTAKEID, nombre.getDepartmentId())
|
||||
viewModel.workerGetFromHasMistake(
|
||||
nombre.getDepartmentId()
|
||||
)
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
binding.filterItemFk.isEnabled = true
|
||||
baseSearchDialogCompat.dismiss()
|
||||
}).show()
|
||||
}.show()
|
||||
}
|
||||
|
||||
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
ma.hideBottomNavigation(View.GONE)
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
setToolBar()
|
||||
setEvents()
|
||||
super.init()
|
||||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = entryPoint
|
||||
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
@ -141,38 +131,20 @@ class WorkermistakeFragment(
|
|||
|
||||
}
|
||||
|
||||
/* override fun onPause() {
|
||||
super.onPause()
|
||||
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
|
||||
}*/
|
||||
|
||||
/* override fun onResume() {
|
||||
super.onResume()
|
||||
if (binding.workermistakeRecyclerview.layoutManager != null){
|
||||
if (firstVisiblePosition <= listInvetory.size){
|
||||
binding.workermistakeRecyclerview.layoutManager!!.scrollToPosition(firstVisiblePosition)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
mistakeDepartmentList.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
createDepartmentList(it.list)
|
||||
}
|
||||
|
||||
workerFromMistakeList.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
createWorkerList(it.list)
|
||||
adapterworker =
|
||||
WorkermistakeAdapter(listWorker, object : onMistakeWorkerClickListener {
|
||||
override fun onMistakeWorkerClickListener(item: WorkerFromMistake) {
|
||||
viewModel.workerMistakeType_get(
|
||||
viewModel.workerMistakeTypeGet(
|
||||
)
|
||||
workerMistakeName =
|
||||
WorkerFromMistake(item.id, item.firstName, item.lastName, true, "")
|
||||
|
||||
}
|
||||
})
|
||||
binding.workermistakeRecyclerview.adapter = adapterworker
|
||||
|
@ -182,40 +154,24 @@ class WorkermistakeFragment(
|
|||
}
|
||||
|
||||
mistakeWorkerList.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
showMistakeList(it.list)
|
||||
}
|
||||
|
||||
responseAddMistake.observe(viewLifecycleOwner) {
|
||||
/*responseAddMistake.observe(viewLifecycleOwner) {
|
||||
ma.messageWithSound(
|
||||
if (it.isError) {
|
||||
if (it.codeError == 403) {
|
||||
getString(R.string.userNotPermission)
|
||||
} else {
|
||||
it.errorMessage
|
||||
}
|
||||
} else {
|
||||
getString(R.string.errorCauseRegistered)
|
||||
}, it.isError, true, isToasted = true
|
||||
message = getString(R.string.errorCauseRegistered),
|
||||
it.isError,
|
||||
true,
|
||||
isToasted = true
|
||||
)
|
||||
}
|
||||
|
||||
response.observe(viewLifecycleOwner) {
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(it.errorMessage, true, false)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private fun showMistakeList(list: List<MistakeType>) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
listMistakes = ArrayList()
|
||||
list.forEach {
|
||||
listMistakes.add(BarcodeVO(code = it.description))
|
||||
}
|
||||
|
||||
|
||||
customDialogList.setTitle(getString(R.string.errorCause) + workerMistakeName!!.firstName)
|
||||
.setKoButton(
|
||||
getString(
|
||||
|
@ -225,13 +181,12 @@ class WorkermistakeFragment(
|
|||
customDialogList.dismiss()
|
||||
}.hideDialog().show()
|
||||
|
||||
|
||||
listMistakesAdapter =
|
||||
BarcodeAdapter(listMistakes, object : OnBarcodeRowClickListener {
|
||||
override fun onBarcodeRowClickListener(item: BarcodeVO) {
|
||||
list.forEach {
|
||||
if (it.description == item.code) {
|
||||
viewModel.workerMistake_Add(
|
||||
viewModel.workerMistakeAdd(
|
||||
vUserFk = workerMistakeName!!.id!!,
|
||||
vTypeFk = it.code
|
||||
)
|
||||
|
@ -243,7 +198,6 @@ class WorkermistakeFragment(
|
|||
}, showDelete = false)
|
||||
|
||||
customDialogList.getRecyclerView().adapter = listMistakesAdapter
|
||||
|
||||
customDialogList.getRecyclerView().layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
|
@ -256,6 +210,7 @@ class WorkermistakeFragment(
|
|||
try {
|
||||
departments.add(SearchDepartmentModel(department.name, department.id))
|
||||
} catch (e: Exception) {
|
||||
e.message!!.toast(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,11 +220,11 @@ class WorkermistakeFragment(
|
|||
listWorker.clear()
|
||||
|
||||
list.forEach { worker ->
|
||||
|
||||
if (!worker.isError) {
|
||||
try {
|
||||
listWorker.add(worker)
|
||||
} catch (e: Exception) {
|
||||
e.message!!.toast(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -691,6 +691,8 @@
|
|||
<string name="yes">SI</string>
|
||||
<string name="no">NO</string>
|
||||
<string name="add">Añadir...</string>
|
||||
<string name="surname">Apellidos</string>
|
||||
<string name="confirmReserv">Confirmada reserva</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -489,7 +489,7 @@
|
|||
<string name="workFormDescrip">Proporciona un nombre y url de los servidores a los que la app se conectará</string>
|
||||
<string name="silexServer">Servidor Silex</string>
|
||||
<string name="salixServer">Servidor Salix</string>
|
||||
<string name="name">Nombre</string>
|
||||
<string name="name">Nom</string>
|
||||
<string name="deleteWorkForm">Borrar forma trabajo</string>
|
||||
<string name="deleteWorkFormConfirmation">¿Desea borrar definitivamente la forma de trabajo?</string>
|
||||
<string name="icViewCollection">Ver colección o último ticket</string>
|
||||
|
@ -691,6 +691,8 @@
|
|||
<string name="yes">OUI</string>
|
||||
<string name="no">NON</string>
|
||||
<string name="add">Añadir...</string>
|
||||
<string name="surname">Nom de famille</string>
|
||||
<string name="confirmReserv">Confirmada reserva</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -489,7 +489,7 @@
|
|||
<string name="workFormDescrip">Proporciona un nombre y url de los servidores a los que la app se conectará</string>
|
||||
<string name="silexServer">Servidor Silex</string>
|
||||
<string name="salixServer">Servidor Salix</string>
|
||||
<string name="name">Nombre</string>
|
||||
<string name="name">Nome</string>
|
||||
<string name="deleteWorkForm">Borrar forma trabajo</string>
|
||||
<string name="deleteWorkFormConfirmation">¿Desea borrar definitivamente la forma de trabajo?</string>
|
||||
<string name="icViewCollection">Ver colección o último ticket</string>
|
||||
|
@ -691,6 +691,8 @@
|
|||
<string name="yes">SIM</string>
|
||||
<string name="no">NÃO</string>
|
||||
<string name="add">Añadir...</string>
|
||||
<string name="surname">Sobrenome</string>
|
||||
<string name="confirmReserv">Confirmada reserva</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -690,5 +690,7 @@
|
|||
<string name="yes">YES</string>
|
||||
<string name="no">NO</string>
|
||||
<string name="add">Añadir...</string>
|
||||
<string name="surname">Surname</string>
|
||||
<string name="confirmReserv">Confirmada reserva</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue