From fe98c3f9fbcb2874854ef86698f82e4b7a222ca8 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 14 Dec 2023 16:50:30 +0100 Subject: [PATCH] refs #5135 --- app/beta/release/output-metadata.json | 2 +- .../java/es/verdnatura/MobileApplication.kt | 51 +++- .../es/verdnatura/domain/ApiSalixUtils.kt | 8 +- .../java/es/verdnatura/domain/RestClient.kt | 5 +- .../es/verdnatura/domain/SalixCallback.kt | 7 +- .../es/verdnatura/domain/SalixInterceptor.kt | 27 ++- .../java/es/verdnatura/domain/SalixService.kt | 7 +- .../es/verdnatura/domain/SilexInterceptor.kt | 30 ++- .../presentation/common/UICallbacks.kt | 7 +- .../buscaritem/fragment/BuscarItemFragment.kt | 44 ++-- .../fragment/BuscarItemViewModel.kt | 26 +- .../fragment/CollectionFragmentPickerNew.kt | 227 ++++++------------ .../fragment/HistoricoArticuloViewModel.kt | 2 +- .../model/ItemHistoricoVO.kt | 14 +- .../feature/main/activity/MainActivity.kt | 7 +- .../fragment/ExpeditionStateFragment.kt | 45 ++-- .../fragment/ExpeditionStateViewModel.kt | 50 +--- .../fragment/ExpeditionTruckListViewModel.kt | 2 +- .../parking/fragment/ParkingFragment.kt | 30 +-- .../parking/fragment/ParkingViewModel.kt | 32 --- .../parkingSale/adapter/ParkingAdapter.kt | 43 ---- .../fragment/ParkingSaleFragment.kt | 153 ------------ .../parkingSale/fragment/ParkingViewModel.kt | 62 ----- app/src/main/res/layout/activity_main.xml | 22 ++ .../main/res/layout/fragment_buscar_item.xml | 106 +++----- .../fragment_itemexpeditionstate_card.xml | 76 ++---- app/src/main/res/layout/fragment_parking.xml | 61 ++--- 27 files changed, 349 insertions(+), 797 deletions(-) delete mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/adapter/ParkingAdapter.kt delete mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingSaleFragment.kt delete mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingViewModel.kt diff --git a/app/beta/release/output-metadata.json b/app/beta/release/output-metadata.json index 5f6018b5..6ec924a6 100644 --- a/app/beta/release/output-metadata.json +++ b/app/beta/release/output-metadata.json @@ -11,7 +11,7 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 242, + "versionCode": 245, "versionName": "23.48Beta", "outputFile": "app-beta-release.apk" } diff --git a/app/src/main/java/es/verdnatura/MobileApplication.kt b/app/src/main/java/es/verdnatura/MobileApplication.kt index bf207c53..0b10ee6d 100644 --- a/app/src/main/java/es/verdnatura/MobileApplication.kt +++ b/app/src/main/java/es/verdnatura/MobileApplication.kt @@ -2,32 +2,44 @@ package es.verdnatura import android.app.Application import android.content.SharedPreferences +import android.graphics.Color import android.media.MediaPlayer +import android.os.Handler +import android.os.Looper import es.verdnatura.di.viewModelModule import es.verdnatura.domain.RestClient import es.verdnatura.domain.SalixService import es.verdnatura.domain.VerdnaturaService +import es.verdnatura.domain.toast +import es.verdnatura.presentation.common.InteceptorListener +import es.verdnatura.presentation.common.MainActivityListener import es.verdnatura.presentation.view.component.CustomDialogMainActivity import org.koin.android.ext.koin.androidContext import org.koin.core.context.loadKoinModules import org.koin.core.context.startKoin -class MobileApplication : Application() { +class MobileApplication : Application(), InteceptorListener { + private lateinit var interceptoreListener: InteceptorListener + private var mainActivityListener: MainActivityListener? = null + fun setMainListener(listener: MainActivityListener) { + mainActivityListener = listener + } + lateinit var silex: VerdnaturaService lateinit var salix: SalixService var userId: Int? = null var userName: String? = null - var renewPeriod:Long = 0 - var renewInterval:Long = 0 + var renewPeriod: Long = 0 + var renewInterval: Long = 0 var userPassword: String? = null - var hasNetwork:Boolean = true - var serialNumber:String = "" - var versionName:String = "" - var androidId:String = "" + var hasNetwork: Boolean = true + var serialNumber: String = "" + var versionName: String = "" + var androidId: String = "" var mperror: MediaPlayer? = null var mpok: MediaPlayer? = null private lateinit var customDialog: CustomDialogMainActivity - + private val handler = Handler(Looper.getMainLooper()) protected val PREFS_USER = "es.verdnatura.user.prefs" @@ -41,7 +53,7 @@ class MobileApplication : Application() { loadKoinModules(moduleList) } - var restClient = RestClient(this) + var restClient = RestClient(this, this) silex = restClient.restClient salix = restClient.salixClient } @@ -50,6 +62,7 @@ class MobileApplication : Application() { val prefs: SharedPreferences = getSharedPreferences(PREFS_USER, 0) return prefs.edit() } + fun getPrefsShared(): SharedPreferences { return getSharedPreferences(PREFS_USER, 0) } @@ -58,4 +71,24 @@ class MobileApplication : Application() { if (bool) mpok!!.start() else mperror!!.start() } + fun messageToast(isError: Boolean, message:String) { + val playSound = when (isError) { + null -> null + false -> mpok + true -> mperror + } + playSound?.start() + message.toast(this,color = Color.RED) + } + + override fun onInterceptionResult(visibility: Int) { + if (mainActivityListener != null) { + handler.post { + val mainActivityListener = this.mainActivityListener + mainActivityListener?.onApplicationEventAnimation(visibility) + } + } + + } + } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/ApiSalixUtils.kt b/app/src/main/java/es/verdnatura/domain/ApiSalixUtils.kt index 60a9e9a3..79d97d4d 100644 --- a/app/src/main/java/es/verdnatura/domain/ApiSalixUtils.kt +++ b/app/src/main/java/es/verdnatura/domain/ApiSalixUtils.kt @@ -3,6 +3,7 @@ package es.verdnatura.domain import android.content.Context import androidx.preference.PreferenceManager import com.google.gson.GsonBuilder +import es.verdnatura.presentation.common.InteceptorListener import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -10,14 +11,12 @@ import java.util.concurrent.TimeUnit class ApiSalixUtils { companion object { - //const val BASE_URL:String = "http://192.168.1.155:9009/" - //const val BASE_URL: String = "https://test-salix.verdnatura.es/api/" const val BASE_URL: String = "https://salix.verdnatura.es" - fun getApiService(context: Context): SalixService { + fun getApiService(context: Context,myObserver: InteceptorListener?): SalixService { var salixClient = OkHttpClient.Builder() - .addInterceptor(SalixInterceptor(context)) + .addInterceptor(SalixInterceptor(context, myObserver)) .connectTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS) .readTimeout(40, TimeUnit.SECONDS) @@ -39,7 +38,6 @@ class ApiSalixUtils { GsonConverterFactory.create(GsonBuilder().serializeNulls().create() ) ).build() - //d("VERDNATURA::","El server Salix es "+getBaseUrlLocal(context = context)) return salixRetrofit.create(SalixService::class.java) } diff --git a/app/src/main/java/es/verdnatura/domain/RestClient.kt b/app/src/main/java/es/verdnatura/domain/RestClient.kt index e2354bc5..821d541b 100644 --- a/app/src/main/java/es/verdnatura/domain/RestClient.kt +++ b/app/src/main/java/es/verdnatura/domain/RestClient.kt @@ -1,13 +1,14 @@ package es.verdnatura.domain import android.content.Context +import es.verdnatura.presentation.common.InteceptorListener -open class RestClient(context: Context) { +open class RestClient(context: Context, myObserver: InteceptorListener? = null) { var restClient: VerdnaturaService var salixClient: SalixService init { restClient = ApiUtils.getApiService(context) - salixClient = ApiSalixUtils.getApiService(context) + salixClient = ApiSalixUtils.getApiService(context, myObserver) } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt index 00e9e4f1..a32ccad3 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import com.google.gson.Gson import com.google.gson.JsonObject +import es.verdnatura.MobileApplication import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.view.feature.login.activity.LoginActivity import org.json.JSONObject @@ -53,9 +54,9 @@ abstract class SalixCallback(val context: Context) : Callback { } private fun defaultErrorHandler(t: Throwable) { - println("ErrorSalixx${t.message}") - (nameofFunction((this)) + t.message).toast(context) - //(context as MobileApplication).playSoundIsOK(false) + //println("ErrorSalixx${t.message}") + // (nameofFunction((this)) + t.message).toast(context) + (context as MobileApplication).messageToast(true, (nameofFunction((this)) + t.message)) } open fun onSuccess(response: Response) { diff --git a/app/src/main/java/es/verdnatura/domain/SalixInterceptor.kt b/app/src/main/java/es/verdnatura/domain/SalixInterceptor.kt index ba38997a..0c56b375 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixInterceptor.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixInterceptor.kt @@ -2,24 +2,21 @@ package es.verdnatura.domain import android.content.Context import android.content.SharedPreferences -import android.util.Log.d +import android.view.View +import es.verdnatura.presentation.common.InteceptorListener import okhttp3.Interceptor import okhttp3.Response import java.io.IOException -class SalixInterceptor : Interceptor { - private var context: Context - - constructor(context: Context) { - this.context = context - } +class SalixInterceptor(private val context: Context, private val listener: InteceptorListener?) : + Interceptor { @Throws(IOException::class) - override fun intercept(chain: Interceptor.Chain, ): Response { + override fun intercept(chain: Interceptor.Chain): Response { val prefs: SharedPreferences = this.context.getSharedPreferences("es.verdnatura.user.prefs", 0) - val request = chain.request() + var request = chain.request() //sergio: condición para que añada o no headers según se vaya quitando de las llamadas //no quitar condición hasta que estén quitados if (request.headers().toString().isEmpty()) { @@ -27,10 +24,14 @@ class SalixInterceptor : Interceptor { .addHeader("Content-Type", "application/json") .addHeader("Authorization", prefs.getString("token", "")) .build() - - return chain.proceed(newRequest) - } else + request = newRequest + } + if (request.url().toString().contains("renew")){ return chain.proceed(request) - + }else{ + listener!!.onInterceptionResult(View.VISIBLE) + val response = chain.proceed(request) + listener!!.onInterceptionResult(View.INVISIBLE) + return response } } } diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index c4706f6e..ab124a3d 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -137,6 +137,11 @@ interface SalixService { @Query("params") params: Any? = null ): Call + @POST("Applications/itemShelvingSale_setQuantity/execute-proc") + fun itemShelvingSaleSetquantitySalix( + @Query("schema") schema: String = "vn", + @Query("params") params: Any? = null + ): Call @POST("Applications/collection_addWithReservation/execute-proc") fun collectionAddWithReservation( @Query("schema") schema: String = "vn", @@ -722,7 +727,7 @@ interface SalixService { ): Call @POST("ItemShelvingSales/itemShelvingSaleSetQuantity") - fun itemShelvingsConfirmRerserved( + fun itemShelvingSaleSetQuantity( @Body params: Any ): Call diff --git a/app/src/main/java/es/verdnatura/domain/SilexInterceptor.kt b/app/src/main/java/es/verdnatura/domain/SilexInterceptor.kt index 218757cb..7fa1690d 100644 --- a/app/src/main/java/es/verdnatura/domain/SilexInterceptor.kt +++ b/app/src/main/java/es/verdnatura/domain/SilexInterceptor.kt @@ -2,10 +2,7 @@ package es.verdnatura.domain import android.content.Context import android.content.SharedPreferences -import es.verdnatura.MobileApplication -import okhttp3.FormBody import okhttp3.Interceptor -import okhttp3.RequestBody import okhttp3.Response import java.io.IOException @@ -23,22 +20,37 @@ class SilexInterceptor : Interceptor { val prefs: SharedPreferences = this.context.getSharedPreferences("es.verdnatura.user.prefs", 0) val request = chain.request() - //sergio: condición para que añada o no headers según se vaya quitando de las llamadas - //no quitar condición hasta que estén quitados - //Tarea 5486 se añade Authorization, más adelante ver de quitar. + if (request.headers().toString().isEmpty()) { val newRequest = request.newBuilder() .addHeader("aplicacion", "json") .addHeader("version", "1") - // Tarea 5613 comentar user y pass cuando en Silex está subido - //.addHeader("user",(context as MobileApplication).userName) - //.addHeader("pass", (context as MobileApplication).userPassword) .addHeader("Authorization", prefs.getString("token", "")) .addHeader("Content-Type", "application/json") .build() // d("VERDNATURA::", newRequest.headers().toString() + newRequest.url()) + /* try { + (context as MainActivity).progressAnimation(View.VISIBLE) + println("print IN") + }catch (ex:Exception){}*/ + /* if (request != null) { + println("Es una solicitud: ${request.method()} ${request.url()}") + }else{ + val response = chain.proceed(request) + if (response != null) { + // Realizar acciones específicas para la respuesta + // Puedes acceder a response.code(), response.body(), etc. + println("Es una respuesta: ${response.code()} ${response.message()}") + } + }*/ + return chain.proceed(newRequest) } else + /* try { + (context as MainActivity).progressAnimation(View.INVISIBLE) + println("print OUT") + }catch (ex:Exception){}*/ + return chain.proceed(request) } diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt index 8093c824..28cc4dd6 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.common import android.graphics.drawable.Drawable -import android.widget.TextView import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO @@ -217,4 +216,10 @@ interface onVehicleSelected { interface OnClickDynamic { fun onClickDynamic(addressFK: Int) } +interface InteceptorListener { + fun onInterceptionResult(visibility: Int) +} +interface MainActivityListener { + fun onApplicationEventAnimation(visibility: Int) +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt index 2ceca268..654b96c4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt @@ -2,8 +2,6 @@ package es.verdnatura.presentation.view.feature.buscaritem.fragment import android.content.Context import android.os.Build -import android.view.View -import android.view.View.GONE import android.view.inputmethod.EditorInfo import androidx.annotation.RequiresApi import androidx.lifecycle.Observer @@ -73,7 +71,6 @@ class BuscarItemFragment( private fun getLocations(itemFk: Any) { this.itemFk = itemFk - binding.splashProgress.visibility = View.VISIBLE viewModel.itemshelvingGetInfo(itemFk) } @@ -82,34 +79,25 @@ class BuscarItemFragment( loadLocationList.observe(viewLifecycleOwner, Observer { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = GONE - if (it.list.isNotEmpty()) { - if (it.list[0].isError) { - ma.messageWithSound( - it.list[0].errorMessage, - true, - true, - it.list[0].errorMessage + try { + adapter = LocationAdapter(it.list, pasillerosItemClickListener!!) + binding.locationRecyclerview.adapter = adapter + binding.locationRecyclerview.layoutManager = + LinearLayoutManager( + requireContext(), + LinearLayoutManager.VERTICAL, + false ) - }else{ - adapter = LocationAdapter(it.list, pasillerosItemClickListener!!) - binding.locationRecyclerview.adapter = adapter - binding.locationRecyclerview.layoutManager = - LinearLayoutManager( - requireContext(), - LinearLayoutManager.VERTICAL, - false - ) - - var totalVisible = 0 - it.list.forEach { - totalVisible += it.visible - } - binding.mainToolbar.toolbarTitle.text = - getString(R.string.item) + itemFk + " " + getString(R.string.visibleTotal) + totalVisible - } + } catch (ex: Exception) { + ma.messageWithSound( + message = ex.message.toString(), + isError = true, + isPlayed = true + ) } + binding.mainToolbar.toolbarTitle.text = + getString(R.string.item) + itemFk + " " + getString(R.string.visibleTotal) + it.list.sumOf { it.visible } } }) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt index 4bfa7692..1cb8537f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt @@ -1,24 +1,18 @@ package es.verdnatura.presentation.view.feature.buscaritem.fragment import android.content.Context -import android.os.Build -import androidx.annotation.RequiresApi import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations -import es.verdnatura.domain.SilexCallback +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.Event import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO import retrofit2.Response class BuscarItemViewModel(val context: Context) : BaseViewModel(context) { - //private val getBuscarItemUserCase: GetBuscarItemUserCase = GetBuscarItemUserCase(context) - private val _locationList by lazy { MutableLiveData() } val locationList: LiveData get() = _locationList @@ -26,27 +20,13 @@ class BuscarItemViewModel(val context: Context) : BaseViewModel(context) { fun itemshelvingGetInfo(itemFk: Any) { //salix falla fecha - // silex.searchItemsUbicador(itemFk) + // silex.searchItemsUbicador(itemFk) salix.itemshelvingGetInfo(params = arrayListOf(itemFk).formatWithQuotes()) - .enqueue(object : SilexCallback>(context) { + .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { _locationList.value = response.body()?.let { LocationListVO(it) } } - @RequiresApi(Build.VERSION_CODES.O) - override fun onError(t: Throwable) { - val listError: ArrayList = ArrayList() - listError.add( - ItemLocationVO( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - t.message!! - ) - ) - ) - _locationList.value = LocationListVO(listError) - } }) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt index 109bacdf..7212c146 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt @@ -27,7 +27,7 @@ import es.verdnatura.databinding.FragmentCollectionNewBinding import es.verdnatura.domain.ConstAndValues.CONTROLADOR import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.toast -import es.verdnatura.presentation.base.BaseFragmentSalix +import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialogInput @@ -39,7 +39,6 @@ import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterNew import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.main.activity.MainActivity -import es.verdnatura.presentation.view.feature.modelViewModel.FragmentsViewModel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.sacador.model.* import org.json.JSONObject @@ -49,9 +48,8 @@ import org.json.JSONObject class CollectionFragmentPickerNew( var collection: CollectionTicket, var type: String = SACADOR -) : BaseFragmentSalix( - CollectionViewModel::class, - FragmentsViewModel::class +) : BaseFragment( + CollectionViewModel::class ) { private var sales: List = listOf() @@ -229,22 +227,8 @@ class CollectionFragmentPickerNew( if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}") - /* callBack( - viewModelSalix.callBackProcedSalix( - "itemShelvingSale_setQuantity", - params = arrayListOf( - sales[indice].itemShelvingSaleFk, - ) - ), splashProgress = binding.splashProgress - - )*/ - - callBack( - viewModelSalix.callBackProcedSalix( - "saleTracking_add", params = arrayListOf(saleGroupScanned) - ), splashProgress = binding.splashProgress - - ) + binding.splashProgress.visibility = View.VISIBLE + viewModel.saleTrackingAddPreparedSaleGroup(saleGroupScanned.toInt()) return true mpok!!.start() @@ -376,9 +360,7 @@ class CollectionFragmentPickerNew( @RequiresApi(Build.VERSION_CODES.O) override fun observeViewModel() { - - - with(viewModelSalix) { + /* with(viewModelSalix) { responseCallBack.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE @@ -423,15 +405,15 @@ class CollectionFragmentPickerNew( ) } } - /* if (!goBack) { + *//* if (!goBack) { ma.messageWithSound( if (it.isError) it.errorMessage else getString(R.string.savedShelves), it.isError, true ) - }*/ + }*//* }) - } + }*/ with(viewModel) { binding.splashProgress.visibility = View.GONE collectionTicketList.observe(viewLifecycleOwner, Observer { @@ -503,6 +485,27 @@ class CollectionFragmentPickerNew( }) + responseCollectionAddItem.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = View.GONE + + if (!goBack) { + binding.splashProgress.visibility = View.GONE + ma.messageWithSound( + "ítem y reserva añadida correctamente", + it.isError, !it.isError + ) + viewModel.collectionTicketGet( + collection.collectionFk, + getDataInt(SECTORFK), + print = "0", + type + ) + + goBack = false + } + + }) + responsePrint.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE @@ -522,45 +525,7 @@ class CollectionFragmentPickerNew( }) - /* responseSplit.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (!goBack) { - - if (it.isError) { - ma.messageWithSound( - it.errorMessage, - it.isError, true - ) - } else { - ma.messageWithSound( - getString(R.string.splitOk), - it.isError, true - ) - } - } - - } - */ - - /* responseItem_updatePackingShelve.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - ma.messageWithSound( - if (it.isError) it.errorMessage else getString(R.string.packingSave), - it.isError, !it.isError - ) - if (!it.isError) { - viewModel.collectionTicketGet( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - ) - } - - }) - */ - /* responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE @@ -582,65 +547,39 @@ class CollectionFragmentPickerNew( } }) - */ - /* responseSaleGroup.observe(viewLifecycleOwner, Observer { + responseItemShelvingSale.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = View.GONE + myGroupList[positionConfirm].isPicked = 1 + myGroupList[positionConfirm].reservedQuantity = quantityConfirm + viewModel.collectionTicketGetSalix( + collection.collectionFk, + print = false + ) + lm!!.scrollToPositionWithOffset(positionConfirm, 0) + //saleAdapter!!.notifyDataSetChanged() + ma.messageWithSound( + "Confirmada acción", + it.isError, !it.isError + ) + }) + responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = View.GONE + myGroupList[positionUnmarked].isPicked = 1 + myGroupList[positionUnmarked].reservedQuantity = quantityConfirm + viewModel.collectionTicketGetSalix( + collection.collectionFk, + print = false + ) + lm!!.scrollToPositionWithOffset(positionUnmarked, 0) + //saleAdapter!!.notifyDataSetChanged() + ma.messageWithSound( + "Confirmada acción", + it.isError, !it.isError + ) + }) - if (it.isError) { - - ma.messageWithSound(it.errorMessage, true, true) - } else { - ma.messageWithSound(getString(R.string.previousCollected), false, true) - binding.splashProgress.visibility = View.VISIBLE - viewModel.collectionTicketGet( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - ) - } - })*/ - - /* item.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - if (!goBack) toastDisponibility(it) - goBack = false - }) - */ - /* responseNew.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - // if (!goBack) { - if (it.isError) { - customDialog.setTitle(getString(R.string.disponibility)) - .setDescription(getString(R.string.errorCollectionNew) + it.errorMessage) - .setKoButton(getString(R.string.close)) { - scanRequest() - customDialog.dismiss() - }.show() - } else { - - binding.splashProgress.visibility = - View.VISIBLE - - - if (!goBack) { - - viewModel.collectionTicketGet( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - ) - - - } - } - // } - - goBack = false - - })*/ responseCode.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE @@ -893,23 +832,17 @@ class CollectionFragmentPickerNew( } - private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean) { + private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?) { state = 0 isScanned = null positionConfirm = position quantityConfirm = quantity isMarking = true - callBack( - viewModelSalix.callBackProcedSalix( - "itemShelvingSale_setQuantity", - params = arrayListOf( - myGroupList[position].itemShelvingSaleFk, - quantity, - isItemShelvingSaleEmpty - ) - ), splashProgress = binding.splashProgress - ) + + viewModel.itemShelvingSaleSetQuantity(myGroupList[position].itemShelvingSaleFk, + quantity, + isItemShelvingSaleEmpty) //nuevo tema agrupacion sales //checkStateParent() @@ -999,19 +932,8 @@ class CollectionFragmentPickerNew( } storedBackPosition = position setListPosition(position, false) - - callBack( - viewModelSalix.callBackProcedSalix( - "itemShelvingSale_unpicked", - params = arrayListOf( - sales[position].itemShelvingSaleFk, - ) - ), splashProgress = binding.splashProgress - ) - + viewModel.itemShelvingSaleUnpicked(sales[position].itemShelvingSaleFk) positionUnmarked = position - - setTotalLines() scanRequest() customDialog.dismiss() @@ -1186,7 +1108,7 @@ class CollectionFragmentPickerNew( /* if (myGroupList[storedPosition].reservedQuantity == 0) { showQuestionUbicationEmpty(storedPosition) } else {*/ - markLine(storedPosition, quantity, false) + markLine(storedPosition, quantity, null) // } @@ -1326,16 +1248,11 @@ class CollectionFragmentPickerNew( binding.splashProgress.visibility = View.VISIBLE - callBack( - viewModelSalix.callBackProcedSalix( - "collection_addWithReservation", - params = arrayListOf( - customDialogList.getValue().toInt(), - customDialogList.getValueTwo().toInt(), - ticketSelected - ) - ), splashProgress = binding.splashProgress - ) + + viewModel.collectionAddWithReservation(customDialogList.getValue().toInt(), + customDialogList.getValueTwo().toInt(), + ticketSelected) + customDialogList.dismiss() hideKeyboards() scanRequest() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt index 7570bbe0..5c88a70a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt @@ -22,7 +22,7 @@ class HistoricoArticuloViewModel(val context: Context) : BaseViewModel(context) val loadHistoricoList = Transformations.map(_historicoList) { Event(it) } fun itemGetBalance(itemFk: Int, vWarehouseFk: Int) { - //salix falla fecha + //salix falla fecha -- No tiene hora. silex.itemDiary(itemFk, vWarehouseFk) // salix.itemGetBalance(arrayListOf(itemFk, vWarehouseFk, null)) .enqueue(object : diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/model/ItemHistoricoVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/model/ItemHistoricoVO.kt index b0543280..064e880c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/model/ItemHistoricoVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/model/ItemHistoricoVO.kt @@ -1,7 +1,11 @@ package es.verdnatura.presentation.view.feature.historicoarticulo.model +import android.os.Build +import androidx.annotation.RequiresApi +import es.verdnatura.domain.isoToString + class ItemHistoricoVO( - var shipped: String? = null, + //var shipped: String? = null, var stateName: String? = null, var origin: Int? = null, var reference: String? = null, @@ -12,7 +16,13 @@ class ItemHistoricoVO( var balance: Int? = null, var isError: Boolean = false, var errorMessage: String = "" -) +) { + var shipped: String = "" + @RequiresApi(Build.VERSION_CODES.O) + get() { + return field.isoToString(returnOnlyDate = true) + } +} class ItemHistoricoListVO( var list: List = listOf() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index 0e816bec..c9dfa64b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -98,7 +98,7 @@ import java.util.concurrent.TimeUnit class MainActivity : BaseActivity(), OnPasillerosItemClickListener, OnTruckClickListener, OnPalletClickListener, OnComprobarPalletViewClickListener, - OnCollectionSelectedListener, OnCollectionTicketSelectedListener { + OnCollectionSelectedListener, OnCollectionTicketSelectedListener,MainActivityListener { private var lastBottomMenuItemSelected: ItemMenuVO? = null private lateinit var customDialog: CustomDialogMainActivity @@ -147,6 +147,7 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL setFragments() setBottomMenuFragment() setRegisterNetwork() + (application as MobileApplication).setMainListener(this) //Tarea //printBluetooth() @@ -1126,4 +1127,8 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL } } + override fun onApplicationEventAnimation(visibility:Int) { + binding.splashAnimation.visibility = visibility + } + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt index 8f00741e..b1389506 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt @@ -1,6 +1,5 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment - import android.view.View import android.view.inputmethod.EditorInfo import androidx.recyclerview.widget.LinearLayoutManager @@ -19,7 +18,6 @@ class ExpeditionStateFragment( ExpeditionStateViewModel::class ) { - private var adapter: ExpeditionStateAdapter? = null private var listItemsRow: ArrayList = ArrayList() private var itemScan = "" @@ -36,7 +34,6 @@ class ExpeditionStateFragment( super.init() } - private fun setToolBar(title: String) { binding.mainToolbar.toolbarTitle.text = title } @@ -46,8 +43,19 @@ class ExpeditionStateFragment( binding.editItemFk.setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (binding.editItemFk.text.toString().isNotEmpty()) { - getExpedtionState(binding.editItemFk.toInt()) - itemScan = binding.editItemFk.text.toString() + try { + viewModel.expeditionGetStateJSON(binding.editItemFk.toInt()) + itemScan = binding.editItemFk.text.toString() + } catch (ex: Exception) { + ma.messageWithSound( + message = getString(R.string.errorInput), + isError = true, + isToasted = true, + isPlayed = true, + titleWithError = "Error" + ) + } + } binding.editItemFk.setText("") ma.hideKeyboard(binding.editItemFk) @@ -60,39 +68,18 @@ class ExpeditionStateFragment( binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() } - - } - - private fun getExpedtionState(expeditionFk: Int) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.expedition_getStateJSON(expeditionFk) } override fun observeViewModel() { with(viewModel) { itemexpedition.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (it.isError) { - binding.itemcardLayout.visibility = View.GONE - binding.mainToolbar.toolbarTitle.text = entryPoint - ma.messageWithSound( - getString(R.string.noDataLabelScanned), - true, - false, - getString(R.string.noResults) - ) - - } else { - setItemExpeditionState(it) - } + setItemExpeditionState(it) } - } } - private fun setItemExpeditionState(itemInfo: itemExpedetionState) { - setToolBar(getString(R.string.expedition) + itemScan) + setToolBar(getString(R.string.expedition) + " " + itemScan) binding.itemcardLayout.visibility = View.VISIBLE listItemsRow = ArrayList() @@ -110,9 +97,7 @@ class ExpeditionStateFragment( binding.itemexpeditionstateRecyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - } - } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt index f6cc5762..89298746 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt @@ -2,51 +2,30 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment //import es.verdnatura.presentation.view.feature.paletizador.model.itemExpeditionDynamicsList import android.content.Context +import android.os.Build +import androidx.annotation.RequiresApi import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken import es.verdnatura.domain.SalixCallback +import es.verdnatura.domain.isoToString 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 es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO -import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics import retrofit2.Response class ExpeditionStateViewModel(val context: Context) : BaseViewModel(context) { - private val _itemcard by lazy { MutableLiveData() } - val itemcard: LiveData - get() = _itemcard - - private val _itemexpeditionlist by lazy { MutableLiveData() } - val itemexpeditionlist: LiveData - get() = _itemexpeditionlist - private val _itemexpedition by lazy { MutableLiveData() } val itemexpedition: LiveData get() = _itemexpedition - private val _response by lazy { MutableLiveData() } - val response: LiveData - get() = _response - - private val _itemspackinglist by lazy { MutableLiveData() } - val itemspackinglist: LiveData - get() = _itemspackinglist - - private val _itemsExpeditionlist by lazy { MutableLiveData() } - val itemsExpeditionlist: LiveData - get() = _itemsExpeditionlist - - fun expedition_getStateJSON(expeditionFk: Int) { + fun expeditionGetStateJSON(expeditionFk: Int) { salix.expedition_getState(params = arrayListOf(expeditionFk)) .enqueue(object : SalixCallback>(context) { + @RequiresApi(Build.VERSION_CODES.O) override fun onSuccess(response: Response>) { _itemexpedition.value = itemExpedetionState( isError = false, @@ -60,31 +39,26 @@ class ExpeditionStateViewModel(val context: Context) : BaseViewModel(context) { } - override fun onError(t: Throwable) { - _itemexpedition.value = itemExpedetionState( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!), - list = mutableListOf() - - ) - } - }) } + @RequiresApi(Build.VERSION_CODES.O) fun getListFromJSON(json: JsonObject): MutableList { val gson = Gson() var list = mutableListOf() var expeditionState: Map = gson.fromJson(json, object : TypeToken>() {}.type) expeditionState.forEach { - list.add(itemsExpeditionDynamics(key = it.key, it.value ?: "")) - } + list.forEach { element -> + if (element.value!!.takeLast(4).matches(Regex("[0-9]{3}Z"))) { + element.value = element.value.isoToString(false) + } + } + return list } - } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt index d8937e12..17239c73 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt @@ -35,7 +35,7 @@ class ExpeditionTruckListViewModel(val context: Context) : BaseViewModel(context "between": ["${LocalDate.now().atTime(LocalTime.MIN)}", "${ LocalDate.now().atTime(LocalTime.MAX) - }"]}}}""" + }"]}},"order": "eta ASC"}""" ).enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { _expeditionTruckList.value = diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt index ad8a3284..9670fd88 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt @@ -3,7 +3,6 @@ package es.verdnatura.presentation.view.feature.parking.fragment import android.media.MediaPlayer import android.os.Bundle -import android.view.View import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager @@ -34,13 +33,14 @@ class ParkingFragment (var menuOrigin:String): BaseFragment get() = _response - private val _isLoading by lazy { MutableLiveData() } - val isLoading: LiveData = _isLoading - - private val _isLoadingProgress by lazy { MutableLiveData() } - val isLoadingProgress: LiveData = _isLoadingProgress - - private fun showProgressLoading() { - _isLoading.value = true - } - - fun hideProgressLoading() { - _isLoading.value = false - } - - fun ProgressLoading(visibility: Int) { - _isLoadingProgress.value = visibility - } - fun setParking(scanItem: String, parking: String) { - ProgressLoading(VISIBLE) salix.setParking(arrayListOf(scanItem, parking).formatWithQuotes()) .enqueue(object : SalixCallback(context) { override fun onSuccess(response: Response) { - ProgressLoading(GONE) _response.value = ResponseItemVO(isError = false, response = response.message()) } - - override fun onError(t: Throwable) { - ProgressLoading(GONE) - _response.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } }) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/adapter/ParkingAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/adapter/ParkingAdapter.kt deleted file mode 100644 index 5b8d5453..00000000 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/adapter/ParkingAdapter.kt +++ /dev/null @@ -1,43 +0,0 @@ -/*package es.verdnatura.presentation.view.feature.parking.adapter - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import es.verdnatura.databinding.ItemBarcodeRowBinding -import es.verdnatura.presentation.common.OnBarcodeRowClickListener -import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO -/* - -class ParkingAdapter ( - private val items: List, - private val onBarcodeRowClickListener: OnBarcodeRowClickListener -): RecyclerView.Adapter () { - - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { - return ItemHolder( - ItemBarcodeRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) - ) - } - - override fun getItemCount() =items.size - - override fun onBindViewHolder(holder: ItemHolder, position: Int) { - holder.bind(items[position]) - holder.binding.root.setOnClickListener { - onBarcodeRowClickListener.onBarcodeRowClickListener(items[position]) - } - } - - - inner class ItemHolder( - val binding: ItemBarcodeRowBinding - ) : RecyclerView.ViewHolder(binding.root){ - fun bind(item: BarcodeVO) { - binding.apply { - this.item = item - } - } - } -} -*/ \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingSaleFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingSaleFragment.kt deleted file mode 100644 index 4eaea7c3..00000000 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingSaleFragment.kt +++ /dev/null @@ -1,153 +0,0 @@ -package es.verdnatura.presentation.view.feature.parking.fragment - -import android.media.MediaPlayer -import android.os.Bundle -import android.view.View -import android.view.inputmethod.EditorInfo -import androidx.lifecycle.Observer -import androidx.recyclerview.widget.LinearLayoutManager -import es.verdnatura.R -import es.verdnatura.databinding.FragmentParkingBinding -import es.verdnatura.presentation.base.BaseFragment -import es.verdnatura.presentation.common.OnBarcodeRowClickListener -import es.verdnatura.presentation.common.hideKeyboard -import es.verdnatura.presentation.view.component.CustomDialog -import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO -import es.verdnatura.presentation.view.feature.main.activity.MainActivity -import es.verdnatura.presentation.view.feature.parking.adapter.ParkingAdapter - -@Suppress("UNUSED_ANONYMOUS_PARAMETER") -class ParkingSaleFragment : BaseFragment(ParkingSaleViewModel::class) { - - - private lateinit var customDialog: CustomDialog - private var scanerList:ArrayList = ArrayList() - private var adapter : ParkingAdapter? = null - private var numParking : Int = 0 - var mperror: MediaPlayer? = null - var mpok: MediaPlayer? = null - - - override fun getLayoutId(): Int = R.layout.fragment_parking - companion object { - fun newInstance(SaleVO: Any?) = ParkingFragment("") - } - - - override fun init() { - setEvents() - binding.mainToolbar.toolbarTitle.text = getString(R.string.Parking) - binding.splashProgress.visibility=View.GONE - setList() - customDialog = CustomDialog(requireContext()) - super.init() - } - - private fun setEvents(){ - binding.scanInput.requestFocus() - binding.scanInput.setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!binding.scanInput.text.isNullOrEmpty()) { - checkScan(binding.scanInput.text.toString()) - } - binding.scanInput.setText("") - requireActivity().hideKeyboard() - return@setOnEditorActionListener true - } - false - } - - binding.mainToolbar.backButton.setOnClickListener { - requireActivity().onBackPressed() - } - } - - override fun observeViewModel() { - with(viewModel){ - response.observe(viewLifecycleOwner, Observer { - if (it.isError){ - mperror?.start() - ma.messageWithSound(it.errorMessage,true,false) - /* customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage).setOkButton(getString(R.string.close)){ - customDialog.dismiss() - }.show()*/ - }else{ - ma.messageWithSound(it.errorMessage,false,false, isToasted = true) - numParking -= 1 - if (numParking <= 0) { - //viewModel.hideProgressLoading() - - mpok?.start() - setList() - } - } - }) - - isLoading.observe(viewLifecycleOwner, Observer { - if (it){ - binding.splashProgress.visibility = View.VISIBLE - }else{ - binding.splashProgress.visibility = View.GONE - } - - }) - - isLoadingProgress.observe(viewLifecycleOwner, { - - binding.splashProgress.visibility = it - - }) - - - } - } - - private fun setList(){ - scanerList = ArrayList() - adapter = ParkingAdapter(scanerList,object: OnBarcodeRowClickListener{ - override fun onBarcodeRowClickListener(item: BarcodeVO) { - scanerList.removeAt(scanerList.indexOf(item)) - adapter?.notifyDataSetChanged() - } - }) - val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - - binding.fragmentParkingScanList.adapter = adapter - binding.fragmentParkingScanList.layoutManager = lm - } - - private fun checkScan(txtScan:String){ - var isParking:Boolean = false - if (txtScan.trim().length == 4 && isLetter(txtScan.substring(txtScan.length - 1)) || txtScan.contains("-")){ - isParking = true - } - - if (isParking){ - numParking = scanerList.size - scanerList.forEach { - // binding.splashProgress.visibility = View.VSIIBLE - viewModel.setParking( - parking = txtScan, - scanItem = it.code!! - ) - } - }else{ - scanerList.add(BarcodeVO(code = txtScan)) - adapter?.notifyDataSetChanged() - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - - mperror = MediaPlayer.create((activity as MainActivity),R.raw.error) - mpok = MediaPlayer.create((activity as MainActivity),R.raw.ok) - super.onCreate(savedInstanceState) - } - - @Throws(NumberFormatException::class) - fun isLetter(text: String): Boolean { - return text.matches("[a-zA-Z ]+".toRegex()) - } - - -} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingViewModel.kt deleted file mode 100644 index 0bd6e6f7..00000000 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parkingSale/fragment/ParkingViewModel.kt +++ /dev/null @@ -1,62 +0,0 @@ -package es.verdnatura.presentation.view.feature.parking.fragment - -import android.content.Context -import android.view.View -import android.view.View.VISIBLE -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -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 - -class ParkingSaleViewModel(val context: Context) : BaseViewModel(context) { - private val _response by lazy { MutableLiveData() } - val response: LiveData - get() = _response - - private val _isLoading by lazy { MutableLiveData() } - val isLoading: LiveData = _isLoading - - private val _isLoadingProgress by lazy { MutableLiveData() } - val isLoadingProgress: LiveData = _isLoadingProgress - - private val _responseParkingAdd by lazy { MutableLiveData() } - val responseParkingAdd: LiveData - get() = _responseParkingAdd - - private fun showProgressLoading() { - _isLoading.value = true - } - - fun hideProgressLoading() { - _isLoading.value = false - } - - fun ProgressLoading(visibility: Int) { - _isLoadingProgress.value = visibility - } - - fun setParking(scanItem: String, parking: String) { - ProgressLoading(VISIBLE) - salix.setParking(arrayListOf(scanItem, parking).formatWithQuotes()) - .enqueue(object : - SalixCallback(context) { - override fun onSuccess(response: Response) { - ProgressLoading(View.GONE) - _response.value = ResponseItemVO(isError = false, response = response.message()) - } - - override fun onError(t: Throwable) { - _response.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } - }) - } - -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index bc8fc7ee..135913de 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -28,6 +28,28 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> + + + + - - + + app:layout_constraintTop_toTopOf="parent"> - + + + android:textSize="@dimen/body2" /> + + android:textSize="@dimen/body2" /> + + android:textSize="@dimen/body2" /> + + android:textSize="@dimen/body2" /> + + android:gravity="center" + android:text="@string/Fecha" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/body2" /> + + tools:listitem="@layout/item_location_row" /> - - - - - - ' - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml b/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml index 5c2d5a68..e4c6a297 100644 --- a/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml +++ b/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml @@ -1,16 +1,12 @@ - - - + - - - - - + android:orientation="vertical"> + + android:orientation="vertical" + android:padding="10dp"> - + android:padding="@dimen/layout_margin_min"> - + - > - + - ' - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_parking.xml b/app/src/main/res/layout/fragment_parking.xml index 4903fcfb..cc9ebf0d 100644 --- a/app/src/main/res/layout/fragment_parking.xml +++ b/app/src/main/res/layout/fragment_parking.xml @@ -1,9 +1,10 @@ - + + @@ -14,24 +15,19 @@ android:layout_height="match_parent" android:background="@color/verdnatura_black"> - - - - + - - - - - - \ No newline at end of file