Commit 15c37e974eb2af5cdaf737ef807f0d620d706dcc
1 parent
6aec0e86d9
Exists in
master
31022020 2309
Showing
12 changed files
with
229 additions
and
246 deletions
Show diff stats
Solicitudes API Articulos y Time.docx
No preview for this file type
app/build.gradle
| ... | ... | @@ -13,8 +13,12 @@ android { |
| 13 | 13 | targetSdkVersion 30 |
| 14 | 14 | versionCode 1 |
| 15 | 15 | versionName "1.0" |
| 16 | - | |
| 17 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 17 | + javaCompileOptions { | |
| 18 | + annotationProcessorOptions { | |
| 19 | + arguments = ["room.incremental":"true"] | |
| 20 | + } | |
| 21 | + } | |
| 18 | 22 | } |
| 19 | 23 | |
| 20 | 24 | buildTypes { |
| ... | ... | @@ -26,6 +30,7 @@ android { |
| 26 | 30 | compileOptions { |
| 27 | 31 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 28 | 32 | targetCompatibility JavaVersion.VERSION_1_8 |
| 33 | + | |
| 29 | 34 | } |
| 30 | 35 | kotlinOptions { |
| 31 | 36 | jvmTarget = '1.8' |
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
app/src/main/java/com/focasoftware/deboinventariov20/Model/ProductosService.kt
| ... | ... | @@ -4,8 +4,8 @@ import retrofit2.Retrofit |
| 4 | 4 | import retrofit2.converter.gson.GsonConverterFactory |
| 5 | 5 | |
| 6 | 6 | object ProductosService { |
| 7 | - private val BASE_URL ="http://192.168.0.2:3000/" | |
| 8 | - //"http://10.0.2.2:3000/" | |
| 7 | + private val BASE_URL ="http://10.0.2.2:3000/" | |
| 8 | + //"http://192.168.0.2:3000/" | |
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | fun getProductosService(): ProductosApi { |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionFragment.kt
| ... | ... | @@ -7,6 +7,7 @@ import android.graphics.Canvas |
| 7 | 7 | import android.graphics.Color |
| 8 | 8 | import android.graphics.drawable.ColorDrawable |
| 9 | 9 | import android.os.Bundle |
| 10 | +import android.text.InputType | |
| 10 | 11 | import android.view.LayoutInflater |
| 11 | 12 | import android.view.View |
| 12 | 13 | import android.view.ViewGroup |
| ... | ... | @@ -95,7 +96,10 @@ class DescripcionFragment : Fragment() { |
| 95 | 96 | numeroInventario.toString()) |
| 96 | 97 | if (artCargadoEnBD == null) { |
| 97 | 98 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) |
| 98 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setCancelable(false) | |
| 99 | + val mBuilder = AlertDialog.Builder(context).setView(mDialogView) | |
| 100 | + .setCancelable(false) | |
| 101 | + if ((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==1 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==3 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==7) | |
| 102 | + mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
| 99 | 103 | mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" |
| 100 | 104 | val mAlertDialog = mBuilder.show() |
| 101 | 105 | mDialogView.btnAceptar.setOnClickListener { |
| ... | ... | @@ -128,6 +132,7 @@ class DescripcionFragment : Fragment() { |
| 128 | 132 | |
| 129 | 133 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
| 130 | 134 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) |
| 135 | + if (artCargadoEnBD!!.balanza.toString().contains("1" ) || artCargadoEnBD!!.balanza.toString().contains("3") || artCargadoEnBD!!.balanza.toString().contains("7")) mDialogView.tvNuevaCantidad.inputType= InputType.TYPE_CLASS_NUMBER | |
| 131 | 136 | mDialogView.tvCantInicial.text = artCargadoEnBD!!.cantTomada |
| 132 | 137 | |
| 133 | 138 | val mAlertDialog = mBuilder.show() |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
| ... | ... | @@ -9,6 +9,9 @@ import android.graphics.Canvas |
| 9 | 9 | import android.graphics.Color |
| 10 | 10 | import android.graphics.drawable.Drawable |
| 11 | 11 | import android.os.Bundle |
| 12 | +import android.text.InputType | |
| 13 | +import android.text.InputType.TYPE_CLASS_NUMBER | |
| 14 | +import android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL | |
| 12 | 15 | import android.view.KeyEvent |
| 13 | 16 | import android.view.LayoutInflater |
| 14 | 17 | import android.view.View |
| ... | ... | @@ -31,13 +34,12 @@ import com.focasoftware.deboinventariov20.Model.InvBody |
| 31 | 34 | import com.focasoftware.deboinventariov20.Model.InvHead |
| 32 | 35 | import com.focasoftware.deboinventariov20.R |
| 33 | 36 | import com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado |
| 34 | -import com.focasoftware.deboinventariov20.ui.util.Base.AlertDialogBorrarInv | |
| 35 | -import com.focasoftware.deboinventariov20.ui.util.Base.NoEncontradoSimple | |
| 36 | 37 | import kotlinx.android.synthetic.main.fragment_inventario.* |
| 37 | 38 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* |
| 38 | 39 | import kotlinx.android.synthetic.main.login_dialog.view.* |
| 39 | 40 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar |
| 40 | 41 | import kotlinx.coroutines.* |
| 42 | +import java.lang.Integer.TYPE | |
| 41 | 43 | import java.time.LocalDateTime |
| 42 | 44 | import java.time.format.DateTimeFormatter |
| 43 | 45 | import java.util.* |
| ... | ... | @@ -86,10 +88,8 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 86 | 88 | GlobalScope.launch(Dispatchers.Main) { |
| 87 | 89 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO |
| 88 | 90 | InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 |
| 89 | - SerchArea() | |
| 90 | - val descripInv: String = if (iArea == 0) "Ventas" else "Deposito" | |
| 91 | 91 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO |
| 92 | - invHead = InvHead(InventarioNuevo, descripInv, 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, iArea, AjusteProductos(), ProdNoCont()) | |
| 92 | + invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) | |
| 93 | 93 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) |
| 94 | 94 | tvTitulo.text = "Inventario Dinamico" + " Nยฐ $InventarioNuevo" |
| 95 | 95 | } |
| ... | ... | @@ -127,51 +127,7 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 127 | 127 | listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada+1 |
| 128 | 128 | viewAdapter.notifyDataSetChanged() |
| 129 | 129 | } else { |
| 130 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 131 | - val mBuilder = | |
| 132 | - AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | |
| 133 | -// .setCancelable(false) | |
| 134 | - mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | |
| 135 | - val mAlertDialog = mBuilder.show() | |
| 136 | - mDialogView.rbSumar.setOnClickListener { | |
| 137 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 138 | - mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 139 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 140 | - } | |
| 141 | - } | |
| 142 | - mDialogView.rbRestar.setOnClickListener { | |
| 143 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 144 | - if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
| 145 | - mDialogView.tvgenerico4.text = | |
| 146 | - (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 147 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 148 | - } | |
| 149 | - } | |
| 150 | - } | |
| 151 | - mDialogView.rbMdodificar.setOnClickListener { | |
| 152 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 153 | - mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 154 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 155 | - } | |
| 156 | - } | |
| 157 | - mDialogView.btnAceptar.setOnClickListener { | |
| 158 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 159 | - mAlertDialog.dismiss() | |
| 160 | -// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 161 | -// fCant = 0F | |
| 162 | -// fCant = name | |
| 163 | - listArticulos[indiceDelArtEncontrado].cantTomada = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 164 | - updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), mDialogView.tvgenerico4.text.toString().toFloat()) | |
| 165 | - viewAdapter.notifyDataSetChanged() | |
| 166 | - } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 167 | - mDialogView.tvNuevaCantidad.error = "No vacio" | |
| 168 | - mDialogView.tvNuevaCantidad.requestFocus() | |
| 169 | - mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
| 170 | - } | |
| 171 | - } | |
| 172 | - mDialogView.dialogCancelBtn.setOnClickListener { | |
| 173 | - mAlertDialog.dismiss() | |
| 174 | - } | |
| 130 | + dialogoSumaResta(requireContext(),indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta) | |
| 175 | 131 | } |
| 176 | 132 | |
| 177 | 133 | } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD |
| ... | ... | @@ -320,8 +276,8 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 320 | 276 | super.onViewCreated(view, savedInstanceState) |
| 321 | 277 | navController = Navigation.findNavController(view) |
| 322 | 278 | etCodigoBarras.requestFocus() |
| 323 | - val modalDialog = NoEncontradoSimple() | |
| 324 | - modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
| 279 | +// val modalDialog = NoEncontradoSimple() | |
| 280 | +// modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
| 325 | 281 | |
| 326 | 282 | btnBorrarInv.setOnClickListener { |
| 327 | 283 | AlertDialog.Builder(requireContext()) |
| ... | ... | @@ -340,22 +296,6 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 340 | 296 | //botรณn cancel pulsado |
| 341 | 297 | }) |
| 342 | 298 | .show() |
| 343 | - | |
| 344 | - | |
| 345 | -// MaterialDialog(requireContext()).show { | |
| 346 | -// title(R.string.sTituloBorrarInv) | |
| 347 | -// message(R.string.sMensajeBorrarInv) | |
| 348 | -// positiveButton(R.string.btnOk) { | |
| 349 | -// BorrarInvActual() | |
| 350 | -// Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | |
| 351 | -// navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
| 352 | -// InventarioNuevo = 0 | |
| 353 | -// dismiss() | |
| 354 | -// } | |
| 355 | -// negativeButton { | |
| 356 | -// dismiss() | |
| 357 | -// } | |
| 358 | -// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 359 | 299 | } |
| 360 | 300 | |
| 361 | 301 | btnExportarInv.setOnClickListener { |
| ... | ... | @@ -461,34 +401,33 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 461 | 401 | //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV |
| 462 | 402 | |
| 463 | 403 | if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD |
| 464 | -// if (swSumaUno!!.isChecked) {// TODO: SI ESTA +1, PONE CANTIDAD 1 | |
| 465 | - if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
| 466 | - fCant = 0F | |
| 467 | - fCant += 1F | |
| 468 | - // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
| 469 | - val acargarPorDesc = Articles(artAcargar[0].sector, | |
| 470 | - artAcargar[0].codigo, | |
| 471 | - artAcargar[0].descripcion, | |
| 472 | - artAcargar[0].codBar, | |
| 473 | - artAcargar[0].codOrigen, | |
| 474 | - artAcargar[0].precio, | |
| 475 | - artAcargar[0].costo, | |
| 476 | - "", | |
| 477 | - "", | |
| 478 | - "", | |
| 479 | - artAcargar[0].balanza, | |
| 480 | - artAcargar[0].depSn, | |
| 481 | - "") | |
| 482 | - // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
| 483 | - cargarArtEnBd(acargarPorDesc, fCant) | |
| 484 | - cargarRecicler(acargarPorDesc, fCant) | |
| 485 | - } else { | |
| 404 | +// if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | |
| 405 | +// fCant = 0F | |
| 406 | +// fCant += 1F | |
| 407 | +// // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | |
| 408 | +// val acargarPorDesc = Articles(artAcargar[0].sector, | |
| 409 | +// artAcargar[0].codigo, | |
| 410 | +// artAcargar[0].descripcion, | |
| 411 | +// artAcargar[0].codBar, | |
| 412 | +// artAcargar[0].codOrigen, | |
| 413 | +// artAcargar[0].precio, | |
| 414 | +// artAcargar[0].costo, | |
| 415 | +// "", | |
| 416 | +// "", | |
| 417 | +// "", | |
| 418 | +// artAcargar[0].balanza, | |
| 419 | +// artAcargar[0].depSn, | |
| 420 | +// "") | |
| 421 | +// // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | |
| 422 | +// cargarArtEnBd(acargarPorDesc, fCant) | |
| 423 | +// cargarRecicler(acargarPorDesc, fCant) | |
| 424 | +// } else { | |
| 486 | 425 | var bundle = Bundle() |
| 487 | 426 | bundle = bundleOf("ArrayDesc" to artAcargar) |
| 488 | 427 | bundle.putInt("numeroInv", InventarioNuevo) |
| 489 | 428 | navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) |
| 490 | 429 | //navController.backStack.removeLast() |
| 491 | - } | |
| 430 | +// } | |
| 492 | 431 | // } else {//SI NO ESTA +1 |
| 493 | 432 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV |
| 494 | 433 | // fCant = listArticulos[0].cantTomada |
| ... | ... | @@ -528,17 +467,7 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 528 | 467 | // } |
| 529 | 468 | } else {//TODO si no lo encuentra en la BD |
| 530 | 469 | val modalDialog = DialogNoEncontrado() |
| 531 | - | |
| 532 | 470 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
| 533 | - | |
| 534 | -// MaterialDialog(requireContext()).show { | |
| 535 | -// val t=etCodigoBarras.text | |
| 536 | -// title(text = "El articulo ${etCodigoBarras.text.toString()}") | |
| 537 | -// message(R.string.sMensaje) | |
| 538 | -// positiveButton(R.string.btnOk) { | |
| 539 | -// dismiss() | |
| 540 | -// } | |
| 541 | -// }.cornerRadius(10F) | |
| 542 | 471 | } |
| 543 | 472 | etCodigoBarras.focusable = View.FOCUSABLE |
| 544 | 473 | etCodigoBarras.setText("") |
| ... | ... | @@ -555,46 +484,92 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 555 | 484 | cargarRecicler(artAcargar, fCant) |
| 556 | 485 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD |
| 557 | 486 | |
| 558 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | |
| 559 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView) | |
| 560 | - .setCancelable(false) | |
| 561 | - mDialogView.tvTitulo.text = "${artAcargar.descripcion.toString()}" | |
| 562 | - val mAlertDialog = mBuilder.show() | |
| 563 | - mDialogView.btnAceptar.setOnClickListener { | |
| 564 | - if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
| 565 | - mDialogView.etCantidad.error = "No vacio" | |
| 566 | - mDialogView.etCantidad.requestFocus() | |
| 567 | - mDialogView.etCantidad.hint = "Ingrese un valor" | |
| 568 | - } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
| 569 | - mAlertDialog.dismiss() | |
| 570 | -// fCant = 0F | |
| 571 | -// fCant = mDialogView.etCantidad.text.toString().toFloat() | |
| 572 | - cargarArtEnBd(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | |
| 573 | - cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | |
| 574 | - } | |
| 575 | - } | |
| 487 | + DialogingresarCantidad(requireContext(),artAcargar) | |
| 576 | 488 | } |
| 577 | 489 | } else {// TODO si no lo encuentra en la BD |
| 578 | - val modalDialog = NoEncontradoSimple() | |
| 490 | + val modalDialog = DialogNoEncontrado() | |
| 579 | 491 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
| 580 | -// MaterialDialog(requireContext()).show { | |
| 581 | -// | |
| 582 | -// title(text = "El producto: $sChangeUpper") | |
| 583 | -// message(text = "ยกNo fue encontrado!") | |
| 584 | -// positiveButton(R.string.btnOk) {} | |
| 585 | -// dismiss() | |
| 586 | -// } | |
| 587 | 492 | } |
| 588 | 493 | etCodigoBarras.focusable = View.FOCUSABLE |
| 589 | 494 | etCodigoBarras.setText("") |
| 590 | 495 | etCodigoBarras.selectAll() |
| 591 | 496 | } |
| 592 | 497 | |
| 498 | + fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?) { | |
| 499 | + val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) | |
| 500 | + val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView) | |
| 501 | + .setCancelable(false) | |
| 502 | + if (artAcargar!!.balanza!!.toInt()==1 || artAcargar.balanza!!.toInt()==3 || artAcargar.balanza!!.toInt()==7) mDialogView.etCantidad.inputType=TYPE_CLASS_NUMBER | |
| 503 | + mDialogView.tvTitulo.text = artAcargar.descripcion.toString() | |
| 504 | + val mAlertDialog = mBuilder.show() | |
| 505 | + mDialogView.btnAceptar.setOnClickListener { | |
| 506 | + if (mDialogView.etCantidad.text.isNullOrEmpty()) { | |
| 507 | + mDialogView.etCantidad.error = "No vacio" | |
| 508 | + mDialogView.etCantidad.requestFocus() | |
| 509 | + mDialogView.etCantidad.hint = "Ingrese un valor" | |
| 510 | + } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | |
| 511 | + mAlertDialog.dismiss() | |
| 512 | + cargarArtEnBd(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | |
| 513 | + cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | |
| 514 | + } | |
| 515 | + } | |
| 516 | + } | |
| 517 | + | |
| 518 | + fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String) { | |
| 519 | + val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 520 | + val mBuilder = | |
| 521 | + AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.") | |
| 522 | +// .setCancelable(false) | |
| 523 | + if (univta.contains("1" ) || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType=TYPE_CLASS_NUMBER | |
| 524 | + | |
| 525 | + mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | |
| 526 | + val mAlertDialog = mBuilder.show() | |
| 527 | + mDialogView.rbSumar.setOnClickListener { | |
| 528 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 529 | + mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 530 | + mDialogView.tvNuevaCantidad.isEnabled=false | |
| 531 | + } | |
| 532 | + } | |
| 533 | + mDialogView.rbRestar.setOnClickListener { | |
| 534 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 535 | + if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
| 536 | + mDialogView.tvgenerico4.text = | |
| 537 | + (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 538 | + mDialogView.tvNuevaCantidad.isEnabled=false | |
| 539 | + } | |
| 540 | + } | |
| 541 | + } | |
| 542 | + mDialogView.rbMdodificar.setOnClickListener { | |
| 543 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 544 | + mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 545 | + mDialogView.tvNuevaCantidad.isEnabled=false | |
| 546 | + } | |
| 547 | + } | |
| 548 | + mDialogView.btnAceptar.setOnClickListener { | |
| 549 | + if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 550 | + mAlertDialog.dismiss() | |
| 551 | +// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 552 | +// fCant = 0F | |
| 553 | +// fCant = name | |
| 554 | + listArticulos[indiceDelArtEncontrado].cantTomada = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 555 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), mDialogView.tvgenerico4.text.toString().toFloat()) | |
| 556 | + viewAdapter.notifyDataSetChanged() | |
| 557 | + } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 558 | + mDialogView.tvNuevaCantidad.error = "No vacio" | |
| 559 | + mDialogView.tvNuevaCantidad.requestFocus() | |
| 560 | + mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
| 561 | + } | |
| 562 | + } | |
| 563 | + mDialogView.dialogCancelBtn.setOnClickListener { | |
| 564 | + mAlertDialog.dismiss() | |
| 565 | + } | |
| 566 | + } | |
| 567 | + | |
| 593 | 568 | suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { |
| 594 | 569 | //TODO BUSQUEDA POR CODIGO DE BARRAS |
| 595 | 570 | var busqueda: Articles? = null |
| 596 | 571 | return GlobalScope.async(Dispatchers.IO) { |
| 597 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, iArea) | |
| 572 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) | |
| 598 | 573 | return@async busqueda |
| 599 | 574 | }.await() |
| 600 | 575 | } |
| ... | ... | @@ -603,7 +578,7 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 603 | 578 | //TODO BUSQUEDA POR DESCRIPCION |
| 604 | 579 | var busqueda: List<Articles>? = null |
| 605 | 580 | return GlobalScope.async(Dispatchers.IO) { |
| 606 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, iArea) | |
| 581 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) | |
| 607 | 582 | return@async busqueda |
| 608 | 583 | }.await() |
| 609 | 584 | } |
| ... | ... | @@ -660,7 +635,7 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 660 | 635 | //TODO BUSQUEDA POR DESCRIPCION |
| 661 | 636 | var busqueda: Articles? = null |
| 662 | 637 | return GlobalScope.async(Dispatchers.IO) { |
| 663 | - busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, iArea) | |
| 638 | + busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) | |
| 664 | 639 | return@async busqueda |
| 665 | 640 | }.await() |
| 666 | 641 | } |
| ... | ... | @@ -684,7 +659,7 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 684 | 659 | |
| 685 | 660 | fun cargarRecicler(articulos: Articles, cant: Float) { |
| 686 | 661 | //TODO CARGO EN LE RV |
| 687 | - val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen) | |
| 662 | + val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(),articulos.de.toString()) | |
| 688 | 663 | listArticulos.add(item) |
| 689 | 664 | |
| 690 | 665 | viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) |
| ... | ... | @@ -744,9 +719,10 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 744 | 719 | return prodInclu |
| 745 | 720 | } |
| 746 | 721 | |
| 747 | - private fun SerchArea() { | |
| 722 | + private fun SerchArea(): Int { | |
| 748 | 723 | if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 |
| 749 | 724 | if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 |
| 725 | + return iArea | |
| 750 | 726 | } |
| 751 | 727 | |
| 752 | 728 | fun ObtenerFechaActual(): String? { |
| ... | ... | @@ -788,50 +764,51 @@ class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickList |
| 788 | 764 | } |
| 789 | 765 | |
| 790 | 766 | override fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) { |
| 791 | - | |
| 792 | - val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 793 | - val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[position.toInt()].descripcion}") | |
| 794 | -// .setCancelable(false) | |
| 795 | - mDialogView.tvCantInicial.text = cantidad | |
| 796 | - val mAlertDialog = mBuilder.show() | |
| 797 | - mDialogView.rbSumar.setOnClickListener { | |
| 798 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 799 | - mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 800 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 801 | - } | |
| 802 | - } | |
| 803 | - mDialogView.rbRestar.setOnClickListener { | |
| 804 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 805 | - if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
| 806 | - mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 807 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 808 | - } | |
| 809 | - } | |
| 810 | - } | |
| 811 | - mDialogView.rbMdodificar.setOnClickListener { | |
| 812 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 813 | - mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 814 | - mDialogView.tvNuevaCantidad.isEnabled=false | |
| 815 | - } | |
| 816 | - } | |
| 817 | - mDialogView.btnAceptar.setOnClickListener { | |
| 818 | - if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 819 | - mAlertDialog.dismiss() | |
| 820 | - val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 821 | - fCant = 0F | |
| 822 | - fCant = name | |
| 823 | - listArticulos[position.toInt()].cantTomada = fCant | |
| 824 | - updateCantidad(listArticulos[position.toInt()].sector.toString(), listArticulos[position.toInt()].codigo.toString(), fCant) | |
| 825 | - viewAdapter.notifyDataSetChanged() | |
| 826 | - } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 827 | - mDialogView.tvNuevaCantidad.error = "No vacio" | |
| 828 | - mDialogView.tvNuevaCantidad.requestFocus() | |
| 829 | - mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
| 830 | - } | |
| 831 | - } | |
| 832 | - mDialogView.dialogCancelBtn.setOnClickListener { | |
| 833 | - mAlertDialog.dismiss() | |
| 834 | - } | |
| 767 | + dialogoSumaResta(requireContext(), position.toInt(), listArticulos[position.toInt()].univta) | |
| 768 | + | |
| 769 | +// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 770 | +// val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[position.toInt()].descripcion}") | |
| 771 | +//// .setCancelable(false) | |
| 772 | +// mDialogView.tvCantInicial.text = cantidad | |
| 773 | +// val mAlertDialog = mBuilder.show() | |
| 774 | +// mDialogView.rbSumar.setOnClickListener { | |
| 775 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 776 | +// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 777 | +// mDialogView.tvNuevaCantidad.isEnabled=false | |
| 778 | +// } | |
| 779 | +// } | |
| 780 | +// mDialogView.rbRestar.setOnClickListener { | |
| 781 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 782 | +// if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | |
| 783 | +// mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 784 | +// mDialogView.tvNuevaCantidad.isEnabled=false | |
| 785 | +// } | |
| 786 | +// } | |
| 787 | +// } | |
| 788 | +// mDialogView.rbMdodificar.setOnClickListener { | |
| 789 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 790 | +// mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | |
| 791 | +// mDialogView.tvNuevaCantidad.isEnabled=false | |
| 792 | +// } | |
| 793 | +// } | |
| 794 | +// mDialogView.btnAceptar.setOnClickListener { | |
| 795 | +// if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 796 | +// mAlertDialog.dismiss() | |
| 797 | +// val name = mDialogView.tvgenerico4.text.toString().toFloat() | |
| 798 | +// fCant = 0F | |
| 799 | +// fCant = name | |
| 800 | +// listArticulos[position.toInt()].cantTomada = fCant | |
| 801 | +// updateCantidad(listArticulos[position.toInt()].sector.toString(), listArticulos[position.toInt()].codigo.toString(), fCant) | |
| 802 | +// viewAdapter.notifyDataSetChanged() | |
| 803 | +// } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | |
| 804 | +// mDialogView.tvNuevaCantidad.error = "No vacio" | |
| 805 | +// mDialogView.tvNuevaCantidad.requestFocus() | |
| 806 | +// mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | |
| 807 | +// } | |
| 808 | +// } | |
| 809 | +// mDialogView.dialogCancelBtn.setOnClickListener { | |
| 810 | +// mAlertDialog.dismiss() | |
| 811 | +// } | |
| 835 | 812 | } |
| 836 | 813 | } |
| 837 | 814 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ItemsRecycler.kt
| ... | ... | @@ -2,6 +2,6 @@ package com.focasoftware.deboinventariov20.ui.inventario |
| 2 | 2 | |
| 3 | 3 | import android.widget.ImageView |
| 4 | 4 | |
| 5 | -data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?) { | |
| 5 | +data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?,val univta: String,val dev:String) { | |
| 6 | 6 | |
| 7 | 7 | } |
| 8 | 8 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ProductosListAdapter.kt
| ... | ... | @@ -17,17 +17,12 @@ class ProductosListAdapter(private val context: Context,private val productos: A |
| 17 | 17 | |
| 18 | 18 | private var removePosition: Int = 0 |
| 19 | 19 | private var removedItem: ItemsRecycler? = null |
| 20 | -// private var items2: ArrayList<ItemsRecycler>? = null | |
| 21 | 20 | |
| 22 | 21 | interface OnImageDotsClickListener { |
| 23 | 22 | fun onImageDotsClick(sector: String?,codigo: String?) |
| 24 | 23 | fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | -// init { | |
| 28 | -// this.items2 = productos | |
| 29 | -// } | |
| 30 | - | |
| 31 | 26 | override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) |
| 32 | 27 | |
| 33 | 28 | override fun getItemCount() = productos.size |
| ... | ... | @@ -51,22 +46,7 @@ class ProductosListAdapter(private val context: Context,private val productos: A |
| 51 | 46 | itemView.tvCodigoOrigen.text=item.sector |
| 52 | 47 | itemView.ivPen.setImageResource(R.drawable.pen) |
| 53 | 48 | itemView.ivDots.setImageResource(R.drawable.more) |
| 54 | - | |
| 55 | 49 | } |
| 56 | -// val sector = itemView.tvSector | |
| 57 | -// val codigo = itemView.tvCodigo | |
| 58 | -// val descripcion = itemView.tvDescripcion | |
| 59 | -// val cantCont = itemView.tvCantidad | |
| 60 | -// val codigoBarras = itemView.tvCodigoBarras | |
| 61 | -// val codigoOrigen = itemView.tvCodigoOrigen | |
| 62 | -// val imageDots = itemView.ivDots | |
| 63 | -// val imagePen = itemView.ivPen | |
| 64 | -// | |
| 65 | -// fun bind(pro: ItemsRecycler) { | |
| 66 | -// | |
| 67 | -// } | |
| 68 | - | |
| 69 | - | |
| 70 | 50 | } |
| 71 | 51 | |
| 72 | 52 | fun removeItem(viewHolder: RecyclerView.ViewHolder) { |
| ... | ... | @@ -75,11 +55,6 @@ class ProductosListAdapter(private val context: Context,private val productos: A |
| 75 | 55 | |
| 76 | 56 | productos.removeAt(viewHolder.adapterPosition) |
| 77 | 57 | notifyItemRemoved(viewHolder.adapterPosition) |
| 78 | -// | |
| 79 | -// Snackbar.make(viewHolder.itemView, "El articulo fue ${removedItem!!.descripcion} eliminado", Snackbar.LENGTH_LONG).setAction("Rehacer") { | |
| 80 | -// productos.add(removePosition, removedItem!!) | |
| 81 | -// notifyItemInserted(removePosition) | |
| 82 | -// }.show() | |
| 83 | 58 | } |
| 84 | 59 | |
| 85 | 60 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/InventarioListAdapter.kt
| ... | ... | @@ -10,7 +10,7 @@ import com.focasoftware.deboinventariov20.R |
| 10 | 10 | import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder |
| 11 | 11 | import kotlinx.android.synthetic.main.item_principal.view.* |
| 12 | 12 | |
| 13 | -class InventarioListAdapter(private val context: Context, private val inv: ArrayList<InvHead>, private val itemClickListener: OnInventarioClickListener) : | |
| 13 | +class InventarioListAdapter(private val context: Context, private val inv: List<InvHead>, private val itemClickListener: OnInventarioClickListener) : | |
| 14 | 14 | RecyclerView.Adapter<BaseViewHolder<*>>() { |
| 15 | 15 | |
| 16 | 16 | interface OnInventarioClickListener { |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
| ... | ... | @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView |
| 18 | 18 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
| 19 | 19 | import com.focasoftware.deboinventariov20.Model.InvHead |
| 20 | 20 | import com.focasoftware.deboinventariov20.R |
| 21 | +import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | |
| 21 | 22 | import kotlinx.coroutines.Dispatchers |
| 22 | 23 | import kotlinx.coroutines.GlobalScope |
| 23 | 24 | import kotlinx.coroutines.async |
| ... | ... | @@ -25,12 +26,13 @@ import kotlinx.coroutines.launch |
| 25 | 26 | import java.util.* |
| 26 | 27 | |
| 27 | 28 | class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { |
| 28 | - private lateinit var inventarios: ArrayList<InvHead> | |
| 29 | - private lateinit var ordenado: ArrayList<InvHead> | |
| 29 | + private lateinit var inventarios: List<InvHead> | |
| 30 | + private lateinit var ordenado: List<InvHead> | |
| 30 | 31 | private lateinit var rcInventario: RecyclerView |
| 31 | 32 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
| 32 | 33 | private lateinit var viewManager: RecyclerView.LayoutManager |
| 33 | - private var listIvn = ArrayList<InvHead>() | |
| 34 | +// private var listIvn2 = List<InvHead>() | |
| 35 | +private var listIvn2 = ArrayList<InvHead>() | |
| 34 | 36 | private lateinit var navController: NavController |
| 35 | 37 | private lateinit var sharedPreferences: SharedPreferences |
| 36 | 38 | private var cantidadInventarios: Int = 0 |
| ... | ... | @@ -45,7 +47,6 @@ class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener |
| 45 | 47 | val v = inflater.inflate(R.layout.fragment_main, container, false) |
| 46 | 48 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) |
| 47 | 49 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) |
| 48 | - val tvFecha = v.findViewById<TextView>(R.id.tvFecha) | |
| 49 | 50 | val ivSort19= v.findViewById<ImageView>(R.id.ivSort19) |
| 50 | 51 | val ivSort91= v.findViewById<ImageView>(R.id.ivSort91) |
| 51 | 52 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) |
| ... | ... | @@ -68,34 +69,47 @@ class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener |
| 68 | 69 | cargarRecicler(inv) |
| 69 | 70 | cantidadInventarios = i + 1 |
| 70 | 71 | } |
| 71 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})+" | |
| 72 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
| 72 | 73 | tvInvDinamicos.setOnClickListener { |
| 73 | 74 | if (!bAbiertoCerrado) { |
| 74 | 75 | bAbiertoCerrado = true |
| 75 | 76 | txtDeposito.visibility = View.GONE |
| 76 | 77 | rcInventario.visibility = View.VISIBLE |
| 77 | - ivSort91.visibility = View.VISIBLE | |
| 78 | - ivSort19.visibility = View.INVISIBLE | |
| 79 | - tvFecha.visibility = View.VISIBLE | |
| 78 | + ivSort91.visibility = View.INVISIBLE | |
| 79 | + ivSort19.visibility = View.VISIBLE | |
| 80 | 80 | cbVentas.visibility = View.VISIBLE |
| 81 | 81 | cbDeposito.visibility = View.VISIBLE |
| 82 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})-" | |
| 82 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" | |
| 83 | 83 | } else { |
| 84 | 84 | bAbiertoCerrado = false |
| 85 | 85 | rcInventario.visibility = View.GONE |
| 86 | 86 | ivSort91.visibility = View.GONE |
| 87 | 87 | ivSort19.visibility = View.GONE |
| 88 | - tvFecha.visibility = View.GONE | |
| 89 | 88 | txtDeposito.visibility = View.VISIBLE |
| 90 | 89 | cbVentas.visibility = View.GONE |
| 91 | 90 | cbDeposito.visibility = View.GONE |
| 92 | - tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})+" | |
| 91 | + tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | |
| 93 | 92 | } |
| 94 | 93 | } |
| 95 | - ivSort91.setOnClickListener { | |
| 94 | + ivSort19.setOnClickListener { | |
| 96 | 95 | ordenado= inventarios.sortedByDescending { |
| 97 | 96 | it.invNum |
| 98 | - } as ArrayList<InvHead> | |
| 97 | + } | |
| 98 | + viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | |
| 99 | + viewManager = LinearLayoutManager(requireContext()) | |
| 100 | + | |
| 101 | + rcInventario.apply { | |
| 102 | + adapter = viewAdapter | |
| 103 | + layoutManager = viewManager | |
| 104 | + } | |
| 105 | + viewAdapter.notifyDataSetChanged() | |
| 106 | + ivSort19.visibility=View.INVISIBLE | |
| 107 | + ivSort91.visibility=View.VISIBLE | |
| 108 | + } | |
| 109 | + ivSort91.setOnClickListener { | |
| 110 | + ordenado= inventarios.sortedBy { | |
| 111 | + it.invNum | |
| 112 | + } | |
| 99 | 113 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) |
| 100 | 114 | viewManager = LinearLayoutManager(requireContext()) |
| 101 | 115 | |
| ... | ... | @@ -104,14 +118,16 @@ class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener |
| 104 | 118 | layoutManager = viewManager |
| 105 | 119 | } |
| 106 | 120 | viewAdapter.notifyDataSetChanged() |
| 121 | + ivSort91.visibility=View.INVISIBLE | |
| 122 | + ivSort19.visibility=View.VISIBLE | |
| 107 | 123 | } |
| 108 | 124 | } |
| 109 | 125 | return v |
| 110 | 126 | } |
| 111 | 127 | |
| 112 | - suspend fun buscarEnBDInvHead(): ArrayList<InvHead> { | |
| 128 | + suspend fun buscarEnBDInvHead(): List<InvHead> { | |
| 113 | 129 | //TODO BUSQUEDA POR DESCRIPCION |
| 114 | - var busqueda: ArrayList<InvHead> | |
| 130 | + var busqueda: List<InvHead> | |
| 115 | 131 | return GlobalScope.async(Dispatchers.IO) { |
| 116 | 132 | busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() |
| 117 | 133 | return@async busqueda |
| ... | ... | @@ -125,8 +141,8 @@ class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener |
| 125 | 141 | val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") |
| 126 | 142 | //(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar) |
| 127 | 143 | // listIvn.add(item) |
| 128 | - listIvn.add(inv) | |
| 129 | - viewAdapter = InventarioListAdapter(requireContext(), listIvn, this) | |
| 144 | + listIvn2.add(inv) | |
| 145 | + viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) | |
| 130 | 146 | viewManager = LinearLayoutManager(requireContext()) |
| 131 | 147 | |
| 132 | 148 | rcInventario.apply { |
| ... | ... | @@ -138,7 +154,7 @@ class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener |
| 138 | 154 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 139 | 155 | super.onViewCreated(view, savedInstanceState) |
| 140 | 156 | navController = Navigation.findNavController(view) |
| 141 | - listIvn.clear() | |
| 157 | + listIvn2.clear() | |
| 142 | 158 | } |
| 143 | 159 | |
| 144 | 160 | override fun onItemClick(inventario: String?) { |
app/src/main/res/layout/fragment_main.xml
| ... | ... | @@ -25,9 +25,10 @@ |
| 25 | 25 | |
| 26 | 26 | <ImageView |
| 27 | 27 | android:id="@+id/ivSort19" |
| 28 | - android:layout_width="wrap_content" | |
| 29 | - android:layout_height="wrap_content" | |
| 28 | + android:layout_width="35dp" | |
| 29 | + android:layout_height="35dp" | |
| 30 | 30 | android:layout_margin="10dp" |
| 31 | + android:padding="5dp" | |
| 31 | 32 | android:contentDescription=" " |
| 32 | 33 | android:visibility="gone" |
| 33 | 34 | android:src="@drawable/ic_sort19" |
| ... | ... | @@ -38,11 +39,12 @@ |
| 38 | 39 | |
| 39 | 40 | <ImageView |
| 40 | 41 | android:id="@+id/ivSort91" |
| 41 | - android:layout_width="wrap_content" | |
| 42 | - android:layout_height="wrap_content" | |
| 42 | + android:layout_width="35dp" | |
| 43 | + android:layout_height="35dp" | |
| 43 | 44 | android:layout_margin="10dp" |
| 45 | + android:padding="5dp" | |
| 44 | 46 | android:layout_marginTop="12dp" |
| 45 | - android:contentDescription=" " | |
| 47 | + android:contentDescription="Fecha" | |
| 46 | 48 | android:visibility="gone" |
| 47 | 49 | android:src="@drawable/ic_sort91" |
| 48 | 50 | app:layout_constraintHorizontal_bias="1.0" |
| ... | ... | @@ -50,20 +52,6 @@ |
| 50 | 52 | app:layout_constraintStart_toStartOf="parent" |
| 51 | 53 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
| 52 | 54 | |
| 53 | - <TextView | |
| 54 | - android:id="@+id/tvFecha" | |
| 55 | - android:layout_width="wrap_content" | |
| 56 | - android:layout_height="wrap_content" | |
| 57 | - android:layout_marginTop="5dp" | |
| 58 | - android:text="Fecha" | |
| 59 | - android:textColor="@android:color/black" | |
| 60 | - android:textSize="25sp" | |
| 61 | - android:visibility="gone" | |
| 62 | - android:textStyle="bold" | |
| 63 | - app:layout_constraintBottom_toTopOf="@id/rcInventario" | |
| 64 | - app:layout_constraintHorizontal_chainStyle="packed" | |
| 65 | - app:layout_constraintStart_toEndOf="@+id/ivSort19" | |
| 66 | - app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | |
| 67 | 55 | |
| 68 | 56 | <androidx.recyclerview.widget.RecyclerView |
| 69 | 57 | android:id="@+id/rcInventario" |
| ... | ... | @@ -74,7 +62,7 @@ |
| 74 | 62 | android:visibility="gone" |
| 75 | 63 | app:layout_constraintEnd_toEndOf="parent" |
| 76 | 64 | app:layout_constraintStart_toStartOf="parent" |
| 77 | - app:layout_constraintTop_toBottomOf="@id/tvFecha" | |
| 65 | + app:layout_constraintTop_toBottomOf="@id/ivSort19" | |
| 78 | 66 | tools:listitem="@layout/item_principal" /> |
| 79 | 67 | |
| 80 | 68 | <com.google.android.material.checkbox.MaterialCheckBox |
| ... | ... | @@ -83,6 +71,7 @@ |
| 83 | 71 | android:layout_height="wrap_content" |
| 84 | 72 | android:layout_margin="5dp" |
| 85 | 73 | android:text="Ventas" |
| 74 | + android:checked="true" | |
| 86 | 75 | android:visibility="gone" |
| 87 | 76 | app:layout_constraintEnd_toStartOf="@+id/cbDeposito" |
| 88 | 77 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
| ... | ... | @@ -94,6 +83,7 @@ |
| 94 | 83 | android:layout_margin="5dp" |
| 95 | 84 | android:visibility="gone" |
| 96 | 85 | android:text="Deposito" |
| 86 | + android:checked="true" | |
| 97 | 87 | app:layout_constraintEnd_toEndOf="parent" |
| 98 | 88 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
| 99 | 89 |
gradle/wrapper/gradle-wrapper.properties
| ... | ... | @@ -4,3 +4,18 @@ distributionPath=wrapper/dists |
| 4 | 4 | zipStoreBase=GRADLE_USER_HOME |
| 5 | 5 | zipStorePath=wrapper/dists |
| 6 | 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
| 7 | + | |
| 8 | +# Enable Kapt Incremental annotation processing requeste | |
| 9 | +kapt.incremental.apt=true | |
| 10 | + | |
| 11 | +# Enable android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC) | |
| 12 | +android.databinding.incremental=true | |
| 13 | + | |
| 14 | +# Decrease gradle builds time | |
| 15 | +kapt.use.worker.api=true | |
| 16 | + | |
| 17 | +# turn off AP discovery in compile path, and therefore turn on Compile Avoidance | |
| 18 | +kapt.include.compile.classpath=false | |
| 19 | + | |
| 20 | +# Enable In Logcat to determine Kapt | |
| 21 | +kapt.verbose=true | |
| 7 | 22 | \ No newline at end of file |