Commit b5325948ae96a5ebefaccc8101e7d5b2645b3124
1 parent
23f89b25e1
Exists in
master
24022020 1214
Showing
11 changed files
with
235 additions
and
183 deletions
Show diff stats
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionFragment.kt
| ... | ... | @@ -6,6 +6,7 @@ import android.graphics.Canvas |
| 6 | 6 | import android.graphics.Color |
| 7 | 7 | import android.graphics.drawable.ColorDrawable |
| 8 | 8 | import android.os.Bundle |
| 9 | +import android.text.InputType | |
| 9 | 10 | import android.view.LayoutInflater |
| 10 | 11 | import android.view.View |
| 11 | 12 | import android.view.ViewGroup |
| ... | ... | @@ -39,6 +40,7 @@ class DescripcionFragment : Fragment() { |
| 39 | 40 | private var numeroInventario = 0 |
| 40 | 41 | lateinit var navController: NavController |
| 41 | 42 | lateinit var sharedPreferences: SharedPreferences |
| 43 | + private var indice=0 | |
| 42 | 44 | |
| 43 | 45 | override fun onCreate(savedInstanceState: Bundle?) { |
| 44 | 46 | super.onCreate(savedInstanceState) |
| ... | ... | @@ -55,7 +57,6 @@ class DescripcionFragment : Fragment() { |
| 55 | 57 | } |
| 56 | 58 | |
| 57 | 59 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
| 58 | - // Inflate the layout for this fragment | |
| 59 | 60 | val v = inflater.inflate(R.layout.fragment_descripcion, container, false) |
| 60 | 61 | rcDescripcion = v.findViewById(R.id.rcDescripcion) |
| 61 | 62 | val btnSalir = v.findViewById<Button>(R.id.btnSalir) |
| ... | ... | @@ -83,10 +84,11 @@ class DescripcionFragment : Fragment() { |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { |
| 87 | + val type = InputType.TYPE_CLASS_PHONE | |
| 86 | 88 | MaterialDialog(requireContext()).show { |
| 87 | - title(R.string.sTitulo) | |
| 89 | + title(text = "Producto: ${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}") | |
| 88 | 90 | message(R.string.sMensajeEncontrado) |
| 89 | - input { materialDialog, charSequence -> | |
| 91 | + input (waitForPositiveButton = false ,hint = "99.99", inputType = type){ materialDialog, charSequence -> | |
| 90 | 92 | cantidad = 0F |
| 91 | 93 | cantidad = charSequence.toString().toFloat() |
| 92 | 94 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/DialogNoEncontrado.kt
| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | +package com.focasoftware.deboinventariov20.ui.dialogos | |
| 2 | + | |
| 3 | +import android.app.AlertDialog | |
| 4 | +import android.app.Dialog | |
| 5 | +import android.content.DialogInterface | |
| 6 | +import android.os.Bundle | |
| 7 | +import android.view.LayoutInflater | |
| 8 | +import androidx.fragment.app.DialogFragment | |
| 9 | +import com.focasoftware.deboinventariov20.R | |
| 10 | +import kotlinx.android.synthetic.main.ingresar_cantidad.* | |
| 11 | +import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | |
| 12 | + | |
| 13 | +class DialogNoEncontrado : DialogFragment() { | |
| 14 | + | |
| 15 | + fun newInstance(title: String, s: String): DialogNoEncontrado? { | |
| 16 | + val dialog = DialogNoEncontrado() | |
| 17 | + | |
| 18 | + val args = Bundle() | |
| 19 | + args.putString("title", title) | |
| 20 | + args.putString("s", s) | |
| 21 | + dialog.arguments = args | |
| 22 | + return dialog | |
| 23 | + } | |
| 24 | + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
| 25 | + return activity?.let { | |
| 26 | + val args = requireArguments() | |
| 27 | + val title = args.getString("title") | |
| 28 | + val s = args.getString("s") | |
| 29 | + | |
| 30 | + val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | |
| 31 | + val inflater = requireActivity().layoutInflater; | |
| 32 | + | |
| 33 | + builder.setView(inflater.inflate(R.layout.ingresar_cantidad, null)) | |
| 34 | + .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, id ->}) | |
| 35 | + | |
| 36 | + | |
| 37 | + builder.create() | |
| 38 | + } ?: throw IllegalStateException("Activity cannot be null") | |
| 39 | + } | |
| 40 | + | |
| 41 | +} | |
| 42 | + |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/dialogoLogin.kt
| ... | ... | @@ -37,7 +37,7 @@ class dialogoLogin() : DialogFragment() { |
| 37 | 37 | // val title = args.getString("title") |
| 38 | 38 | val inflater = requireActivity().layoutInflater; |
| 39 | 39 | |
| 40 | - builder.setView(inflater.inflate(R.layout.dialog_signin, null)) | |
| 40 | + builder.setView(inflater.inflate(R.layout.login_dialog, null)) | |
| 41 | 41 | .setTitle("El producto ya fue escaneado") |
| 42 | 42 | // .setMessage("La cantidad cargada es $title") |
| 43 | 43 | .setPositiveButton(android.R.string.ok) { _, _ -> |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
| ... | ... | @@ -6,6 +6,7 @@ import android.graphics.Canvas |
| 6 | 6 | import android.graphics.Color |
| 7 | 7 | import android.graphics.drawable.Drawable |
| 8 | 8 | import android.os.Bundle |
| 9 | +import android.text.InputType | |
| 9 | 10 | import android.view.KeyEvent |
| 10 | 11 | import android.view.LayoutInflater |
| 11 | 12 | import android.view.View |
| ... | ... | @@ -114,26 +115,34 @@ class InventarioFragment : Fragment() { |
| 114 | 115 | listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 115 | 116 | viewAdapter.notifyDataSetChanged() |
| 116 | 117 | } else { |
| 117 | - // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 118 | - // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Login Form").setCancelable(false) | |
| 119 | - // val mAlertDialog = mBuilder.show() | |
| 120 | - // mDialogView.dialogLoginBtn.setOnClickListener { | |
| 121 | - // mAlertDialog.dismiss() | |
| 122 | - // //get text from EditTexts of custom layout | |
| 123 | - // val name = mDialogView.dialogNameEt.text.toString() | |
| 124 | - // val email = mDialogView.dialogEmailEt.text.toString() | |
| 125 | - // val password = mDialogView.dialogPasswEt.text.toString() | |
| 126 | - // fCant = 0F | |
| 127 | - // fCant = name.toFloat() | |
| 128 | - // } | |
| 129 | - // mDialogView.dialogCancelBtn.setOnClickListener { | |
| 130 | - // mAlertDialog.dismiss() | |
| 131 | - // } | |
| 118 | + // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 119 | + // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Login Form").setCancelable(false) | |
| 120 | + // val mAlertDialog = mBuilder.show() | |
| 121 | + // mDialogView.dialogLoginBtn.setOnClickListener { | |
| 122 | + // mAlertDialog.dismiss() | |
| 123 | + // //get text from EditTexts of custom layout | |
| 124 | + // val name = mDialogView.dialogNameEt.text.toString() | |
| 125 | + // val email = mDialogView.dialogEmailEt.text.toString() | |
| 126 | + // val password = mDialogView.dialogPasswEt.text.toString() | |
| 127 | + // fCant = 0F | |
| 128 | + // fCant = name.toFloat() | |
| 129 | + // } | |
| 130 | + // mDialogView.dialogCancelBtn.setOnClickListener { | |
| 131 | + // mAlertDialog.dismiss() | |
| 132 | + // } | |
| 132 | 133 | fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 134 | + | |
| 135 | + val type = InputType.TYPE_CLASS_PHONE | |
| 133 | 136 | MaterialDialog(requireContext()).show { |
| 134 | - title(R.string.sTituloNueva) | |
| 135 | - message(R.string.sCantidadNueva) | |
| 136 | - input { materialDialog, charSequence -> | |
| 137 | + | |
| 138 | + title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
| 139 | + message(R.string.sMensajeEncontrado) | |
| 140 | + input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
| 141 | + // val inputField = materialDialog.getInputField() | |
| 142 | + // val isValid = charSequence.isEmpty() | |
| 143 | + // | |
| 144 | + // inputField.error = if (isValid) null else "El campo no puede quedar vacio" | |
| 145 | + // materialDialog.setActionButtonEnabled(WhichButton.POSITIVE, isValid) | |
| 137 | 146 | fCant = 0F |
| 138 | 147 | fCant = charSequence.toString().toFloat() |
| 139 | 148 | } |
| ... | ... | @@ -165,40 +174,40 @@ class InventarioFragment : Fragment() { |
| 165 | 174 | |
| 166 | 175 | } |
| 167 | 176 | 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** |
| 168 | - // | |
| 169 | - // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
| 170 | - // //TODO Si no lo encuentra devuelve -1 | |
| 171 | - // if (indiceDelArtEncontrado != -1) { | |
| 172 | - //// if (swSumaUno!!.isChecked) { | |
| 173 | - //// fCant = 0F | |
| 174 | - //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 175 | - //// fCant += 1F | |
| 176 | - //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 177 | - //// viewAdapter.notifyDataSetChanged() | |
| 178 | - //// } else { | |
| 179 | - // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 180 | - // MaterialDialog(requireContext()).show { | |
| 181 | - // title(R.string.sTituloNueva) | |
| 182 | - // message(R.string.sCantidadNueva) | |
| 183 | - // input { materialDialog, charSequence -> | |
| 184 | - // fCant = 0F | |
| 185 | - // fCant = charSequence.toString().toFloat() | |
| 186 | - // } | |
| 187 | - // positiveButton(R.string.btnOk) { | |
| 188 | - // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 189 | - // viewAdapter.notifyDataSetChanged() | |
| 190 | - // dismiss() | |
| 191 | - // } | |
| 192 | - // }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 193 | - //// } | |
| 194 | - // | |
| 195 | - // } else if | |
| 196 | - // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
| 177 | + // | |
| 178 | + // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
| 179 | + // //TODO Si no lo encuentra devuelve -1 | |
| 180 | + // if (indiceDelArtEncontrado != -1) { | |
| 181 | + //// if (swSumaUno!!.isChecked) { | |
| 182 | + //// fCant = 0F | |
| 183 | + //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 184 | + //// fCant += 1F | |
| 185 | + //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 186 | + //// viewAdapter.notifyDataSetChanged() | |
| 187 | + //// } else { | |
| 188 | + // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 189 | + // MaterialDialog(requireContext()).show { | |
| 190 | + // title(R.string.sTituloNueva) | |
| 191 | + // message(R.string.sCantidadNueva) | |
| 192 | + // input { materialDialog, charSequence -> | |
| 193 | + // fCant = 0F | |
| 194 | + // fCant = charSequence.toString().toFloat() | |
| 195 | + // } | |
| 196 | + // positiveButton(R.string.btnOk) { | |
| 197 | + // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 198 | + // viewAdapter.notifyDataSetChanged() | |
| 199 | + // dismiss() | |
| 200 | + // } | |
| 201 | + // }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 202 | + //// } | |
| 203 | + // | |
| 204 | + // } else if | |
| 205 | + // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
| 197 | 206 | GlobalScope.launch(Dispatchers.Main) { |
| 198 | 207 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 199 | 208 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) |
| 200 | 209 | } |
| 201 | - // } | |
| 210 | + // } | |
| 202 | 211 | tCodigoBarras.focusable = View.FOCUSABLE |
| 203 | 212 | tCodigoBarras.setText("") |
| 204 | 213 | tCodigoBarras.selectAll() |
| ... | ... | @@ -218,26 +227,13 @@ class InventarioFragment : Fragment() { |
| 218 | 227 | listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 219 | 228 | viewAdapter.notifyDataSetChanged() |
| 220 | 229 | } else { |
| 221 | - // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 222 | - // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Login Form").setCancelable(false) | |
| 223 | - // val mAlertDialog = mBuilder.show() | |
| 224 | - // mDialogView.dialogLoginBtn.setOnClickListener { | |
| 225 | - // mAlertDialog.dismiss() | |
| 226 | - // //get text from EditTexts of custom layout | |
| 227 | - // val name = mDialogView.dialogNameEt.text.toString() | |
| 228 | - // val email = mDialogView.dialogEmailEt.text.toString() | |
| 229 | - // val password = mDialogView.dialogPasswEt.text.toString() | |
| 230 | - // fCant = 0F | |
| 231 | - // fCant = name.toFloat() | |
| 232 | - // } | |
| 233 | - // mDialogView.dialogCancelBtn.setOnClickListener { | |
| 234 | - // mAlertDialog.dismiss() | |
| 235 | - // } | |
| 236 | 230 | fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 231 | + val type = InputType.TYPE_CLASS_PHONE | |
| 237 | 232 | MaterialDialog(requireContext()).show { |
| 238 | - title(R.string.sTituloNueva) | |
| 233 | + | |
| 234 | + title(text = "Producto '$sChangeUpper', se encuentra cargado.") | |
| 239 | 235 | message(R.string.sCantidadNueva) |
| 240 | - input { materialDialog, charSequence -> | |
| 236 | + input (waitForPositiveButton = false ,hint = "99.99", inputType = type){ materialDialog, charSequence -> | |
| 241 | 237 | fCant = 0F |
| 242 | 238 | fCant = charSequence.toString().toFloat() |
| 243 | 239 | } |
| ... | ... | @@ -324,19 +320,19 @@ class InventarioFragment : Fragment() { |
| 324 | 320 | ivCamara.setImageResource(R.drawable.codbar) |
| 325 | 321 | etCodigoBarras.hint = "Busqueda por C. Barras" |
| 326 | 322 | swSumaUno.visibility = View.VISIBLE |
| 327 | - iEstado = 1 | |
| 323 | + iEstado = 0 | |
| 328 | 324 | } |
| 329 | 325 | 1 -> { |
| 330 | 326 | ivCamara.setImageResource(R.drawable.desc) |
| 331 | 327 | etCodigoBarras.hint = "Busqueda por Descripción" |
| 332 | 328 | swSumaUno.visibility = View.GONE |
| 333 | - iEstado = 2 | |
| 329 | + iEstado = 1 | |
| 334 | 330 | } |
| 335 | 331 | 2 -> { |
| 336 | 332 | ivCamara.setImageResource(R.drawable.cod_origen) |
| 337 | 333 | etCodigoBarras.hint = "Busqueda por C. Origen" |
| 338 | 334 | swSumaUno.visibility = View.GONE |
| 339 | - iEstado = 0 | |
| 335 | + iEstado = 2 | |
| 340 | 336 | } |
| 341 | 337 | } |
| 342 | 338 | } |
| ... | ... | @@ -438,13 +434,39 @@ class InventarioFragment : Fragment() { |
| 438 | 434 | // } |
| 439 | 435 | // } |
| 440 | 436 | } else {//TODO si no lo encuentra en la BD |
| 441 | - MaterialDialog(requireContext()).show { | |
| 442 | - title(R.string.sTitulo) | |
| 443 | - message(R.string.sMensaje) | |
| 444 | - positiveButton(R.string.btnOk) { | |
| 445 | - dismiss() | |
| 446 | - } | |
| 447 | - }.cornerRadius(10F) | |
| 437 | +// MaterialDialog(requireContext()).show { | |
| 438 | +// title(R.string.sTitulo) | |
| 439 | +// message(R.string.sMensaje) | |
| 440 | +// positiveButton(R.string.btnOk) { | |
| 441 | +// dismiss() | |
| 442 | +// } | |
| 443 | +// }.cornerRadius(10F) | |
| 444 | + | |
| 445 | +// val modalDialog = DialogNoEncontrado() | |
| 446 | +// modalDialog.isCancelable=false | |
| 447 | +// modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | |
| 448 | +// | |
| 449 | +// | |
| 450 | +// val modalDialog = DialogNoEncontrado().newInstance( | |
| 451 | +// "El producto $etCodigoBarras.text.toString()", | |
| 452 | +// "No se encotro en la Base de Datos." | |
| 453 | +// ) | |
| 454 | +// modalDialog?.show(requireActivity().supportFragmentManager, "DialogFragment") | |
| 455 | + | |
| 456 | +// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 457 | +// val mBuilder = AlertDialog.Builder(requireContext()).setView(mDialogView).setTitle("Login Form").setCancelable(false) | |
| 458 | +// val mAlertDialog = mBuilder.show() | |
| 459 | +// mDialogView.dialogLoginBtn.setOnClickListener { | |
| 460 | +// mAlertDialog.dismiss() | |
| 461 | +// //get text from EditTexts of custom layout | |
| 462 | +// val name = mDialogView.tvgenerico4.text.toString() | |
| 463 | +// | |
| 464 | +//// fCant = 0F | |
| 465 | +//// fCant = name.toFloat() | |
| 466 | +// } | |
| 467 | +// mDialogView.dialogCancelBtn.setOnClickListener { | |
| 468 | +// mAlertDialog.dismiss() | |
| 469 | +// } | |
| 448 | 470 | } |
| 449 | 471 | |
| 450 | 472 | } |
| ... | ... | @@ -459,14 +481,20 @@ class InventarioFragment : Fragment() { |
| 459 | 481 | cargarArtEnBd(artAcargar, fCant) |
| 460 | 482 | cargarRecicler(artAcargar, fCant) |
| 461 | 483 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD |
| 484 | + val type = InputType.TYPE_CLASS_PHONE | |
| 462 | 485 | MaterialDialog(requireContext()).show { |
| 463 | - title(R.string.sTitulo) | |
| 486 | + | |
| 487 | + title(text = "Producto: $sChangeUpper") | |
| 464 | 488 | message(R.string.sMensajeEncontrado) |
| 465 | - input { materialDialog, charSequence -> | |
| 489 | + input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | |
| 490 | +// val inputField = materialDialog.getInputField() | |
| 491 | +// val isValid = charSequence.isEmpty() | |
| 492 | +// | |
| 493 | +// inputField.error = if (isValid) null else "El campo no puede quedar vacio" | |
| 494 | +// materialDialog.setActionButtonEnabled(WhichButton.POSITIVE, isValid) | |
| 466 | 495 | fCant = 0F |
| 467 | 496 | fCant = charSequence.toString().toFloat() |
| 468 | 497 | } |
| 469 | -// .input("Cantidad",1,,1,0,InputType.TYPE_CLASS_NUMBER,0,waitForPositiveButton = true,false,positiveButton ()) | |
| 470 | 498 | positiveButton(R.string.btnOk) { |
| 471 | 499 | dismiss() |
| 472 | 500 | cargarArtEnBd(artAcargar, fCant) |
| ... | ... | @@ -476,16 +504,13 @@ class InventarioFragment : Fragment() { |
| 476 | 504 | }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 477 | 505 | } |
| 478 | 506 | } else {// TODO si no lo encuentra en la BD |
| 507 | + | |
| 479 | 508 | MaterialDialog(requireContext()).show { |
| 480 | - title(R.string.sTitulo) | |
| 481 | - message(R.string.sMensaje) | |
| 482 | - positiveButton(R.string.btnOk) { | |
| 483 | -// if (this.swSumaUno.isChecked) { | |
| 484 | -// swSumaUno.isChecked=false | |
| 485 | -// } | |
| 486 | - dismiss() | |
| 487 | - } | |
| 488 | - }.cornerRadius(10F) | |
| 509 | + title(text = "El producto: $sChangeUpper") | |
| 510 | + message(text = "¡No fue encontrado!") | |
| 511 | + positiveButton(R.string.btnOk) {} | |
| 512 | + dismiss() | |
| 513 | + } | |
| 489 | 514 | } |
| 490 | 515 | } |
| 491 | 516 | |
| ... | ... | @@ -526,7 +551,7 @@ class InventarioFragment : Fragment() { |
| 526 | 551 | } |
| 527 | 552 | indice += 1 |
| 528 | 553 | } |
| 529 | - }else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | |
| 554 | + } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | |
| 530 | 555 | for (item in listArticulos) { |
| 531 | 556 | if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
| 532 | 557 | bEncontrado = true |
| ... | ... | @@ -559,7 +584,7 @@ class InventarioFragment : Fragment() { |
| 559 | 584 | fun cargarRecicler(articulos: Articles, cant: Float) { |
| 560 | 585 | |
| 561 | 586 | //TODO CARGO EN LE RV |
| 562 | - val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar,articulos.codOrigen) | |
| 587 | + val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen) | |
| 563 | 588 | listArticulos.add(item) |
| 564 | 589 | |
| 565 | 590 | viewAdapter = ProductosListAdapter(listArticulos) |
| ... | ... | @@ -570,32 +595,32 @@ class InventarioFragment : Fragment() { |
| 570 | 595 | layoutManager = viewManager |
| 571 | 596 | } |
| 572 | 597 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { |
| 573 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 574 | - return false | |
| 575 | - } | |
| 598 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 599 | + return false | |
| 600 | + } | |
| 576 | 601 | |
| 577 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
| 578 | - (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
| 579 | - viewAdapter.notifyDataSetChanged() | |
| 580 | - } | |
| 602 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
| 603 | + (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
| 604 | + viewAdapter.notifyDataSetChanged() | |
| 605 | + } | |
| 581 | 606 | |
| 582 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 583 | - val itemView = viewHolder.itemView | |
| 584 | - val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
| 585 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 607 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 608 | + val itemView = viewHolder.itemView | |
| 609 | + val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
| 610 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 586 | 611 | |
| 587 | - if (dX > 0) { | |
| 612 | + if (dX > 0) { | |
| 588 | 613 | |
| 589 | - if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
| 590 | - else c.drawColor(Color.RED) | |
| 591 | - deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
| 592 | - } else { | |
| 614 | + if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
| 615 | + else c.drawColor(Color.RED) | |
| 616 | + deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
| 617 | + } else { | |
| 593 | 618 | |
| 594 | - } | |
| 595 | - | |
| 596 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 597 | - deleteIcon.draw(c) | |
| 598 | 619 | } |
| 620 | + | |
| 621 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 622 | + deleteIcon.draw(c) | |
| 623 | + } | |
| 599 | 624 | } |
| 600 | 625 | |
| 601 | 626 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/InventarioListAdapter.kt
| ... | ... | @@ -30,7 +30,6 @@ class InventarioListAdapter(private val productos: ArrayList<ItemInventario>, pr |
| 30 | 30 | |
| 31 | 31 | inner class ItemsViewHolder constructor(view: View) : RecyclerView.ViewHolder(view),View.OnClickListener { |
| 32 | 32 | |
| 33 | - | |
| 34 | 33 | val inventario = view.inventario |
| 35 | 34 | init { |
| 36 | 35 | itemView.setOnClickListener(this) |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
| ... | ... | @@ -38,6 +38,7 @@ class MainFragment : Fragment(), InventarioListAdapter.OnItemClickListener { |
| 38 | 38 | |
| 39 | 39 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
| 40 | 40 | val v = inflater.inflate(R.layout.fragment_main, container, false) |
| 41 | + | |
| 41 | 42 | GlobalScope.launch(Dispatchers.Main) { |
| 42 | 43 | inventarios = buscarEnBDInvHead() |
| 43 | 44 | for ((i, item) in inventarios.withIndex()) { |
| ... | ... | @@ -86,6 +87,7 @@ class MainFragment : Fragment(), InventarioListAdapter.OnItemClickListener { |
| 86 | 87 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 87 | 88 | super.onViewCreated(view, savedInstanceState) |
| 88 | 89 | navController = Navigation.findNavController(view) |
| 90 | + listIvn.clear() | |
| 89 | 91 | } |
| 90 | 92 | |
| 91 | 93 | override fun OnItemClick(position: Int) { |
app/src/main/res/layout/dialog_signin.xml
| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | - android:orientation="vertical" | |
| 3 | - android:layout_width="wrap_content" | |
| 4 | - android:layout_height="wrap_content"> | |
| 5 | - | |
| 6 | - <EditText | |
| 7 | - android:id="@+id/username" | |
| 8 | - android:inputType="textEmailAddress" | |
| 9 | - android:layout_width="match_parent" | |
| 10 | - android:layout_height="wrap_content" | |
| 11 | - android:layout_marginTop="16dp" | |
| 12 | - android:layout_marginLeft="4dp" | |
| 13 | - android:layout_marginRight="4dp" | |
| 14 | - android:layout_marginBottom="4dp" | |
| 15 | - android:hint="" /> | |
| 16 | - <EditText | |
| 17 | - android:id="@+id/password" | |
| 18 | - android:inputType="textPassword" | |
| 19 | - android:layout_width="match_parent" | |
| 20 | - android:layout_height="wrap_content" | |
| 21 | - android:layout_marginTop="4dp" | |
| 22 | - android:layout_marginLeft="4dp" | |
| 23 | - android:layout_marginRight="4dp" | |
| 24 | - android:layout_marginBottom="16dp" | |
| 25 | - android:fontFamily="sans-serif" | |
| 26 | - android:hint=""/> | |
| 27 | -</LinearLayout> | |
| 28 | 0 | \ No newline at end of file |
app/src/main/res/layout/ingresar_cantidad.xml
| ... | ... | @@ -8,7 +8,6 @@ |
| 8 | 8 | app:cardCornerRadius="10dp" |
| 9 | 9 | app:cardElevation="5dp" |
| 10 | 10 | android:background="@drawable/md_transparent" |
| 11 | - tools:context=".ui.inventario.InsertCant" | |
| 12 | 11 | tools:ignore="PrivateResource"> |
| 13 | 12 | |
| 14 | 13 | |
| ... | ... | @@ -28,6 +27,7 @@ |
| 28 | 27 | app:layout_constraintTop_toBottomOf="@+id/lySegundo"> |
| 29 | 28 | |
| 30 | 29 | <androidx.appcompat.widget.AppCompatTextView |
| 30 | + android:id="@+id/tvTitulo" | |
| 31 | 31 | android:layout_width="0dp" |
| 32 | 32 | android:layout_height="wrap_content" |
| 33 | 33 | android:layout_margin="10dp" |
app/src/main/res/layout/item_principal.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | - <androidx.cardview.widget.CardView | |
| 3 | - xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | - xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 5 | - android:id="@+id/cvInventario" | |
| 6 | - android:layout_width="match_parent" | |
| 2 | +<androidx.cardview.widget.CardView | |
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 5 | + xmlns:tools="http://schemas.android.com/tools" | |
| 6 | + android:id="@+id/cvInventario" | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="wrap_content" | |
| 9 | + android:layout_rowWeight="1" | |
| 10 | + android:layout_columnWeight="1" | |
| 11 | + android:layout_margin="15dp" | |
| 12 | + android:clickable="true" | |
| 13 | + app:cardCornerRadius="8dp" | |
| 14 | + app:cardElevation="8dp" | |
| 15 | + app:layout_constraintBottom_toBottomOf="parent" | |
| 16 | + app:layout_constraintEnd_toEndOf="parent" | |
| 17 | + app:layout_constraintStart_toStartOf="parent" | |
| 18 | + app:layout_constraintTop_toTopOf="parent"> | |
| 19 | + | |
| 20 | + <LinearLayout | |
| 21 | + android:layout_width="wrap_content" | |
| 7 | 22 | android:layout_height="wrap_content" |
| 8 | - android:layout_rowWeight="1" | |
| 9 | - android:layout_columnWeight="1" | |
| 10 | - android:layout_margin="15dp" | |
| 11 | - app:cardCornerRadius="8dp" | |
| 12 | - app:cardElevation="8dp" | |
| 13 | - app:layout_constraintBottom_toBottomOf="parent" | |
| 14 | - app:layout_constraintEnd_toEndOf="parent" | |
| 15 | - app:layout_constraintStart_toStartOf="parent" | |
| 16 | - app:layout_constraintTop_toTopOf="parent"> | |
| 23 | + android:layout_gravity="center_horizontal|center_vertical" | |
| 24 | + android:orientation="vertical"> | |
| 17 | 25 | |
| 18 | - <LinearLayout | |
| 26 | + <androidx.appcompat.widget.AppCompatImageView | |
| 19 | 27 | android:layout_width="wrap_content" |
| 20 | 28 | android:layout_height="wrap_content" |
| 21 | - android:layout_gravity="center_horizontal|center_vertical" | |
| 22 | - android:layout_margin="15dp" | |
| 23 | - android:orientation="vertical"> | |
| 24 | - | |
| 25 | - <androidx.appcompat.widget.AppCompatImageView | |
| 26 | - android:layout_width="wrap_content" | |
| 27 | - android:layout_height="wrap_content" | |
| 28 | - android:layout_gravity="center_horizontal" | |
| 29 | - android:src="@drawable/inventario" /> | |
| 29 | + android:layout_gravity="center_horizontal" | |
| 30 | + android:src="@drawable/inventario" /> | |
| 30 | 31 | |
| 31 | - <androidx.appcompat.widget.AppCompatTextView | |
| 32 | - android:id="@+id/inventario" | |
| 33 | - android:layout_width="wrap_content" | |
| 34 | - android:layout_height="60dp" | |
| 35 | - android:autoSizeMaxTextSize="50sp" | |
| 36 | - android:autoSizeMinTextSize="15sp" | |
| 37 | - android:clickable="true" | |
| 38 | - android:autoSizeStepGranularity="5sp" | |
| 39 | - android:autoSizeTextType="uniform" | |
| 40 | - android:gravity="center" | |
| 41 | - android:inputType="textMultiLine" | |
| 42 | - android:text="Inventeario 1 Abierto. Articulos 100 12/12/2020 12:00" | |
| 43 | - android:textColor="@android:color/black" | |
| 44 | - android:textStyle="bold" /> | |
| 45 | - </LinearLayout> | |
| 46 | - </androidx.cardview.widget.CardView> | |
| 32 | + <TextView | |
| 33 | + android:id="@+id/inventario" | |
| 34 | + android:layout_width="wrap_content" | |
| 35 | + android:layout_height="wrap_content" | |
| 36 | + android:clickable="true" | |
| 37 | + android:gravity="center" | |
| 38 | + android:lines="2" | |
| 39 | + tools:text="Demo text" | |
| 40 | + android:textColor="@android:color/black" | |
| 41 | + android:textStyle="bold" /> | |
| 42 | + </LinearLayout> | |
| 43 | +</androidx.cardview.widget.CardView> |
app/src/main/res/navigation/mobile_navigation.xml
| ... | ... | @@ -104,4 +104,16 @@ |
| 104 | 104 | app:popUpTo="@+id/descripcionFragment" |
| 105 | 105 | app:popUpToInclusive="true"/> |
| 106 | 106 | </fragment> |
| 107 | + <dialog | |
| 108 | + android:id="@+id/dialogNoEncontrado" | |
| 109 | + android:name="com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado" | |
| 110 | + android:label="DialogNoEncontrado" /> | |
| 111 | + <fragment | |
| 112 | + android:id="@+id/dialogoLogin" | |
| 113 | + android:name="com.focasoftware.deboinventariov20.ui.dialogos.dialogoLogin" | |
| 114 | + android:label="dialogoLogin" /> | |
| 115 | + <fragment | |
| 116 | + android:id="@+id/singleChoiceAlertDialog" | |
| 117 | + android:name="com.focasoftware.deboinventariov20.ui.dialogos.SingleChoiceAlertDialog" | |
| 118 | + android:label="SingleChoiceAlertDialog" /> | |
| 107 | 119 | </navigation> |
| 108 | 120 | \ No newline at end of file |
app/src/main/res/values/strings.xml
| ... | ... | @@ -111,7 +111,7 @@ |
| 111 | 111 | <string name="btnOk">Aceptar</string> |
| 112 | 112 | <string name="btnCancelar">Cancelar</string> |
| 113 | 113 | <string name="sMensaje">¡No se encontro el producto ingresado!</string> |
| 114 | - <string name="sMensajeEncontrado">¡Ingrese la cantidad contada!</string> | |
| 114 | + <string name="sMensajeEncontrado">¡Ingrese nueva cantidad!</string> | |
| 115 | 115 | <string name="sTituloNueva">Producto ingresado esta cargado</string> |
| 116 | 116 | <string name="sCantidadNueva">¡Por favor ingrese la nueva Cantidad!</string> |
| 117 | 117 | <string name="sMensajeBorrarInv">¡Seguro que desea Borrar el inventario!</string> |