diff --git a/.idea/workspace.xml b/.idea/workspace.xml index dcccc6bb..50fa9597 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -129,17 +129,42 @@ + + - - + + + + + + + + + + + + + + + + + + + + + + + + + - { - "keyToString": { - "ApkExportedModule": "Gestor_Almacén.app", - "ExportApk.ApkPathForGestor_Almacén.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app", - "KotlinFunctionFindUsagesOptions.isSearchForTextOccurrences": "true", - "PROJECT_TRUSTED_KEY": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.cidr.known.project.marker": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "ScreenRecorder.SavePath": "C:\\Users\\sergiodt", - "android-custom-viewC:/Users/sergiodt/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED": "RecyclerView", - "android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-29/android/widget/TextView.java_SELECTED": "TextView", - "android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-33/android/view/View.java_SELECTED": "View", - "cidr.known.project.marker": "true", - "com.android.tools.idea.devicemanager.tab": "Physical", - "com.google.services.firebase.aqiPopupShown": "true", - "git-widget-placeholder": "dev", - "last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable", - "project.structure.last.edited": "Suggestions", - "project.structure.proportion": "0.17", - "project.structure.side.proportion": "0.2", - "run.code.analysis.last.selected.profile": "pProject Default", - "settings.editor.selected.configurable": "preferences.sourceCode.Kotlin" + +}]]> @@ -950,7 +976,6 @@ diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index 169e6d35..00b7b7a4 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -260,7 +260,7 @@ interface SalixService { @Body vararg params: Any? ): Call - @GET("ItemShelvings/getSale")//NO SALIX + @GET("Sales/getFromSectorCollection")//NO SALIX fun sectorCollectionGetSale( @Query("sectorFk") sectorFk: Int, @Query("sectorCollectionFk") sectorCollectionFk: Int, @@ -307,6 +307,12 @@ interface SalixService { ): Call + @POST("MachineWorkers/add")//REVISADA + fun machineWorkerAdd( + @Query("plate") plate: Any + ): + Call + @POST("SaleTrackings/updateTracking")//REVISADA fun saleTrackingUpdate( @Body params: Any diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index eb0d864b..487b0031 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -433,7 +433,7 @@ abstract class BaseFragment( saveWorkForm( WorkForms( "TestHome", - "http://192.168.1.142:9000", + "http://192.168.1.132:9000", urlSalix = "https://test-salix.verdnatura.es" ) ) @@ -447,8 +447,8 @@ abstract class BaseFragment( saveWorkForm( WorkForms( "TestLOCALHOME", - "http://192.168.1.142:9000", - urlSalix = "http://192.168.1.142:3000" + "http://192.168.1.132:9000", + urlSalix = "http://192.168.1.132:3000" ) ) } else { diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragmentSalix.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragmentSalix.kt index fdcbb8d8..219ccf8e 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragmentSalix.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragmentSalix.kt @@ -391,7 +391,7 @@ abstract class BaseFragmentSalix(BufferFragmentViewModel::class) { - override fun getLayoutId(): Int = R.layout.fragment_buffer companion object { fun newInstance(entryPoint: String) = BufferFragment(entryPoint) } - override fun init() { - binding.splashProgress.visibility = View.GONE setToolbar() setEvents() super.init() @@ -41,23 +37,29 @@ class BufferFragment( binding.scanInput.setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!binding.scanInput.text.isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE + try { + when (entryPoint) { + getString(R.string.titleBufferEmpty) -> entryPoint = "UNLOADING" + getString(R.string.titleBufferFill) -> entryPoint = "LOADING" + getString(R.string.titleBufferAccumulate) -> entryPoint = "ACCUMULATION" + getString(R.string.titleBufferOff) -> entryPoint = "DISABLED" + getString(R.string.titleBufferStrapping) -> entryPoint = "STRAPPING" + } - when (entryPoint) { + viewModel.bufferSetTypeByName( + binding.scanInput.toInt(), + entryPoint - getString(R.string.titleBufferEmpty) -> entryPoint = "UNLOADING" - getString(R.string.titleBufferFill) -> entryPoint = "LOADING" - getString(R.string.titleBufferAccumulate) -> entryPoint = "ACCUMULATION" - getString(R.string.titleBufferOff) -> entryPoint = "DISABLED" - getString(R.string.titleBufferStrapping) -> entryPoint = "STRAPPING" + ) + } catch (ex: Exception) { + ma.messageWithSound( + getString(R.string.itemNotValid), + isToasted = true, + isError = true, + isPlayed = true + ) } - viewModel.buffer_setTypeByName( - binding.scanInput.toInt(), - entryPoint - - ) - } binding.scanInput.setText("") ma.hideKeyboard(binding.scanInput) @@ -71,31 +73,11 @@ class BufferFragment( with(viewModel) { itembuffertype.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - if (it.isError) { - - ma.messageWithSound( - getString(R.string.errorOperation) + it.errorMessage, - it.isError, - isPlayed = true - ) - - } else { - - ma.messageWithSound( - entryPoint.lowercase() + "." + getString(R.string.operationSuccess), - false, - isPlayed = true - ) - binding.mainToolbar.backButton.performClick() - - } + binding.mainToolbar.backButton.performClick() }) } } - -} - +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt index 284d212f..3e973717 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt @@ -8,8 +8,6 @@ import es.verdnatura.R import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.formatWithQuotes import es.verdnatura.presentation.base.BaseViewModel -import es.verdnatura.presentation.base.getMessageFromAllResponse -import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.ResponseItemVO import retrofit2.Response @@ -25,7 +23,7 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) { val bufferloadresponse: LiveData get() = _bufferloadresponse - fun buffer_setTypeByName(vBufferFk: Int, vType: String) { + fun bufferSetTypeByName(vBufferFk: Int, vType: String) { salix.buffer_setTypeByName(params = listOf(vBufferFk, vType).formatWithQuotes()) .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { @@ -37,14 +35,9 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) { } else { "" } - ) - } - override fun onError(t: Throwable) { - _itembuffertype.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) ) + super.onSuccess(response) } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt index 20c15528..fcc3c161 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt @@ -5,7 +5,6 @@ import android.graphics.drawable.Drawable import android.os.Build import android.util.TypedValue import android.view.View.GONE -import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import android.widget.ImageView import androidx.recyclerview.widget.LinearLayoutManager @@ -51,11 +50,7 @@ class ControlVehiculoFragment( customDialogInput = CustomDialogInput(requireContext()) customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) goBack = false - - binding.splashProgress.visibility = GONE - - - if (tagName.equals(HistoricoVehiculoFragment.TAG)) { + if (tagName == HistoricoVehiculoFragment.TAG) { setToolBar("HISTORY") showScanner(getString(R.string.scanShelvingHistorical), "HISTORY") } else { @@ -69,7 +64,6 @@ class ControlVehiculoFragment( super.init() } - override fun onPause() { goBack = true super.onPause() @@ -103,6 +97,7 @@ class ControlVehiculoFragment( listIcons.add(iconVehicleOut) listIcons.add(iconHistory) } + "IN" -> { listIcons.remove(iconVehicleOut) listIcons.add(iconVehicleIn) @@ -117,13 +112,12 @@ class ControlVehiculoFragment( when (item) { iconHistory.drawable -> showScanner( - getString(R.string.scanShelvingHistorical), - "HISTORY" + getString(R.string.scanShelvingHistorical), "HISTORY" ) + iconVehicleIn.drawable -> showScanner(getString(R.string.scanPlate), "IN") iconVehicleOut.drawable -> showScanner( - getString(R.string.scanPlateTakeoff), - "OUT" + getString(R.string.scanPlateTakeoff), "OUT" ) } } @@ -167,7 +161,6 @@ class ControlVehiculoFragment( private fun checkControlTimeVehicle() { if (!goBack) { - binding.splashProgress.visibility = VISIBLE viewModel.workerMachineryIsRegistered(mobileApplication.userId!!) } } @@ -177,11 +170,9 @@ class ControlVehiculoFragment( if (direction.equals("HISTORY")) { ma.onPasillerosItemClickListener( - PasillerosItemVO(title = getString(R.string.titleHistoricalHide)), - plateNumber + PasillerosItemVO(title = getString(R.string.titleHistoricalHide)), plateNumber ) } else if (direction.equals("IN")) { - binding.splashProgress.visibility = VISIBLE viewModel.machineWorker_add(plateNumber) } else if (direction.equals("OUT")) { @@ -198,9 +189,7 @@ class ControlVehiculoFragment( } private fun scanRequest() { - // if (binding.scanInput != null) { binding.scanInput.requestFocus() - //} hideKeyboards() } @@ -211,12 +200,10 @@ class ControlVehiculoFragment( } } - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { ma.openFragmentPickers(true) - //requireActivity().onBackPressed() } @@ -250,7 +237,6 @@ class ControlVehiculoFragment( if (customDialogThreeButtons.getValue().trim().isEmpty()) { getString(R.string.returnScan).toast(requireContext()) } else { - binding.splashProgress.visibility = VISIBLE customDialogThreeButtons.dismiss() insertControlTimeVehicle(customDialogThreeButtons.getValue(), "IN") } @@ -261,7 +247,6 @@ class ControlVehiculoFragment( if (customDialogThreeButtons.getValue().trim().isEmpty()) { getString(R.string.returnScan).toast(requireContext()) } else { - binding.splashProgress.visibility = VISIBLE customDialogThreeButtons.dismiss() insertControlTimeVehicle(customDialogThreeButtons.getValue(), "OUT") } @@ -307,7 +292,6 @@ class ControlVehiculoFragment( override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = GONE responseinsert.observe(viewLifecycleOwner) { if (it.isError) { @@ -325,60 +309,49 @@ class ControlVehiculoFragment( } else { if (it.response == "true") { ma.openFragmentPickers(false) - //ma.onPasillerosItemClickListener( PasillerosItemVO(title = "Sacadores"),"CONTROL") - //checkControlTimeVehicle() + } } } - binding.splashProgress.visibility = GONE + } responsecontrol.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = GONE - if (it.isError) { - ma.messageWithSound(it.errorMessage, true, false) + if (it.response == "1") { + isWorkedTimed = "REGISTERED" + setToolBar("OUT") + + if (!tagName.equals(SacadorFragment.TAG)) { + ma.openFragmentPickers(false) + } } else { - if (it.response == "1") { - isWorkedTimed = "REGISTERED" - setToolBar("OUT") - if (!tagName.equals(SacadorFragment.TAG)) { - ma.openFragmentPickers(false) - } + if (it.response == "0") { + setToolBar("IN") - } else { - - if (it.response == "0") { - setToolBar("IN") - - customDialogInput.setTitle(getString(R.string.vehiclecontrol)) - .setDescription(getString(R.string.scanPlate)) - .setOkButton(getString(R.string.takeVehicle)) { - if (customDialogInput.getValue().isNotEmpty()) { - // "$description ${customDialogInput.getValue()} OK".toast(requireContext()) - insertControlTimeVehicle(customDialogInput.getValue(), "IN") - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogInput.setTitle(getString(R.string.vehiclecontrol)) + .setDescription(getString(R.string.scanPlate)) + .setOkButton(getString(R.string.takeVehicle)) { + if (customDialogInput.getValue().isNotEmpty()) { + insertControlTimeVehicle(customDialogInput.getValue(), "IN") } + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() + } - .setKoButton(getString(R.string.noVehicle)) { - customDialogInput.dismiss() - ma.openFragmentPickers(true) - /* if (tagName.equals(HistoricoVehiculoFragment.TAG)) { - ma.onBackPressed() - }*/ + .setKoButton(getString(R.string.noVehicle)) { + customDialogInput.dismiss() + ma.openFragmentPickers(true) - }.setValue("").show() + }.setValue("").show() - customDialogInput.setFocusText() + customDialogInput.setFocusText() - } } } } @@ -387,7 +360,4 @@ class ControlVehiculoFragment( } - -} - - +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt index 1e06b99e..8471f58f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt @@ -11,13 +11,14 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentVehiclecontrolUserBinding +import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.common.loadUrl class ControlVehiculoUsuarioFragment( - var vUserFK: Int + private var vUserFK: Int ) : BaseFragment( ControlVehiculoViewModel::class ) { @@ -34,7 +35,6 @@ class ControlVehiculoUsuarioFragment( override fun init() { binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclecontroluser) goBack = false - binding.splashProgress.visibility = GONE setEvents() setToolBar() setControlVehicleUser() @@ -70,8 +70,6 @@ class ControlVehiculoUsuarioFragment( } private fun getExtensionFromUser() { - - binding.splashProgress.visibility = VISIBLE viewModel.sip_getExtensionSalix(vUserFK) } @@ -85,7 +83,6 @@ class ControlVehiculoUsuarioFragment( userFk = mobileApplication.userId!! if (userFk == vUserFK) { - binding.splashProgress.visibility = VISIBLE viewModel.machineGetWorkerPlate(mobileApplication.userId!!) viewModel.deviceProduction_getnameDevice( getData(ANDROID_ID) @@ -125,11 +122,9 @@ class ControlVehiculoUsuarioFragment( override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = GONE + responsemachine.observe(viewLifecycleOwner) { - responsemachine.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = GONE if (it.isError) { ma.messageWithSound(it.errorMessage, true, false) @@ -154,11 +149,9 @@ class ControlVehiculoUsuarioFragment( } - }) + } responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = GONE - if (it.isError) { ma.messageWithSound( getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + vUserFK, @@ -186,7 +179,7 @@ class ControlVehiculoUsuarioFragment( startActivity(intent) } catch (e: Exception) { - + getString(R.string.errorOperation).toast(requireContext()) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt index a7650733..e92762b9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt @@ -20,9 +20,6 @@ import retrofit2.Response class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { - /* private val getVehicleControlTimeUserCase: GetVehicleControlTimeUserCase = - GetVehicleControlTimeUserCase(context)*/ - private val _responseinsert by lazy { MutableLiveData() } val responseinsert: LiveData get() = _responseinsert @@ -40,12 +37,12 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { get() = _responseGetExtensionFromUserId fun machineWorker_add( - PlateNumber: String + plateNumber: String ) { //tarea 6276 - // salix.machineWorkerUpdateInTime() - silex.machineWorker_add(PlateNumber) - .enqueue(object : SilexCallback(context) { + //salix.machineWorkerAdd(plateNumber) + silex.machineWorker_add(plateNumber) + .enqueue(object : SalixCallback(context) { override fun onError(t: Throwable) { _responseinsert.value = ResponseItemVO( isError = true, @@ -85,7 +82,7 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { ) { //Tarea 6276 //salix.machineWorkerUpdateInTime(plate) - silex.machineWorker_update(plate) + silex.machineWorker_update(plate) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _responseinsert.value = ResponseItemVO( @@ -125,13 +122,6 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { _responsecontrol.value = ResponseItemVO(isError = false, response = response.body()!!) } - - override fun onError(t: Throwable) { - _responsecontrol.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } }) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/InfoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/InfoFragment.kt index 806d3831..0c4b94aa 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/InfoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/InfoFragment.kt @@ -18,7 +18,6 @@ class InfoFragment(var title: String) : super.init() binding.mainToolbar.toolbarTitle.text = title ma.hideBottomNavigation(View.GONE) - binding.splashProgress.visibility = View.VISIBLE viewModel.companyGetFiscaldata(mobileApplication.userId!!) viewModel.getInfoFreelance(mobileApplication.userId!!) setEvents() @@ -34,7 +33,6 @@ class InfoFragment(var title: String) : with(viewModel) { companyInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { binding.itemName.text = it.list[0]?.name binding.itemNif.text = it.list[0]?.nif @@ -43,7 +41,6 @@ class InfoFragment(var title: String) : } freelanceInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { binding.linearInfoFreelance.visibility=View.VISIBLE binding.freelanceName.text = it.list[0]?.name diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt index 6d30fffe..156b9c89 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt @@ -2,8 +2,6 @@ package es.verdnatura.presentation.view.feature.delivery.fragments import android.content.Context import android.content.Intent -import android.content.pm.PackageInfo -import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.os.Build import android.view.View @@ -37,10 +35,10 @@ import org.json.JSONObject import java.util.Date class LoadUnloadFragment( - var title: String = "", - var state: String = "", - var entryPoint: String, - var clientTicketList: ArrayList? + private var title: String = "", + private var state: String = "", + private var entryPoint: String, + private var clientTicketList: ArrayList? ) : BaseFragment( DeliveryViewModel::class @@ -62,13 +60,11 @@ class LoadUnloadFragment( state: String, entryPoint: String, clientTicketList: ArrayList? = null - ) = - LoadUnloadFragment(title, state, entryPoint, clientTicketList) + ) = LoadUnloadFragment(title, state, entryPoint, clientTicketList) fun scanning(scan: Boolean) { scanned = scan } - } override fun getLayoutId(): Int = R.layout.fragment_expedition_loadunload_delivery @@ -126,7 +122,6 @@ class LoadUnloadFragment( } ) - binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { @@ -141,11 +136,9 @@ class LoadUnloadFragment( iconSign.drawable -> { setExpeditionsState(myList, state) - //openSignActivity() } } } catch (ex: Exception) { - //Tarea 5313 getString(R.string.errorNotData).toast(requireContext()) } @@ -184,7 +177,6 @@ class LoadUnloadFragment( var expeditionBack = hashMapOf("expeditions" to mlist as List) if (list.filter { it.code == state }.isNotEmpty()) { if (list.filter { it.code == state }.size == list.size) { - binding.splashProgress.visibility = View.VISIBLE viewModel.expeditionStateAddSalix(expeditionBack) counterCalls = 1 } else { @@ -215,8 +207,7 @@ class LoadUnloadFragment( val intent = Intent(requireContext(), SignedActivity::class.java) intent.putExtra( - "clientTicketList", - clientTicketList!!.first() + "clientTicketList", clientTicketList!!.first() ) intent.putExtra("objectSigned", "ticket") //cmr @@ -224,27 +215,6 @@ class LoadUnloadFragment( requireActivity().onBackPressed() } - private fun openAppDelivery() { - val i = Intent() - val manager: PackageManager = requireContext().packageManager - val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - val version = info.versionName - - if (version.contains("Beta")) { - i.setClassName( - "verdnatura.es.repartoverdnatura.sfusion", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } else { - i.setClassName( - "verdnatura.es.repartoverdnatura", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } - i.putExtra("app", "picking") - startActivity(i) - } - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() @@ -312,14 +282,12 @@ class LoadUnloadFragment( if (binding.mainToolbar.switchButton.isChecked) { counterCalls = 1 - binding.splashProgress.visibility = View.VISIBLE val pendingExpeditionSend = myList.map { l -> ExpeditionSalix( - expeditionFk = l.id, - stateCode = l.code + expeditionFk = l.id, stateCode = l.code ) } - viewModel.expeditionStateAddSalix( hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == state })) + viewModel.expeditionStateAddSalix(hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == state })) } else { updateCount(myList, state) } @@ -329,11 +297,9 @@ class LoadUnloadFragment( override fun observeViewModel() { with(viewModel) { expeditionInfoLoadUnloadList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createList(it.list as MutableList) } routeInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.switchButton.visibility = View.VISIBLE @@ -344,7 +310,6 @@ class LoadUnloadFragment( } } responseStateAdd.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (!it.isError) { counterResponse = counterResponse + 1 if (counterResponse == counterCalls) { @@ -367,14 +332,12 @@ class LoadUnloadFragment( } responseStateList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE ma.messageWithSound(it.errorMessage, true, true, "", true) savePendingExpeditions() openSignActivity() } responseLoadList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createList(mutableListOf(), true) } } @@ -414,9 +377,8 @@ class LoadUnloadFragment( private fun setSwitchButon() { binding.mainToolbar.switchButton.tooltipText = getString(R.string.expeditionMarkLost) binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked -> - binding.mainToolbar.switchButton.tooltipText = if (isChecked) - getString(R.string.expeditionMarkFound) else - getString(R.string.expeditionMarkLost) + binding.mainToolbar.switchButton.tooltipText = + if (isChecked) getString(R.string.expeditionMarkFound) else getString(R.string.expeditionMarkLost) binding.mainToolbar.toolbarTitle.text = if (isChecked) { @@ -436,13 +398,9 @@ class LoadUnloadFragment( withContext(Dispatchers.IO) { if (getSaved) { - myList = - db.expedicionDao() - .getAllPending(route) + myList = db.expedicionDao().getAllPending(route) if (myList.isEmpty()) { - myList = - db.expedicionDao() - .getAll(route) + myList = db.expedicionDao().getAll(route) } } else { @@ -463,12 +421,9 @@ class LoadUnloadFragment( binding.expeditionloadunloadRecyclerview.adapter = adapter binding.expeditionloadunloadRecyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - binding.mainToolbar.toolbarSubtitle.text = - getString( - R.string.summaryCount, - myList.filter { it.code == state }.size, - myList.size - ) + binding.mainToolbar.toolbarSubtitle.text = getString( + R.string.summaryCount, myList.filter { it.code == state }.size, myList.size + ) setListPosition(myList) } @@ -489,8 +444,7 @@ class LoadUnloadFragment( private fun getExpeditionTable(myRoute: Int) { lifecycleScope.launch { withContext(Dispatchers.IO) { - myList = - db.expedicionDao().getAll(myRoute) as MutableList + myList = db.expedicionDao().getAll(myRoute) } } @@ -507,8 +461,7 @@ class LoadUnloadFragment( private fun updateCount(list: MutableList, state: String) { - val countMarked = - list.filter { it.code == state }.size + val countMarked = list.filter { it.code == state }.size binding.mainToolbar.toolbarSubtitle.text = getString(R.string.summaryCount, countMarked, list.size) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt index 1803c38b..d9b67bfb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt @@ -1,8 +1,5 @@ package es.verdnatura.presentation.view.feature.delivery.fragments -import android.content.Intent -import android.content.pm.PackageInfo -import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.os.Build import android.view.View @@ -54,8 +51,7 @@ class LogExpeditionFragment( @RequiresApi(Build.VERSION_CODES.O) private fun setToolBar() { - binding.mainToolbar.switchButton.tooltipText = - getString(R.string.expeditionMarkFound) + binding.mainToolbar.switchButton.tooltipText = getString(R.string.expeditionMarkFound) val listIcons: ArrayList = ArrayList() val iconDelivery = ImageView(context) @@ -74,8 +70,7 @@ class LogExpeditionFragment( when (item) { iconDelivery.drawable -> { ma.openSummaryFragment( - binding.route.text.toString().toInt(), - "ON_DELIVERY" + binding.route.text.toString().toInt(), "ON_DELIVERY" ) } } @@ -87,28 +82,6 @@ class LogExpeditionFragment( binding.mainToolbar.toolbarIcons.visibility = View.GONE } - private fun openAppDelivery() { - val i = Intent() - val manager: PackageManager = requireContext().packageManager - val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - val version = info.versionName - - if (version.contains("Beta")) { - i.setClassName( - "verdnatura.es.repartoverdnatura.sfusion", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } else { - i.setClassName( - "verdnatura.es.repartoverdnatura", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } - i.putExtra("routeId", binding.route.text) - i.putExtra("app", "picking") - startActivity(i) - } - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() @@ -118,7 +91,6 @@ class LogExpeditionFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!binding.scanInput.text.isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE try { viewModel.expeditionGetLog(binding.scanInput.toInt()) originalItem = binding.scanInput.toInt() @@ -139,13 +111,13 @@ class LogExpeditionFragment( override fun observeViewModel() { with(viewModel) { expeditionInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE + createList(it.list) setSwitchButon() viewModel.get_routesFromExpedition(originalItem) } routeInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE + if (it.list.isNotEmpty()) { binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.switchButton.visibility = View.VISIBLE @@ -158,7 +130,6 @@ class LogExpeditionFragment( } } responseStateAdd.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE viewModel.expeditionGetLog(originalItem) } } @@ -168,11 +139,8 @@ class LogExpeditionFragment( private fun setSwitchButon() { binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked -> - binding.mainToolbar.switchButton.tooltipText = if (isChecked) - getString(R.string.expeditionMarkLost) else - getString(R.string.expeditionMarkFound) - - binding.splashProgress.visibility = View.VISIBLE + binding.mainToolbar.switchButton.tooltipText = + if (isChecked) getString(R.string.expeditionMarkLost) else getString(R.string.expeditionMarkFound) if (isChecked) { viewModel.expeditionStateAddSalix( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt index 8d1f6c2e..c3315037 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt @@ -1,8 +1,5 @@ package es.verdnatura.presentation.view.feature.delivery.fragments -import android.content.Intent -import android.content.pm.PackageInfo -import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.os.Build import android.text.Editable @@ -18,7 +15,6 @@ import es.verdnatura.databinding.FragmentRouteBinding import es.verdnatura.db.DeliveryDatabase import es.verdnatura.domain.notNull import es.verdnatura.domain.toDateString -import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.database import es.verdnatura.presentation.common.* @@ -47,8 +43,7 @@ class RoutesFragment( private lateinit var myListRouteLoaded: List companion object { - fun newInstance(title: String) = - RoutesFragment(title) + fun newInstance(title: String) = RoutesFragment(title) } override fun getLayoutId(): Int = R.layout.fragment_route @@ -60,7 +55,7 @@ class RoutesFragment( setToolBar() binding.scanInput.requestFocus() pendingOperations() - callBack(viewModel.getRoutes(mobileApplication.userId!!)) + viewModel.getRoutes() } @@ -74,35 +69,33 @@ class RoutesFragment( for (p in pending) { viewModel.saveSign(p.fileName, p.queryMapList) } - val pendingExpedition = - db.expedicionDao().getAllPendingExpeditions() - + val pendingExpedition = db.expedicionDao().getAllPendingExpeditions() val pendingExpeditionSend = pendingExpedition.map { l -> ExpeditionSalix( - expeditionFk = l.id, - stateCode = l.code + expeditionFk = l.id, stateCode = l.code ) } - if (pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" }.isNotEmpty()) { + if (pendingExpeditionSend.filter { it.stateCode == "DELIVERED" }.isNotEmpty()) { viewModel.expeditionStateAddSalix( - hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" }) + hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == "DELIVERED" }) ) } - if (pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" }.isNotEmpty()) { + if (pendingExpeditionSend.filter { it.stateCode == "ON DELIVERY" } + .isNotEmpty()) { viewModel.expeditionStateAddSalix( - hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" }) + hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == "ON DELIVERY" }) ) } - if (pendingExpeditionSend.filter{ it.stateCode == "LOST" }.isNotEmpty()) { + if (pendingExpeditionSend.filter { it.stateCode == "LOST" }.isNotEmpty()) { viewModel.expeditionStateAddSalix( - hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "LOST" }) + hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == "LOST" }) ) } - if (pendingExpeditionSend.filter{ it.stateCode == "FOUND" }.isNotEmpty()) { + if (pendingExpeditionSend.filter { it.stateCode == "FOUND" }.isNotEmpty()) { viewModel.expeditionStateAddSalix( - hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "FOUND" }) + hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == "FOUND" }) ) } @@ -133,12 +126,6 @@ class RoutesFragment( } } - private fun callBack(callBackEndPoint: Unit) { - binding.splashProgress.visibility = View.VISIBLE - return callBackEndPoint - } - - @RequiresApi(Build.VERSION_CODES.O) private fun setToolBar() { ma.hideBottomNavigation(View.GONE) @@ -173,7 +160,7 @@ class RoutesFragment( when (item) { iconRefresh.drawable -> { - callBack(viewModel.getRoutes(mobileApplication.userId!!)) + viewModel.getRoutes() } iconInfo.drawable -> { @@ -198,42 +185,6 @@ class RoutesFragment( binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE } - private fun openAppDelivery(item: RouteInfo) { - val i = Intent() - val manager: PackageManager = requireContext().packageManager - val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - val version = info.versionName - try { - if (version.contains("Beta")) { - i.setClassName( - "verdnatura.es.repartoverdnatura.sfusion", - "verdnatura.es.repartoverdnatura.Tickets" - ) - } else { - i.setClassName( - "verdnatura.es.repartoverdnatura", - "verdnatura.es.repartoverdnatura.Tickets" - ) - } - i.putExtra("plate", item.numberPlate) - i.putExtra("id", item.id.toString()) - i.putExtra("agency", item.name) - i.putExtra("hour", item.hour) - i.putExtra("date", item.created.toString()) - i.putExtra("m3", item.m3.toString()) - i.putExtra("driver", item.driver) - i.putExtra("kmStart", item.kmStart.toString()) - i.putExtra("kmEnd", item.kmEnd.toString()) - i.putExtra("dEnd", item.finished) - i.putExtra("dStart", item.started) - i.putExtra("app", "picking") - startActivity(i) - } catch (e: Exception) { - getString(R.string.deliveryApp).toast(context) - } - - } - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() @@ -246,9 +197,7 @@ class RoutesFragment( } override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - val searchText = s.toString().lowercase() filteredList(s.toString().lowercase()) - } override fun afterTextChanged(s: Editable?) { @@ -271,14 +220,12 @@ class RoutesFragment( with(viewModel) { loadRouteList.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = View.GONE createListRoutes(it.list) } } routeInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.switchButton.visibility = View.VISIBLE @@ -301,7 +248,6 @@ class RoutesFragment( } responseLoadList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE ma.messageWithSound(getString(R.string.offline), false, false, "", true) createListRoutes(mutableListOf(), getSaved = true) } @@ -337,8 +283,7 @@ class RoutesFragment( // myListRoute = list adapter = RouteAdapter( - myListRoute, - object : OnItemImageRouteRowClickListener { + myListRoute, object : OnItemImageRouteRowClickListener { override fun onItemImageRouteRowClickListener(item: RouteInfo, action: String) { when (action) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt index 24109b4e..c4059b07 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt @@ -1,8 +1,5 @@ package es.verdnatura.presentation.view.feature.delivery.fragments -import android.content.Intent -import android.content.pm.PackageInfo -import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.os.Build import android.view.View @@ -59,7 +56,7 @@ class SummaryFragment( setEvents() setToolBar() binding.scanInput.requestFocus() - callBack(viewModel.route_getExpeditionSummary(route)) + callBack(viewModel.routeGetExpeditionSummary(route)) routeSelected = route setViews() @@ -76,7 +73,6 @@ class SummaryFragment( } private fun callBack(routeGetexpeditionsummary: Unit) { - binding.splashProgress.visibility = View.VISIBLE routeGetexpeditionsummary } @@ -188,9 +184,6 @@ class SummaryFragment( android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.save) ) { dialog, which -> - binding.splashProgress.visibility = View.VISIBLE - - counterCalls = 1 viewModel.expeditionStateAddSalix(hashMapOf("expeditions" to listExpedition.filter { it.stateCode == state })) @@ -210,28 +203,6 @@ class SummaryFragment( } - private fun openAppDelivery() { - val i = Intent() - val manager: PackageManager = requireContext().packageManager - val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - val version = info.versionName - - if (version.contains("Beta")) { - i.setClassName( - "verdnatura.es.repartoverdnatura.sfusion", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } else { - i.setClassName( - "verdnatura.es.repartoverdnatura", - "verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity" - ) - } - // i.putExtra("routeId", binding.route.text) - i.putExtra("app", "picking") - startActivity(i) - } - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() @@ -294,17 +265,14 @@ class SummaryFragment( with(viewModel) { expeditionInfoLoadUnloadList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createList(it.list as MutableList) } expeditionInfoSummary.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createListSummary(it.list) } routeInfoList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.switchButton.visibility = View.VISIBLE @@ -315,11 +283,10 @@ class SummaryFragment( } } responseStateAdd.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (!it.isError) { counterResponse = counterResponse + 1 if (counterResponse == counterCalls) { - callBack(viewModel.route_getExpeditionSummary(routeSelected)) + callBack(viewModel.routeGetExpeditionSummary(routeSelected)) counterResponse = 0 counterCalls = 0 checkNextAddress() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt index a50e93b3..734289a7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt @@ -5,7 +5,6 @@ import android.app.Activity import android.app.AlertDialog import android.app.TimePickerDialog import android.content.Intent -import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.net.Uri @@ -42,10 +41,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.Calendar - class TicketsFragment( - var title: String = "", - var route: RouteInfo + var title: String = "", var route: RouteInfo ) : BaseFragment( DeliveryViewModel::class ) { @@ -75,28 +72,21 @@ class TicketsFragment( setEvents() setToolBar() binding.mainToolbar.toolbarTitle.text = route.name - callBack(viewModel.getTickets(route.id)) + viewModel.getTickets(route.id) db = database(requireContext().applicationContext) } private fun setTitle() { - binding.mainToolbar.toolbarSubtitle.text = - if (::myListClientTicket.isInitialized) { - myListClientTicket.filter { it.signed == 1 }.size.toString() + "/" + myListClientTicket.size - } else { - "0/0" - } + binding.mainToolbar.toolbarSubtitle.text = if (::myListClientTicket.isInitialized) { + myListClientTicket.filter { it.signed == 1 }.size.toString() + "/" + myListClientTicket.size + } else { + "0/0" + } customDialogList = CustomDialogList(requireContext()) } - private fun callBack(callBackEndPoint: Unit) { - binding.splashProgress.visibility = View.VISIBLE - return callBackEndPoint - } - - @RequiresApi(Build.VERSION_CODES.O) private fun setToolBar() { ma.hideBottomNavigation(View.GONE) @@ -105,14 +95,12 @@ class TicketsFragment( binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE - val listIcons: ArrayList = ArrayList() val iconSettings = ImageView(context) val iconSort = ImageView(context) val iconSigned = ImageView(context) val iconSend = ImageView(context) - iconSettings.setImageResource(R.drawable.ic_setting_ui) iconSort.setImageResource(R.drawable.ic_sort) iconSigned.setImageResource(R.drawable.ic_sign_ticket) @@ -130,7 +118,6 @@ class TicketsFragment( listIcons.add(iconSettings) listIcons.add(iconSort) - changeColorIcon(iconSigned.drawable, showSigned) changeColorIcon(iconSettings.drawable, showSigned) @@ -153,8 +140,7 @@ class TicketsFragment( ma.onPasillerosItemClickListener( PasillerosItemVO( title = getString(R.string.titleWebViewer), - ), - entryPoint = Gson().toJson( + ), entryPoint = Gson().toJson( mutableMapOf( "entryPoint" to route.id, "web" to "${getData("base_urlSalix")}#!/route/${route.id}/tickets" @@ -168,12 +154,11 @@ class TicketsFragment( showSigned = !showSigned if (::myListClientTicket.isInitialized) { - adapter!!.updateList( - if (showSigned) { - myListClientTicket.filter { it.signed == 1 } as MutableList - } else { - myListClientTicket.filter { it.signed == 0 } as MutableList - }) + adapter!!.updateList(if (showSigned) { + myListClientTicket.filter { it.signed == 1 } as MutableList + } else { + myListClientTicket.filter { it.signed == 0 } as MutableList + }) } changeColorIcon(iconSigned.drawable, showSigned) @@ -184,7 +169,7 @@ class TicketsFragment( if (myListClientTicket.isEmpty() || route.email.isNullOrEmpty()) { getString(R.string.routeNotTickets).toast(requireContext()) } else { - callBack(viewModel.driverRouteEmail(route.id, route.email!!)) + viewModel.driverRouteEmail(route.id, route.email!!) } } @@ -215,50 +200,12 @@ class TicketsFragment( override fun onResume() { super.onResume() if (isBack) { - callBack(viewModel.getTickets(route.id)) + viewModel.getTickets(route.id) isBack = false } } - private fun openAppDelivery(item: RouteInfo) { - val i = Intent() - val manager: PackageManager = requireContext().packageManager - val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - val version = info.versionName - try { - if (version.contains("Beta")) { - i.setClassName( - "verdnatura.es.repartoverdnatura.sfusion", - "verdnatura.es.repartoverdnatura.Tickets" - ) - } else { - i.setClassName( - "verdnatura.es.repartoverdnatura", - "verdnatura.es.repartoverdnatura.Tickets" - ) - } - i.putExtra("plate", item.numberPlate) - i.putExtra("id", item.id.toString()) - i.putExtra("agency", item.name) - i.putExtra("hour", item.hour) - i.putExtra("date", item.created.toString()) - i.putExtra("m3", item.m3.toString()) - i.putExtra("driver", item.driver) - i.putExtra("kmStart", item.kmStart.toString()) - i.putExtra("kmEnd", item.kmEnd.toString()) - i.putExtra("dEnd", item.finished) - i.putExtra("dStart", item.started) - i.putExtra("app", "picking") - startActivity(i) - } catch (e: Exception) { - getString(R.string.deliveryApp).toast(context) - } - - - } - - private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { if (!binding.itemcardLayout.isVisible) { @@ -279,7 +226,6 @@ class TicketsFragment( binding.hourEnd.setText(getHourDay(route.finished)) binding.saveButton.setOnClickListener { - binding.splashProgress.visibility = View.VISIBLE route.kmStart = binding.kmStart.text.toString().toLong() route.kmEnd = binding.kmEnd.text.toString().toLong() route.started = addDateToTime(binding.hourInit.text.toString()) @@ -302,43 +248,33 @@ class TicketsFragment( with(viewModel) { loadRouteList.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = View.GONE - // createListRoutes(it.list) + // createListRoutes(it.list) } } clientTicketList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (it.list.isNotEmpty()) { + println("llegan los tickets") createLisTickets(it.list) + }else{ + println("tickets vacios") } } - responseStateAdd.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - } + responseStateAdd.observe(viewLifecycleOwner) {} response.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (!it.isError){ - ma.messageWithSound(it.response,false,false,"",true) + if (!it.isError) { + ma.messageWithSound(it.response, false, false, "", true) } } responseUpdateRoute.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (it.isError) { - ma.messageWithSound(it.errorMessage, true, true, "", true) - } else { - showSigned = !showSigned - changeVisibleSettings(false) - setToolBar() - ma.messageWithSound("", false, true, "", false) - } - - + showSigned = !showSigned + changeVisibleSettings(false) + setToolBar() } responseLoadList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE + println("tickets responseLoadList") ma.messageWithSound(getString(R.string.offline), true, false, "", true) createLisTickets(mutableListOf(), getSaved = true) } @@ -346,7 +282,6 @@ class TicketsFragment( } private fun changeVisibleSettings(isVisible: Boolean) { - if (isVisible) { binding.itemcardLayout.visibility = View.GONE binding.ticketsRecyclerview.visibility = View.GONE @@ -366,9 +301,8 @@ class TicketsFragment( lifecycleScope.launch { withContext(Dispatchers.IO) { if (getSaved) { - myListClientTicketAux = db.clienTicketDao().getAll() - .filter { route.id == it.route } - .toMutableList() + myListClientTicketAux = + db.clienTicketDao().getAll().filter { route.id == it.route }.toMutableList() } else { myListClientTicketAux = list.distinctBy { it.addressFk } as MutableList @@ -403,27 +337,25 @@ class TicketsFragment( } else { myListClientTicket.filter { it.signed == 0 } } - adapter = TicketAdapter( - myListFiltered as MutableList, + adapter = TicketAdapter(myListFiltered as MutableList, object : OnItemButtonTicketRowClickListener { override fun onItemButtonTicketRowClickListener( - item: ClientTicketSalix, - action: String + item: ClientTicketSalix, action: String ) { when (action) { "unload" -> { val entryPoint = Gson().toJson( mutableMapOf( - "route" to route.id.toString(), - "address" to item.addressFk + "route" to route.id.toString(), "address" to item.addressFk ) ) - ma.onPasillerosItemClickListener( - PasillerosItemVO(title = getString(R.string.titleUnLoadTruck)), - entryPoint, myListClientTicket.filter { it.id == item.id } - ) + ma.onPasillerosItemClickListener(PasillerosItemVO( + title = getString( + R.string.titleUnLoadTruck + ) + ), entryPoint, myListClientTicket.filter { it.id == item.id }) } @@ -447,7 +379,8 @@ class TicketsFragment( } - }, object : OnItemButtonCMRRowClickListener { + }, + object : OnItemButtonCMRRowClickListener { override fun onItemButtonCMRRowClickListener( item: Ticket ) { @@ -455,8 +388,7 @@ class TicketsFragment( ma.onPasillerosItemClickListener( PasillerosItemVO( title = getString(R.string.titleWebViewer), - ), - entryPoint = Gson().toJson( + ), entryPoint = Gson().toJson( mutableMapOf( "entryPoint" to route.id, "web" to "${getData("base_urlSalix")}/api/Routes/${item.cmrFk}/cmr?access_token=${ @@ -468,8 +400,7 @@ class TicketsFragment( ) ) } - } - ) + }) binding.ticketsRecyclerview.addItemDecoration( ItemDescorationCustomized( @@ -514,14 +445,12 @@ class TicketsFragment( customDialogInput.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) customDialogInput.setOkButton(getString(R.string.save)) { - binding.splashProgress.visibility = View.VISIBLE viewModel.addNotes(itemClient.tickets, customDialogInput.getValue()) customDialogInput.dismiss() + }.setKoButton(getString(R.string.cancel)) { + customDialogInput.cancel() + customDialogInput.dismiss() } - .setKoButton(getString(R.string.cancel)) { - customDialogInput.cancel() - customDialogInput.dismiss() - } customDialogInput.show() } @@ -538,7 +467,6 @@ class TicketsFragment( } - private fun setListPosition(list: MutableList) { for (i in list.indices) { binding.ticketsRecyclerview.scrollToPosition(i) @@ -549,97 +477,73 @@ class TicketsFragment( fun showPhones(clientClicked: ClientTicketSalix) { val phones: MutableList = mutableListOf() //Tarea 6275 - if (clientClicked.clientPhone!=null){ + if (!clientClicked.clientPhone.isNullOrBlank()) { phones.add( GeneralItem( text = "${getString(R.string.Cliente)}:${clientClicked.clientPhone}", - code =clientClicked.clientMobile.toString() - )) + code = clientClicked.clientMobile.toString() + ) + ) } - if (clientClicked.clientMobile!=null){ + if (!clientClicked.clientMobile.isNullOrBlank()) { phones.add( GeneralItem( text = "${getString(R.string.Cliente)}:${clientClicked.clientMobile}", - code =clientClicked.clientMobile.toString() - )) + code = clientClicked.clientMobile.toString() + ) + ) } - if (clientClicked.addressPhone!=null){ + if (!clientClicked.addressPhone.isNullOrBlank()) { phones.add( GeneralItem( text = "${getString(R.string.Cliente)}:${clientClicked.addressPhone}", - code =clientClicked.addressPhone.toString() - )) - } - if (!clientClicked.salePersonPhone.isNullOrEmpty()) - phones.add( - GeneralItem( - text = "${getString(R.string.comercial)}:${clientClicked.salePersonPhone}", - code = - clientClicked.salePersonPhone.toString() + code = clientClicked.addressPhone.toString() ) ) - - /* if (clientClicked.Phones != null && clientClicked.Phones!!.isNotEmpty()) { - for (t in clientClicked.Phones!!) { - phones.add( - GeneralItem( - text = "${getString(R.string.Cliente)}:$t", - code = t - ) - ) - } } + if (!clientClicked.salePersonPhone.isNullOrBlank()) phones.add( + GeneralItem( + text = "${getString(R.string.comercial)}:${clientClicked.salePersonPhone}", + code = clientClicked.salePersonPhone.toString() + ) + ) - if (!clientClicked.SalePersonPhone.isNullOrEmpty()) - phones.add( - GeneralItem( - text = "${getString(R.string.comercial)}:${clientClicked.SalePersonPhone}", - code = - clientClicked.SalePersonPhone.toString() - ) - )*/ customDialogList.setValueVisibility(View.GONE) - customDialogList.setTitle(getString(R.string.phones)) - .setKoButton( - getString( - R.string.cancel - ) - ) { - customDialogList.dismiss() - }.hideDialog().show() + customDialogList.setTitle(getString(R.string.phones)).setKoButton( + getString( + R.string.cancel + ) + ) { + customDialogList.dismiss() + }.hideDialog().show() + val listPhonesAdapter = GeneralAdapter(phones, object : OnGeneralItemRowClickListener { + override fun OnGeneralItemRowClickListener(item: GeneralItem) { + phones.forEach { + if (it.code == item.code) { + if (ContextCompat.checkSelfPermission( + requireContext(), Manifest.permission.CALL_PHONE + ) == PackageManager.PERMISSION_GRANTED + ) { - val listPhonesAdapter = - GeneralAdapter(phones, object : OnGeneralItemRowClickListener { - override fun OnGeneralItemRowClickListener(item: GeneralItem) { - phones.forEach { - if (it.code == item.code) { - if (ContextCompat.checkSelfPermission( - requireContext(), - Manifest.permission.CALL_PHONE - ) == PackageManager.PERMISSION_GRANTED - ) { - - val callIntent = Intent(Intent.ACTION_CALL) - callIntent.data = Uri.parse("tel:${it.code}") - startActivity(callIntent) - } - } else { - ActivityCompat.requestPermissions( - context as Activity, - arrayOf(Manifest.permission.CALL_PHONE), - REQUEST_CALL_PERMISSION - ) + val callIntent = Intent(Intent.ACTION_CALL) + callIntent.data = Uri.parse("tel:${it.code}") + startActivity(callIntent) } - customDialogList.dismiss() + } else { + ActivityCompat.requestPermissions( + context as Activity, + arrayOf(Manifest.permission.CALL_PHONE), + REQUEST_CALL_PERMISSION + ) } + customDialogList.dismiss() } + } - - }) + }) customDialogList.getRecyclerView().adapter = listPhonesAdapter - customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) @@ -647,57 +551,14 @@ class TicketsFragment( fun goMaps(item: ClientTicketSalix) { - if (isGoogleMapsInstalled()) { - - val uri: String - if (item.latitude != null) { - uri = "geo:${item.latitude},${item.longitude}?q=" + item.nickname + - " " + item.street + - " " + item.city + - " " + item.postalCode - - } else { - uri = "geo:0,0?q=" + item.nickname + - " " + item.street + - " " + item.city + - " " + item.postalCode - } - val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) - startActivity(locationIntent) - + val uri: String = if (item.latitude != null) { + "geo:${item.latitude},${item.longitude}?q=" + item.nickname + " " + item.street + " " + item.city + " " + item.postalCode } else { - val builder = AlertDialog.Builder(requireContext()) - builder.setMessage("Instalar Maps de Google") - builder.setCancelable(false) - builder.setPositiveButton( - "Install" - ) { _, _ -> - val intent = Intent( - Intent.ACTION_VIEW, - Uri.parse("market://details?id=com.google.android.apps.maps") - ) - startActivity(intent) - } - val dialog = builder.create() - dialog.show() + "geo:0,0?q=" + item.nickname + " " + item.street + " " + item.city + " " + item.postalCode } - - } - - private fun isGoogleMapsInstalled(): Boolean { - - return true - /*val packageManager = mobileApplication.packageManager - try { - packageManager.getApplicationInfo( - "com.google.android.apps.maps", - PackageManager.GET_ACTIVITIES - ) - return true - } catch (e: PackageManager.NameNotFoundException) { - return false - }*/ + val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) + startActivity(locationIntent) } @@ -706,7 +567,6 @@ class TicketsFragment( val mcurrentTime = Calendar.getInstance() val hour = mcurrentTime[Calendar.HOUR_OF_DAY] val minute = mcurrentTime[Calendar.MINUTE] - val mTimePicker = TimePickerDialog( requireContext(), { _, selectedHour, selectedMinute -> textV.text = "$selectedHour:$selectedMinute" }, @@ -718,11 +578,4 @@ class TicketsFragment( mTimePicker.show() } -} - -data class PhonesTicket( - var label: String, - var phone: String -) - - +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt index cda53256..05574dfb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt @@ -51,10 +51,10 @@ data class ClientTicketSalix( var warehouseName: String?, var salePersonPhone: String?, var ticketObservation: String?, - var clientPhone: Int?, - var clientMobile: Int?, - var addressPhone: Int?, - var addressMobile: Int?, + var clientPhone: String?, + var clientMobile: String?, + var addressPhone: String?, + var addressMobile: String?, var signed: Int, var latitude: Double?, var longitude: Double?, @@ -84,4 +84,3 @@ data class SignedTickets( @PrimaryKey val fileName: String ) - diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt index 2736d913..143cfb13 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt @@ -4,7 +4,6 @@ import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations -import es.verdnatura.R import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.domain.formatWithQuotes @@ -95,10 +94,6 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { _companyInfoList.value = response.body()?.let { FreeLanceDeliveryInfoList(it) } } - override fun onError(t: Throwable) { - _companyInfoList.value = FreeLanceDeliveryInfoList() - super.onError(t) - } }) } @@ -107,24 +102,12 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { ) { salix.getExpeditionStates( """{"where": {"expeditionFk": $expedition},"include": [{"relation": "expeditionStateType","scope": {"fields": ["id","description"]}}],"fields": {"id": true,"created": true,"typeFk": true}}""" - ) - // silex.expedition_getLog(expedition) - .enqueue(object : SalixCallback>(context) { + ).enqueue(object : SalixCallback>(context) { + override fun onSuccess(response: Response>) { + _expeditionInfoList.value = response.body()?.let { ExpeditionInfoList(it) } + } - override fun onSuccess(response: Response>) { - if (response.body() != null) { - _expeditionInfoList.value = response.body()?.let { ExpeditionInfoList(it) } - } else { - _expeditionInfoList.value = ExpeditionInfoList() - } - } - - override fun onError(t: Throwable) { - _expeditionInfoList.value = ExpeditionInfoList() - super.onError(t) - - } - }) + }) } fun getExpeditionFromRoute( @@ -237,20 +220,20 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { fun expeditionStateAddSalix(expeditions: Any) { salix.addExpeditionState(expeditions).enqueue(object : SalixCallback(context) { - override fun onSuccess(response: Response) { - _responseStateAdd.value = ResponseItemVO("", false, "", 0) - } + override fun onSuccess(response: Response) { + _responseStateAdd.value = ResponseItemVO("", false, "", 0) + } - override fun onError(t: Throwable) { - super.onError(t) - _responseStateAdd.value = ResponseItemVO() - } + override fun onError(t: Throwable) { + super.onError(t) + _responseStateAdd.value = ResponseItemVO() + } - override fun onFailure(call: Call, t: Throwable) { - _responseStateAdd.value = ResponseItemVO("", true, t.message.toString(), 0) + override fun onFailure(call: Call, t: Throwable) { + _responseStateAdd.value = ResponseItemVO("", true, t.message.toString(), 0) - } - }) + } + }) } fun getInfoFreelance( @@ -259,27 +242,20 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { salix.freelanceGetInfo(arrayListOf(userId)) .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { - if (response.body() != null) { - _freelanceInfoList.value = - response.body()?.let { FreeLanceDeliveryInfoList(it) } - } else { - _freelanceInfoList.value = FreeLanceDeliveryInfoList() - } + + _freelanceInfoList.value = + response.body()?.let { FreeLanceDeliveryInfoList(it) } + } - override fun onError(t: Throwable) { - _freelanceInfoList.value = FreeLanceDeliveryInfoList() - super.onError(t) - } }) } - fun route_getExpeditionSummary( + fun routeGetExpeditionSummary( route: Int ) { //Tarea 6275 salix.routeGetExpeditionSummary(route) - // silex.route_getExpeditionSummary(route) .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { @@ -301,42 +277,45 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { } fun getRoutes( - workerFk: Int ) { - //Redmine 6028 falta que le pongan el email y PR - salix.getRoutes() - // silex.getRoutes(workerFk) - .enqueue(object : SalixCallback>(context) { - override fun onSuccess(response: Response>) { + salix.getRoutes().enqueue(object : SalixCallback>(context) { - if (response.body() != null) { - _routeList.value = response.body()?.let { RouteList(it) } - } else { - _routeList.value = RouteList() - } - } + override fun onSuccess(response: Response>) { + println() + _routeList.value = response.body()?.let { RouteList(it) } + } - override fun onError(t: Throwable) { - //_routeList.value = RouteList() - _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) - //super.onError(t) + override fun onError(t: Throwable) { + //_routeList.value = RouteList() + _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) + //super.onError(t) - } - }) + } + + override fun onFailure(call: Call>, t: Throwable) { + _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) + } + }) } fun getTickets( routeId: Long ) { - salix.getTickets("""{"id":$routeId,"order":["priority","id"]}""") + salix.getTickets("""{"id":$routeId,"order":["priority","id"],"limit":1}""") .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { + println("ticketsss entrando") + for (list in response.body()!!){ + println("ticketsss ${list.clientFk}") + } _clientTicketList.value = response.body()?.let { ClientTicketList(it) } } override fun onError(t: Throwable) { - _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) + println("ticketsss fallando") + println("tickets fallando ${t.message}") + _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) } }) @@ -346,55 +325,26 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { routeId: Long, email: String ) { salix.driverRouteEmail(id = routeId, hashMapOf("recipient" to email)) - .enqueue(object : SilexCallback(context) { - override fun onSuccess(response: Response) { - - _response.value = ResponseItemVO(context.getString(R.string.sendRouteOk)) - } - - override fun onError(t: Throwable) { - _response.value = ResponseItemVO() - super.onError(t) - - } - }) + .enqueue(object : SalixCallback(context) {}) } - /* fun addNote( - ticketFk: Int - ) { - silex.addNotes(ticketFk) - .enqueue(object : SilexCallback(context) { - - override fun onSuccess(response: Response) { - _responseStateAdd.value = ResponseItemVO() - - } - - override fun onError(t: Throwable) { - _responseStateAdd.value = ResponseItemVO() - super.onError(t) - - } - }) - }*/ - fun routeUpdate( route: RouteInfo ) { - salix.routeUpdate(route.id, route).enqueue(object : SilexCallback(context) { + salix.routeUpdate(route.id, route).enqueue(object : SalixCallback(context) { - override fun onSuccess(response: Response) { - _responseUpdateRoute.value = ResponseItemVO() + override fun onSuccess(response: Response) { + _responseUpdateRoute.value = ResponseItemVO() + super.onSuccess(response) - } + } - override fun onError(t: Throwable) { - _responseUpdateRoute.value = ResponseItemVO() - super.onError(t) + override fun onError(t: Throwable) { + _responseUpdateRoute.value = ResponseItemVO() + super.onError(t) - } - }) + } + }) } fun addNotes( @@ -403,22 +353,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { ) { salix.addNote( arrayListOf(listTickets[0].Id, note).formatWithQuotes() - )/* silex.addNotes( - mapOf( - "Tickets" to listTickets.map { it.Id }, - "note" to note - ) - )*/.enqueue(object : SalixCallback(context) { - override fun onSuccess(response: Response) { - _response.value = - ResponseItemVO(response = context.getString(R.string.noteAddOk)) - } - - override fun onError(t: Throwable) { - _response.value = ResponseItemVO() - super.onError(t) - } - }) + ).enqueue(object : SalixCallback(context) {}) } fun imageUpload( @@ -442,26 +377,25 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { ) salix.saveSign(filePart, mapQuery).enqueue(object : SalixCallback(context) { - override fun onSuccess(response: Response) { - _responseSign.value = ResponseItemVO(filePath, false, "", 0) + override fun onSuccess(response: Response) { + _responseSign.value = ResponseItemVO(filePath, false, "", 0) - } + } - //Otro fallo - override fun onError(t: Throwable) { - _responseSign.value = ResponseItemVO( - "", true, "Tickets:" + File(filePath).name + "→" + t.message.toString(), 0 - ) - // super.onError(t) - } + //Otro fallo + override fun onError(t: Throwable) { + _responseSign.value = ResponseItemVO( + "", true, "Tickets:" + File(filePath).name + "→" + t.message.toString(), 0 + ) + // super.onError(t) + } - //Fallo de red - override fun onFailure(call: Call, t: Throwable) { - _responseSign.value = - ResponseItemVO("NetWork Error", true, t.message.toString(), 0) - } + //Fallo de red + override fun onFailure(call: Call, t: Throwable) { + _responseSign.value = ResponseItemVO("NetWork Error", true, t.message.toString(), 0) + } - }) + }) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt index eb2d5861..8a4d7771 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt @@ -29,7 +29,6 @@ class CmrExpeditionPalletFragment( customDialogList = CustomDialogInputTwoValues(requireContext()) ma.hideBottomNavigation(View.GONE) - binding.splashProgress.visibility = View.GONE setEvents() setToolBar() showExpeditionPalletScan() @@ -43,10 +42,8 @@ class CmrExpeditionPalletFragment( private fun cmrExpeditionPallet_add(vExpeditionPallet: Int?, vCmrId: Int?) { customDialogList.dismiss() - binding.splashProgress.visibility = View.VISIBLE viewModel.cmrExpeditionPalletAdd( - vExpeditionPallet!!, - vCmrId!! + vExpeditionPallet!!, vCmrId!! ) } @@ -63,29 +60,9 @@ class CmrExpeditionPalletFragment( override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = View.GONE + responsescan.observe(viewLifecycleOwner) { - - if (it.isError) { - - ma.messageWithSound( - getString(R.string.cmrError) + it.errorMessage, - isError = true, - isPlayed = true, - isToasted = true - ) - showExpeditionPalletScan() - - } else { - binding.splashProgress.visibility = View.GONE - ma.messageWithSound( - getString(R.string.operationSuccess), - isError = false, - isPlayed = true - ) - showExpeditionPalletScan() - - } + showExpeditionPalletScan() } } @@ -110,12 +87,12 @@ class CmrExpeditionPalletFragment( customDialogList.setFocusText() ma.hideKeyboard(customDialogList.getEditText()) customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (customDialogList.getValue().isNotEmpty()) { dataScanned = itemScan(customDialogList.getValue()) if (dataScanned != null) { - + customDialogList.setValue(dataScanned!!.id.toString()) customDialogList.setHint(true) if (dataScanned!!.table == "cmr") { @@ -134,7 +111,7 @@ class CmrExpeditionPalletFragment( } customDialogList.getEditTextTwo().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (customDialogList.getValueTwo().isNotEmpty() && customDialogList.getValue() .isNotEmpty() @@ -149,7 +126,6 @@ class CmrExpeditionPalletFragment( } else { if (dataScanned != null) { - if (dataScanned!!.table == dataScannedTwo!!.table) { ma.messageWithSound( getString(R.string.errorSameType), @@ -166,8 +142,7 @@ class CmrExpeditionPalletFragment( dataScanned!!.id } else { dataScannedTwo!!.id - }, - if (dataScannedTwo!!.table == "cmr") { + }, if (dataScannedTwo!!.table == "cmr") { dataScannedTwo!!.id } else { dataScanned!!.id @@ -176,8 +151,7 @@ class CmrExpeditionPalletFragment( } } else { cmrExpeditionPallet_add( - customDialogList.getValue().toInt(), - dataScannedTwo!!.id + customDialogList.getValue().toInt(), dataScannedTwo!!.id ) } @@ -203,9 +177,8 @@ private fun itemScan(value: String): ItemScanned? { null } - } catch (Ex: Exception) { + } catch (ex: Exception) { return null } - } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletViewModel.kt index 9761d915..728ba0c0 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletViewModel.kt @@ -22,6 +22,7 @@ class CmrExpeditionPalletViewModel(val context: Context) : BaseViewModel(context override fun onSuccess(response: Response) { _responsescan.value = ResponseItemVO(isError = false, response = response.message()!!) + super.onSuccess(response) } override fun onError(t: Throwable) { @@ -29,6 +30,7 @@ class CmrExpeditionPalletViewModel(val context: Context) : BaseViewModel(context isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) ) + super.onError(t) } }) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt index e3a09d09..89a5aa8a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment import android.view.View.GONE -import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R @@ -12,7 +11,6 @@ import es.verdnatura.presentation.common.GeneralItem import es.verdnatura.presentation.common.OnGeneralItemRowClickListener import es.verdnatura.presentation.view.component.CustomDialogList - class ExpeditionScanSorterFragment( var title: String = "" ) : BaseFragment( @@ -33,8 +31,6 @@ class ExpeditionScanSorterFragment( customDialogList = CustomDialogList(requireContext()) ma.hideBottomNavigation(GONE) - binding.splashProgress.visibility = GONE - setEvents() setToolBar() showExpeditionScan() @@ -45,43 +41,24 @@ class ExpeditionScanSorterFragment( binding.mainToolbar.toolbarTitle.text = title } - private fun expeditionscan(expeditionScan: String) { - - binding.splashProgress.visibility = VISIBLE - viewModel.expeditionScan(expeditionScan) - itemScaned = expeditionScan - - } - private fun setEvents() { - binding.mainToolbar.backButton.setOnClickListener { + binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() } - } override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = GONE - responsescan.observe(viewLifecycleOwner, { + responsescan.observe(viewLifecycleOwner) { + listExpeditionScan.add(GeneralItem(itemScaned, itemScaned)) + customDialogList.setDescription(getString(R.string.total) + ":" + listExpeditionScan.size) + expeditionScanAdapter!!.notifyItemInserted(listExpeditionScan.size - 1) + customDialogList.setValue("") - if (it.isError) { - - ma.messageWithSound(it.errorMessage,true,false) - - } else { - - listExpeditionScan.add(GeneralItem(itemScaned, itemScaned)) - customDialogList.setDescription(getString(R.string.total) + listExpeditionScan.size) - expeditionScanAdapter!!.notifyItemInserted(listExpeditionScan.size-1) - customDialogList.setValue("") - ma.messageWithSound(getString(R.string.added),false,true) - - } - }) + } } @@ -91,22 +68,19 @@ class ExpeditionScanSorterFragment( customDialogList.setTitle(getString(R.string.expeditionNoSorter)) .setOkButton(getString(R.string.end)) { - ma.hideKeyboard(customDialogList.getEditText()) customDialogList.dismiss() binding.mainToolbar.backButton.performClick() - - }.setValue("").show() customDialogList.getEditText().requestFocus() ma.hideKeyboard(customDialogList.getEditText()) - customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (customDialogList.getValue().isNotEmpty()) { - expeditionscan(customDialogList.getValue()) + viewModel.expeditionScan(customDialogList.getValue()) + itemScaned = customDialogList.getValue() } customDialogList.setValue("") ma.hideKeyboard(customDialogList.getEditText()) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt index 75cf1821..88e9231c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt @@ -5,8 +5,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData 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.ResponseItemVO import retrofit2.Response @@ -20,26 +18,10 @@ class ExpeditionScanSorterViewModel(val context: Context) : BaseViewModel(contex salix.expeditionScan(params = arrayListOf(vExpeditionId)) .enqueue(object : SalixCallback(context) { override fun onSuccess(response: Response) { - if (!response.isSuccessful) { - _responsescan.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - response.message() - ) - ) - } else { - _responsescan.value = - ResponseItemVO(isError = false, response = response.message()!!) - } - } - - override fun onError(t: Throwable) { - _responsescan.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) + _responsescan.value = + ResponseItemVO(isError = false, response = response.message()!!) + super.onSuccess(response) } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanFragment.kt index 061ec761..b1c23b44 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanFragment.kt @@ -2,7 +2,6 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment import android.view.View import android.view.inputmethod.EditorInfo -import androidx.core.view.isVisible import es.verdnatura.R import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.domain.toast @@ -22,7 +21,6 @@ class PalletScanFragment( private var itemScaned: Int = 0 private var isShowed = false - companion object { fun newInstance(title: String, action: String) = PalletScanFragment(title, action) } @@ -48,57 +46,37 @@ class PalletScanFragment( requireActivity().onBackPressed() } + customDialogList.setOnDismissListener { - if (!binding.splashProgress.isVisible) - requireActivity().onBackPressed() + customDialogList.dismiss() } } override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = View.GONE responseScan.observe(viewLifecycleOwner) { - if (it.isError) { ma.messageWithSound( - it.errorMessage, - true, - true, - isToasted = true + it.errorMessage, true, true, isToasted = true ) showPalletScan() } else { - binding.splashProgress.visibility = View.GONE ma.messageWithSound(getString(R.string.palletScanned) + itemScaned, false, true) showPalletScan() } } responsePalletGet.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (it.isError) { - ma.messageWithSound( - it.errorMessage, - true, - true, - isToasted = true - ) - showPalletScan() + ma.messageWithSound(getString(R.string.palletScanned) + itemScaned, false, true) + ma.onComprobarPalletFromPalletScan( + it, ItemPalletVO(Pallet = itemScaned) + ) + customDialogList.dismiss() - } else { - binding.splashProgress.visibility = View.GONE - ma.messageWithSound(getString(R.string.palletScanned) + itemScaned, false, true) - - ma.onComprobarPalletFromPalletScan( - it, - ItemPalletVO(Pallet = itemScaned.toInt()) - ) - - } } } @@ -116,8 +94,8 @@ class PalletScanFragment( customDialogList.setOkButton(getString(R.string.end)) { - ma.hideKeyboard(customDialogList.getEditText()) customDialogList.dismiss() + ma.onBackPressed() }.setValue("").show() @@ -125,14 +103,11 @@ class PalletScanFragment( ma.hideKeyboard(customDialogList.getEditText()) customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - if (customDialogList.getValue().isNotEmpty() - ) { + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (customDialogList.getValue().isNotEmpty()) { try { itemScaned = itemScanValue( - customDialogList.getValue(), - "expeditionPallet", - "id" + customDialogList.getValue(), "expeditionPallet", "id" ).toString().toInt() } catch (ex: Exception) { @@ -142,18 +117,16 @@ class PalletScanFragment( ma.hideKeyboard(customDialogList.getEditText()) when (action) { - "receive" -> viewModel.expeditionState_addByPallet( - itemScaned, - "STORED" + "receive" -> viewModel.expeditionStateAddByPallet( + itemScaned, "STORED" ) - "get" -> viewModel.expeditionPallet_get( + "get" -> viewModel.expeditionPalletGet( itemScaned ) } - customDialogList.dismiss() - binding.splashProgress.visibility = View.VISIBLE customDialogList.setValue("") + } return@setOnEditorActionListener true diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanViewModel.kt index 7bde04c1..3d5496f1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/PalletScanViewModel.kt @@ -13,10 +13,8 @@ import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO import retrofit2.Response - class PalletScanViewModel(val context: Context) : BaseViewModel(context) { - private val _responseScan by lazy { MutableLiveData() } val responseScan: LiveData get() = _responseScan @@ -25,14 +23,15 @@ class PalletScanViewModel(val context: Context) : BaseViewModel(context) { val responsePalletGet: LiveData get() = _responsePalletGet - - fun expeditionState_addByPallet( + fun expeditionStateAddByPallet( vPalletId: Int, vStatePallet: String ) { - salix.expeditionStateAddByPallet(arrayListOf( - vPalletId, - vStatePallet).formatWithQuotes() + salix.expeditionStateAddByPallet( + arrayListOf( + vPalletId, + vStatePallet + ).formatWithQuotes() ) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -52,22 +51,14 @@ class PalletScanViewModel(val context: Context) : BaseViewModel(context) { }) } - fun expeditionPallet_get(vPalletId: Int) { + fun expeditionPalletGet(vPalletId: Int) { //Tarea 6276 //salix.expeditionPalletGetPallet(vPalletId) + silex.expeditionPallet_get(vPalletId) .enqueue(object : SalixCallback(context) { - override fun onError(t: Throwable) { - - _responsePalletGet.value = ItemExpeditionTruckVO( - 0, - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } override fun onSuccess(response: Response) { - _responsePalletGet.value = response.body()!! diff --git a/app/src/main/res/layout/fragment_buffer.xml b/app/src/main/res/layout/fragment_buffer.xml index 90c46691..2a050f43 100644 --- a/app/src/main/res/layout/fragment_buffer.xml +++ b/app/src/main/res/layout/fragment_buffer.xml @@ -7,21 +7,17 @@ android:layout_height="match_parent" android:background="@color/verdnatura_black"> - - - - - + - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_buffer_loadexpedition.xml b/app/src/main/res/layout/fragment_buffer_loadexpedition.xml index 13a8df7d..56977c07 100644 --- a/app/src/main/res/layout/fragment_buffer_loadexpedition.xml +++ b/app/src/main/res/layout/fragment_buffer_loadexpedition.xml @@ -2,41 +2,17 @@ - - ' - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_expedition_loadunload_delivery.xml b/app/src/main/res/layout/fragment_expedition_loadunload_delivery.xml index 5df298e3..1876eaab 100644 --- a/app/src/main/res/layout/fragment_expedition_loadunload_delivery.xml +++ b/app/src/main/res/layout/fragment_expedition_loadunload_delivery.xml @@ -1,7 +1,7 @@ - + + app:layout_constraintTop_toTopOf="parent"> - - + app:layout_constraintTop_toTopOf="@+id/main_toolbar" /> + + android:text="@string/expedition" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body1" /> - + android:textSize="@dimen/body1" /> + android:gravity="end" + android:text="@string/consignatario" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body1" /> + - + - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_expedition_log_delivery.xml b/app/src/main/res/layout/fragment_expedition_log_delivery.xml index 53662e37..c957a3fd 100644 --- a/app/src/main/res/layout/fragment_expedition_log_delivery.xml +++ b/app/src/main/res/layout/fragment_expedition_log_delivery.xml @@ -1,7 +1,7 @@ - + + android:orientation="vertical"> + + - + + android:gravity="left" + android:paddingLeft="@dimen/layout_margin_min" + android:text="@string/Ruta" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body1" /> - + android:gravity="left" + android:text="@string/zone" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body2" /> + android:text="@string/Fecha" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body2" /> + + + android:gravity="left" + android:paddingLeft="@dimen/layout_margin_min" + android:text="@string/Fecha" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body2" /> + android:textSize="@dimen/body2" /> - + android:gravity="right" + android:text="@string/state" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body2" /> + - - > + - ' - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_expedition_summary.xml b/app/src/main/res/layout/fragment_expedition_summary.xml index 9c97e79c..c2461214 100644 --- a/app/src/main/res/layout/fragment_expedition_summary.xml +++ b/app/src/main/res/layout/fragment_expedition_summary.xml @@ -1,147 +1,145 @@ - + + - - /> + - + + + + + + + + + + + + + + + + + + + + + android:descendantFocusability="blocksDescendants"> - - - - - - - - - - - - - - - - - - - - - - - - - + android:clipToPadding="false" + android:visibility="visible" + tools:listitem="@layout/item_expedition_summary_row" /> + + - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_expeditionscan_sorter.xml b/app/src/main/res/layout/fragment_expeditionscan_sorter.xml index 64202a81..8db34f78 100644 --- a/app/src/main/res/layout/fragment_expeditionscan_sorter.xml +++ b/app/src/main/res/layout/fragment_expeditionscan_sorter.xml @@ -1,14 +1,14 @@ - + - ' @@ -35,8 +35,8 @@ android:layout_marginStart="50dp" android:layout_marginTop="75dp" android:layout_marginEnd="50dp" - android:gravity="center_horizontal" android:backgroundTint="@color/colorPrimary" + android:gravity="center_horizontal" android:hint="@string/ScanPlateOrSmarttag" android:inputType="text" android:lines="1" @@ -48,13 +48,13 @@ @@ -62,20 +62,19 @@ + android:textDirection="firstStrong" + android:visibility="invisible" />