Commit 23f89b25e16d24bb2c1e6326896d073308794dc6
1 parent
d60eae7d0b
Exists in
master
21082020 2313
Showing
30 changed files
with
697 additions
and
458 deletions
Show diff stats
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
| ... | ... | @@ -4,6 +4,7 @@ import androidx.room.* |
| 4 | 4 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART |
| 5 | 5 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B |
| 6 | 6 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H |
| 7 | +import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV | |
| 7 | 8 | import com.focasoftware.deboinventariov20.Model.* |
| 8 | 9 | |
| 9 | 10 | @Dao |
| ... | ... | @@ -16,7 +17,7 @@ interface ArticulosDAO { |
| 16 | 17 | @Query("SELECT * FROM $TABLA_ART ORDER BY DES DESC") |
| 17 | 18 | suspend fun findAllArticulos(): List<Articles> |
| 18 | 19 | |
| 19 | - @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%' GROUP BY DES ORDER BY SEC, COD") | |
| 20 | + @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%' GROUP BY DES ORDER BY DES") | |
| 20 | 21 | suspend fun findArticuloByDesc(description: String?, dep: Int): List<Articles> |
| 21 | 22 | |
| 22 | 23 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CB LIKE :codBarra") |
| ... | ... | @@ -66,6 +67,9 @@ interface ServeInvDao { |
| 66 | 67 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
| 67 | 68 | fun insertServer(servidor: ServeInv) |
| 68 | 69 | |
| 69 | - @Query("SELECT SER_NUM,SER_DESC, SER_DIR FROM ServeInv") | |
| 70 | - suspend fun findAllServers(): List<ServeInv> | |
| 70 | + @Query("SELECT SER_NUM,SER_DESC, SER_DIR FROM $TABLA_SERV_INV") | |
| 71 | + suspend fun fetchAllServers(): List<ServeInv> | |
| 72 | + | |
| 73 | + @Query("DELETE FROM ServeInv WHERE SER_NUM = :number") | |
| 74 | + suspend fun deleteServer(number: Long) | |
| 71 | 75 | } |
| 72 | 76 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionFragment.kt
| ... | ... | @@ -0,0 +1,157 @@ |
| 1 | +package com.focasoftware.deboinventariov20.ui.descripcionFragment | |
| 2 | + | |
| 3 | +import android.content.Context | |
| 4 | +import android.content.SharedPreferences | |
| 5 | +import android.graphics.Canvas | |
| 6 | +import android.graphics.Color | |
| 7 | +import android.graphics.drawable.ColorDrawable | |
| 8 | +import android.os.Bundle | |
| 9 | +import android.view.LayoutInflater | |
| 10 | +import android.view.View | |
| 11 | +import android.view.ViewGroup | |
| 12 | +import android.widget.Button | |
| 13 | +import androidx.fragment.app.Fragment | |
| 14 | +import androidx.lifecycle.lifecycleScope | |
| 15 | +import androidx.navigation.NavController | |
| 16 | +import androidx.navigation.Navigation | |
| 17 | +import androidx.recyclerview.widget.ItemTouchHelper | |
| 18 | +import androidx.recyclerview.widget.LinearLayoutManager | |
| 19 | +import androidx.recyclerview.widget.RecyclerView | |
| 20 | +import com.afollestad.materialdialogs.MaterialDialog | |
| 21 | +import com.afollestad.materialdialogs.input.input | |
| 22 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
| 23 | +import com.focasoftware.deboinventariov20.Model.Articles | |
| 24 | +import com.focasoftware.deboinventariov20.Model.InvBody | |
| 25 | +import com.focasoftware.deboinventariov20.R | |
| 26 | +import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment | |
| 27 | +import kotlinx.coroutines.Dispatchers | |
| 28 | +import kotlinx.coroutines.launch | |
| 29 | +import kotlinx.coroutines.withContext | |
| 30 | + | |
| 31 | +class DescripcionFragment : Fragment() { | |
| 32 | + private var artAcargar2: List<Articles>? = null | |
| 33 | + private var listArticulos2: List<Articles>? = null | |
| 34 | + lateinit var viewAdapter2: RecyclerView.Adapter<*> | |
| 35 | + private lateinit var viewManager2: RecyclerView.LayoutManager | |
| 36 | + private lateinit var rcDescripcion: RecyclerView | |
| 37 | + private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | |
| 38 | + private var cantidad = 0F | |
| 39 | + private var numeroInventario = 0 | |
| 40 | + lateinit var navController: NavController | |
| 41 | + lateinit var sharedPreferences: SharedPreferences | |
| 42 | + | |
| 43 | + override fun onCreate(savedInstanceState: Bundle?) { | |
| 44 | + super.onCreate(savedInstanceState) | |
| 45 | + sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
| 46 | + arguments.apply { | |
| 47 | + artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | |
| 48 | + numeroInventario = requireArguments().getInt("numeroInv") | |
| 49 | + } | |
| 50 | + } | |
| 51 | + | |
| 52 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| 53 | + super.onViewCreated(view, savedInstanceState) | |
| 54 | + navController = Navigation.findNavController(view) | |
| 55 | + } | |
| 56 | + | |
| 57 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| 58 | + // Inflate the layout for this fragment | |
| 59 | + val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | |
| 60 | + rcDescripcion = v.findViewById(R.id.rcDescripcion) | |
| 61 | + val btnSalir = v.findViewById<Button>(R.id.btnSalir) | |
| 62 | + | |
| 63 | + IngresarRecicler(artAcargar2) | |
| 64 | + | |
| 65 | + btnSalir.setOnClickListener { | |
| 66 | + VolverAinventario() | |
| 67 | + } | |
| 68 | + return v | |
| 69 | + } | |
| 70 | + | |
| 71 | + fun IngresarRecicler(articulos: List<Articles>?) { | |
| 72 | + | |
| 73 | + viewAdapter2 = DescripcionListAdapter(articulos) | |
| 74 | + viewManager2 = LinearLayoutManager(requireContext()) | |
| 75 | + | |
| 76 | + rcDescripcion.apply { | |
| 77 | + adapter = viewAdapter2 | |
| 78 | + layoutManager = viewManager2 | |
| 79 | + } | |
| 80 | + val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) { | |
| 81 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 82 | + return false | |
| 83 | + } | |
| 84 | + | |
| 85 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
| 86 | + MaterialDialog(requireContext()).show { | |
| 87 | + title(R.string.sTitulo) | |
| 88 | + message(R.string.sMensajeEncontrado) | |
| 89 | + input { materialDialog, charSequence -> | |
| 90 | + cantidad = 0F | |
| 91 | + cantidad = charSequence.toString().toFloat() | |
| 92 | + } | |
| 93 | +// .input("Cantidad",1,,1,0,InputType.TYPE_CLASS_NUMBER,0,waitForPositiveButton = true,false,positiveButton ()) | |
| 94 | + positiveButton(R.string.btnOk) { | |
| 95 | + dismiss() | |
| 96 | + var indice = 0 | |
| 97 | + indice=viewHolder.layoutPosition | |
| 98 | + | |
| 99 | + val body = InvBody(numeroInventario, | |
| 100 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | |
| 101 | + // TODO PREPARO PARA MANDAR A CARGAR EN LA BD | |
| 102 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | |
| 103 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | |
| 104 | + cantidad.toString(), | |
| 105 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | |
| 106 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | |
| 107 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
| 108 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
| 109 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | |
| 110 | + (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | |
| 111 | + InventarioFragment().ObtenerFechaActual(), | |
| 112 | + InventarioFragment().ObtenerFechaActual()) | |
| 113 | + InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | |
| 114 | + VolverAinventario() | |
| 115 | + } | |
| 116 | + }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 117 | + } | |
| 118 | + | |
| 119 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 120 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 121 | + val itemView = viewHolder.itemView | |
| 122 | + | |
| 123 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 124 | + | |
| 125 | + if (dX > 0) { | |
| 126 | + | |
| 127 | + c.drawColor(Color.RED) | |
| 128 | + } else if (dX < 0) { | |
| 129 | + // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | |
| 130 | + c.drawColor(Color.YELLOW) | |
| 131 | + } | |
| 132 | + swipeBackground.draw(c) | |
| 133 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 134 | + } | |
| 135 | + } | |
| 136 | + val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | |
| 137 | + itemTouchHelper2.attachToRecyclerView(rcDescripcion) | |
| 138 | + | |
| 139 | + } | |
| 140 | + | |
| 141 | + fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
| 142 | + lifecycleScope.launch { | |
| 143 | + withContext(Dispatchers.IO) { | |
| 144 | + AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
| 145 | + } | |
| 146 | + } | |
| 147 | + } | |
| 148 | + fun VolverAinventario(){ | |
| 149 | + | |
| 150 | + val editor = sharedPreferences.edit() | |
| 151 | + editor?.putString("Inventario", numeroInventario.toString()) | |
| 152 | + editor?.apply() | |
| 153 | + editor.commit() | |
| 154 | + navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
| 155 | + } | |
| 156 | +} | |
| 157 | + |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionListAdapter.kt
| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | +package com.focasoftware.deboinventariov20.ui.descripcionFragment | |
| 2 | + | |
| 3 | +import android.view.LayoutInflater | |
| 4 | +import android.view.View | |
| 5 | +import android.view.ViewGroup | |
| 6 | +import androidx.recyclerview.widget.RecyclerView | |
| 7 | +import com.focasoftware.deboinventariov20.Model.Articles | |
| 8 | +import com.focasoftware.deboinventariov20.R | |
| 9 | +import kotlinx.android.synthetic.main.item.view.* | |
| 10 | + | |
| 11 | +class DescripcionListAdapter(private val productos: List<Articles>?) : | |
| 12 | + RecyclerView.Adapter<DescripcionListAdapter.ItemsViewHolder>() { | |
| 13 | + internal var items2: List<Articles>? = null | |
| 14 | + | |
| 15 | + init { | |
| 16 | + this.items2 = productos | |
| 17 | + } | |
| 18 | + | |
| 19 | + override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder( | |
| 20 | + LayoutInflater.from(parent.context).inflate(R.layout.item_descripcion, parent, false) | |
| 21 | + ) | |
| 22 | + | |
| 23 | + override fun getItemCount() = productos!!.size | |
| 24 | + | |
| 25 | + override fun onBindViewHolder(holder: ItemsViewHolder, position: Int) { | |
| 26 | + when (holder) { | |
| 27 | + is ItemsViewHolder -> { | |
| 28 | + holder.bind(items2!![position]) | |
| 29 | + } | |
| 30 | + } | |
| 31 | + } | |
| 32 | + | |
| 33 | + | |
| 34 | + class ItemsViewHolder constructor(view: View) : RecyclerView.ViewHolder(view) { | |
| 35 | + | |
| 36 | + val sector = view.tvSector | |
| 37 | + val codigo = view.tvCodigo | |
| 38 | + val descripcion = view.tvDescripcion | |
| 39 | + val codigoBarras = view.tvCodigoBarras | |
| 40 | + | |
| 41 | + fun bind(pro: Articles) { | |
| 42 | + sector.text = pro.sector | |
| 43 | + codigo.text = pro.codigo | |
| 44 | + descripcion.text = pro.descripcion | |
| 45 | + codigoBarras.text = pro.codBar | |
| 46 | + } | |
| 47 | + } | |
| 48 | +} | |
| 0 | 49 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/ItemDescripcion.kt
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/BaseFragment.kt
| ... | ... | @@ -1,29 +0,0 @@ |
| 1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
| 2 | - | |
| 3 | -import android.os.Bundle | |
| 4 | -import androidx.fragment.app.Fragment | |
| 5 | -import kotlinx.coroutines.CoroutineScope | |
| 6 | -import kotlinx.coroutines.Dispatchers | |
| 7 | -import kotlinx.coroutines.Job | |
| 8 | -import kotlin.coroutines.CoroutineContext | |
| 9 | - | |
| 10 | -abstract class BaseFragment : Fragment(), CoroutineScope { | |
| 11 | - | |
| 12 | - | |
| 13 | - lateinit var job: Job | |
| 14 | - | |
| 15 | - override val coroutineContext: CoroutineContext | |
| 16 | - get() = job + Dispatchers.Main | |
| 17 | - | |
| 18 | - override fun onCreate(savedInstanceState: Bundle?) { | |
| 19 | - super.onCreate(savedInstanceState) | |
| 20 | - job = Job() | |
| 21 | - } | |
| 22 | - | |
| 23 | - override fun onDestroy() { | |
| 24 | - super.onDestroy() | |
| 25 | - job.cancel() | |
| 26 | - } | |
| 27 | - | |
| 28 | - | |
| 29 | -} | |
| 30 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/DescripcionFragment.kt
| ... | ... | @@ -1,156 +0,0 @@ |
| 1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
| 2 | - | |
| 3 | -import android.content.Context | |
| 4 | -import android.content.SharedPreferences | |
| 5 | -import android.graphics.Canvas | |
| 6 | -import android.graphics.Color | |
| 7 | -import android.graphics.drawable.ColorDrawable | |
| 8 | -import android.os.Bundle | |
| 9 | -import android.view.LayoutInflater | |
| 10 | -import android.view.View | |
| 11 | -import android.view.ViewGroup | |
| 12 | -import android.widget.Button | |
| 13 | -import androidx.fragment.app.Fragment | |
| 14 | -import androidx.lifecycle.lifecycleScope | |
| 15 | -import androidx.navigation.NavController | |
| 16 | -import androidx.navigation.Navigation | |
| 17 | -import androidx.recyclerview.widget.ItemTouchHelper | |
| 18 | -import androidx.recyclerview.widget.LinearLayoutManager | |
| 19 | -import androidx.recyclerview.widget.RecyclerView | |
| 20 | -import com.afollestad.materialdialogs.MaterialDialog | |
| 21 | -import com.afollestad.materialdialogs.input.input | |
| 22 | -import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
| 23 | -import com.focasoftware.deboinventariov20.Model.Articles | |
| 24 | -import com.focasoftware.deboinventariov20.Model.InvBody | |
| 25 | -import com.focasoftware.deboinventariov20.R | |
| 26 | -import kotlinx.coroutines.Dispatchers | |
| 27 | -import kotlinx.coroutines.launch | |
| 28 | -import kotlinx.coroutines.withContext | |
| 29 | - | |
| 30 | -class DescripcionFragment : Fragment() { | |
| 31 | - private var artAcargar2: List<Articles>? = null | |
| 32 | - private var listArticulos2: List<Articles>? = null | |
| 33 | - lateinit var viewAdapter2: RecyclerView.Adapter<*> | |
| 34 | - private lateinit var viewManager2: RecyclerView.LayoutManager | |
| 35 | - private lateinit var rcDescripcion: RecyclerView | |
| 36 | - private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | |
| 37 | - private var cantidad = 0F | |
| 38 | - private var numeroInventario = 0 | |
| 39 | - lateinit var navController: NavController | |
| 40 | - lateinit var sharedPreferences: SharedPreferences | |
| 41 | - | |
| 42 | - override fun onCreate(savedInstanceState: Bundle?) { | |
| 43 | - super.onCreate(savedInstanceState) | |
| 44 | - sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | |
| 45 | - arguments.apply { | |
| 46 | - artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | |
| 47 | - numeroInventario = requireArguments().getInt("numeroInv") | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| 52 | - super.onViewCreated(view, savedInstanceState) | |
| 53 | - navController = Navigation.findNavController(view) | |
| 54 | - } | |
| 55 | - | |
| 56 | - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| 57 | - // Inflate the layout for this fragment | |
| 58 | - val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | |
| 59 | - rcDescripcion = v.findViewById(R.id.rcDescripcion) | |
| 60 | - val btnSalir = v.findViewById<Button>(R.id.btnSalir) | |
| 61 | - | |
| 62 | - IngresarRecicler(artAcargar2) | |
| 63 | - | |
| 64 | - btnSalir.setOnClickListener { | |
| 65 | - VolverAinventario() | |
| 66 | - } | |
| 67 | - return v | |
| 68 | - } | |
| 69 | - | |
| 70 | - fun IngresarRecicler(articulos: List<Articles>?) { | |
| 71 | - | |
| 72 | - viewAdapter2 = DescripcionListAdapter(articulos) | |
| 73 | - viewManager2 = LinearLayoutManager(requireContext()) | |
| 74 | - | |
| 75 | - rcDescripcion.apply { | |
| 76 | - adapter = viewAdapter2 | |
| 77 | - layoutManager = viewManager2 | |
| 78 | - } | |
| 79 | - val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) { | |
| 80 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 81 | - return false | |
| 82 | - } | |
| 83 | - | |
| 84 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
| 85 | - MaterialDialog(requireContext()).show { | |
| 86 | - title(R.string.sTitulo) | |
| 87 | - message(R.string.sMensajeEncontrado) | |
| 88 | - input { materialDialog, charSequence -> | |
| 89 | - cantidad = 0F | |
| 90 | - cantidad = charSequence.toString().toFloat() | |
| 91 | - } | |
| 92 | -// .input("Cantidad",1,,1,0,InputType.TYPE_CLASS_NUMBER,0,waitForPositiveButton = true,false,positiveButton ()) | |
| 93 | - positiveButton(R.string.btnOk) { | |
| 94 | - dismiss() | |
| 95 | - var indice = 0 | |
| 96 | - indice=viewHolder.layoutPosition | |
| 97 | - | |
| 98 | - val body = InvBody(numeroInventario, | |
| 99 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | |
| 100 | - // TODO PREPARO PARA MANDAR A CARGAR EN LA BD | |
| 101 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | |
| 102 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | |
| 103 | - cantidad.toString(), | |
| 104 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | |
| 105 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | |
| 106 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
| 107 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | |
| 108 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | |
| 109 | - (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | |
| 110 | - InventarioFragment().ObtenerFechaActual(), | |
| 111 | - InventarioFragment().ObtenerFechaActual()) | |
| 112 | - InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | |
| 113 | - VolverAinventario() | |
| 114 | - } | |
| 115 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 116 | - } | |
| 117 | - | |
| 118 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 119 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 120 | - val itemView = viewHolder.itemView | |
| 121 | - | |
| 122 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 123 | - | |
| 124 | - if (dX > 0) { | |
| 125 | - | |
| 126 | - c.drawColor(Color.RED) | |
| 127 | - } else if (dX < 0) { | |
| 128 | - // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | |
| 129 | - c.drawColor(Color.YELLOW) | |
| 130 | - } | |
| 131 | - swipeBackground.draw(c) | |
| 132 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 133 | - } | |
| 134 | - } | |
| 135 | - val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | |
| 136 | - itemTouchHelper2.attachToRecyclerView(rcDescripcion) | |
| 137 | - | |
| 138 | - } | |
| 139 | - | |
| 140 | - fun InsertarArtEnDB(cuarpoInventario: InvBody) { | |
| 141 | - lifecycleScope.launch { | |
| 142 | - withContext(Dispatchers.IO) { | |
| 143 | - AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | |
| 144 | - } | |
| 145 | - } | |
| 146 | - } | |
| 147 | - fun VolverAinventario(){ | |
| 148 | - | |
| 149 | - val editor = sharedPreferences.edit() | |
| 150 | - editor?.putString("Inventario", numeroInventario.toString()) | |
| 151 | - editor?.apply() | |
| 152 | - editor.commit() | |
| 153 | - navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
| 154 | - } | |
| 155 | -} | |
| 156 | - |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/DescripcionListAdapter.kt
| ... | ... | @@ -1,48 +0,0 @@ |
| 1 | -package com.focasoftware.deboinventariov20.ui.inventario | |
| 2 | - | |
| 3 | -import android.view.LayoutInflater | |
| 4 | -import android.view.View | |
| 5 | -import android.view.ViewGroup | |
| 6 | -import androidx.recyclerview.widget.RecyclerView | |
| 7 | -import com.focasoftware.deboinventariov20.Model.Articles | |
| 8 | -import com.focasoftware.deboinventariov20.R | |
| 9 | -import kotlinx.android.synthetic.main.item.view.* | |
| 10 | - | |
| 11 | -class DescripcionListAdapter(private val productos: List<Articles>?) : | |
| 12 | - RecyclerView.Adapter<DescripcionListAdapter.ItemsViewHolder>() { | |
| 13 | - internal var items2: List<Articles>? = null | |
| 14 | - | |
| 15 | - init { | |
| 16 | - this.items2 = productos | |
| 17 | - } | |
| 18 | - | |
| 19 | - override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder( | |
| 20 | - LayoutInflater.from(parent.context).inflate(R.layout.item_descripcion, parent, false) | |
| 21 | - ) | |
| 22 | - | |
| 23 | - override fun getItemCount() = productos!!.size | |
| 24 | - | |
| 25 | - override fun onBindViewHolder(holder: ItemsViewHolder, position: Int) { | |
| 26 | - when (holder) { | |
| 27 | - is ItemsViewHolder -> { | |
| 28 | - holder.bind(items2!![position]) | |
| 29 | - } | |
| 30 | - } | |
| 31 | - } | |
| 32 | - | |
| 33 | - | |
| 34 | - class ItemsViewHolder constructor(view: View) : RecyclerView.ViewHolder(view) { | |
| 35 | - | |
| 36 | - val sector = view.tvSector | |
| 37 | - val codigo = view.tvCodigo | |
| 38 | - val descripcion = view.tvDescripcion | |
| 39 | - val codigoBarras = view.tvCodigoBarras | |
| 40 | - | |
| 41 | - fun bind(pro: Articles) { | |
| 42 | - sector.text = pro.sector | |
| 43 | - codigo.text = pro.codigo | |
| 44 | - descripcion.text = pro.descripcion | |
| 45 | - codigoBarras.text = pro.codBar | |
| 46 | - } | |
| 47 | - } | |
| 48 | -} | |
| 49 | 0 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
| ... | ... | @@ -13,7 +13,6 @@ import android.view.ViewGroup |
| 13 | 13 | import android.widget.EditText |
| 14 | 14 | import android.widget.TextView |
| 15 | 15 | import android.widget.Toast |
| 16 | -import android.widget.ToggleButton | |
| 17 | 16 | import androidx.core.content.ContextCompat |
| 18 | 17 | import androidx.core.os.bundleOf |
| 19 | 18 | import androidx.fragment.app.Fragment |
| ... | ... | @@ -43,13 +42,15 @@ class InventarioFragment : Fragment() { |
| 43 | 42 | private var iArea: Int = 0 |
| 44 | 43 | private lateinit var invHead: InvHead |
| 45 | 44 | private lateinit var rcInventarios: RecyclerView |
| 46 | - lateinit var viewAdapter: RecyclerView.Adapter<*> | |
| 45 | + private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
| 47 | 46 | private lateinit var viewManager: RecyclerView.LayoutManager |
| 48 | 47 | private lateinit var sChangeUpper: String |
| 49 | 48 | private var listArticulos = ArrayList<ItemsRecycler>() |
| 50 | - lateinit var navController: NavController | |
| 51 | - var InventarioNuevo: Int = 0 | |
| 52 | - var fCant = 0F | |
| 49 | + private lateinit var navController: NavController | |
| 50 | + private var InventarioNuevo: Int = 0 | |
| 51 | + private var iEstado = 0 | |
| 52 | + private var fCant = 0F | |
| 53 | + private var bFirst = false | |
| 53 | 54 | private lateinit var deleteIcon: Drawable |
| 54 | 55 | // private var editTT: EditText? = null |
| 55 | 56 | // private var dialogoModificacion: DialogPersoComplexCantidadModificacion? = null |
| ... | ... | @@ -73,7 +74,6 @@ class InventarioFragment : Fragment() { |
| 73 | 74 | val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) |
| 74 | 75 | rcInventarios = v.findViewById(R.id.rcInventarios) |
| 75 | 76 | val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) |
| 76 | - val toggleButton = v.findViewById<ToggleButton>(R.id.toggleButton) | |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO |
| ... | ... | @@ -99,108 +99,175 @@ class InventarioFragment : Fragment() { |
| 99 | 99 | var indiceDelArtEncontrado = 0 |
| 100 | 100 | |
| 101 | 101 | //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS |
| 102 | - if (toggleButton.isChecked) { | |
| 103 | - indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | |
| 104 | - //TODO Si no lo encuentra devuelve -1 | |
| 105 | - if (indiceDelArtEncontrado != -1) { | |
| 106 | - if (swSumaUno!!.isChecked) { | |
| 107 | - fCant = 0F | |
| 108 | - fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 109 | - fCant += 1F | |
| 110 | - //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
| 111 | - updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 112 | - //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
| 113 | - listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 114 | - viewAdapter.notifyDataSetChanged() | |
| 115 | - } else { | |
| 116 | -// val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | |
| 117 | -// val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Login Form").setCancelable(false) | |
| 118 | -// val mAlertDialog = mBuilder.show() | |
| 119 | -// mDialogView.dialogLoginBtn.setOnClickListener { | |
| 120 | -// mAlertDialog.dismiss() | |
| 121 | -// //get text from EditTexts of custom layout | |
| 122 | -// val name = mDialogView.dialogNameEt.text.toString() | |
| 123 | -// val email = mDialogView.dialogEmailEt.text.toString() | |
| 124 | -// val password = mDialogView.dialogPasswEt.text.toString() | |
| 125 | -// fCant = 0F | |
| 126 | -// fCant = name.toFloat() | |
| 127 | -// } | |
| 128 | -// mDialogView.dialogCancelBtn.setOnClickListener { | |
| 129 | -// mAlertDialog.dismiss() | |
| 130 | -// } | |
| 131 | - fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 132 | - MaterialDialog(requireContext()).show { | |
| 133 | - title(R.string.sTituloNueva) | |
| 134 | - message(R.string.sCantidadNueva) | |
| 135 | - input { materialDialog, charSequence -> | |
| 136 | - fCant = 0F | |
| 137 | - fCant = charSequence.toString().toFloat() | |
| 138 | - } | |
| 139 | - positiveButton(R.string.btnOk) { | |
| 140 | - //TODO ACTUALIZO CANTIADAD EN BD | |
| 141 | - updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 142 | - //TODO ACTUALIZO CANTIDAD EN RV | |
| 143 | - listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 144 | - viewAdapter.notifyDataSetChanged() | |
| 145 | - dismiss() | |
| 146 | - } | |
| 147 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 102 | + when (iEstado) { | |
| 103 | + 0 -> { | |
| 104 | + indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | |
| 105 | + //TODO Si no lo encuentra devuelve -1 | |
| 106 | + if (indiceDelArtEncontrado != -1) { | |
| 107 | + if (swSumaUno!!.isChecked) { | |
| 108 | + fCant = 0F | |
| 109 | + fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 110 | + fCant += 1F | |
| 111 | + //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
| 112 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 113 | + //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
| 114 | + listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 115 | + viewAdapter.notifyDataSetChanged() | |
| 116 | + } 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 | + // } | |
| 132 | + fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 133 | + MaterialDialog(requireContext()).show { | |
| 134 | + title(R.string.sTituloNueva) | |
| 135 | + message(R.string.sCantidadNueva) | |
| 136 | + input { materialDialog, charSequence -> | |
| 137 | + fCant = 0F | |
| 138 | + fCant = charSequence.toString().toFloat() | |
| 139 | + } | |
| 140 | + positiveButton(R.string.btnOk) { | |
| 141 | + //TODO ACTUALIZO CANTIADAD EN BD | |
| 142 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 143 | + //TODO ACTUALIZO CANTIDAD EN RV | |
| 144 | + listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 145 | + viewAdapter.notifyDataSetChanged() | |
| 146 | + dismiss() | |
| 147 | + } | |
| 148 | + }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 149 | + } | |
| 150 | + | |
| 151 | + } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | |
| 152 | + | |
| 153 | + GlobalScope.launch(Dispatchers.Main) { | |
| 154 | + //TODO BUSCO EN BASE DE DATOS | |
| 155 | + val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
| 156 | + ContinuarCargaCB(artEncontrado) | |
| 157 | + } | |
| 148 | 158 | } |
| 149 | 159 | |
| 150 | - } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | |
| 160 | + tCodigoBarras.focusable = View.FOCUSABLE | |
| 161 | + tCodigoBarras.setText("") | |
| 162 | + tCodigoBarras.selectAll() | |
| 163 | + return@setOnKeyListener true | |
| 151 | 164 | |
| 152 | - GlobalScope.launch(Dispatchers.Main) { | |
| 153 | - //TODO BUSCO EN BASE DE DATOS | |
| 154 | - val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
| 155 | - ContinuarCargaCB(artEncontrado) | |
| 156 | - } | |
| 157 | - } | |
| 158 | 165 | |
| 159 | - tCodigoBarras.focusable = View.FOCUSABLE | |
| 160 | - tCodigoBarras.setText("") | |
| 161 | - tCodigoBarras.selectAll() | |
| 162 | - return@setOnKeyListener true | |
| 163 | - | |
| 164 | - | |
| 165 | - } else {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | |
| 166 | -// | |
| 167 | -// indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
| 168 | -// //TODO Si no lo encuentra devuelve -1 | |
| 169 | -// if (indiceDelArtEncontrado != -1) { | |
| 170 | -//// if (swSumaUno!!.isChecked) { | |
| 171 | -//// fCant = 0F | |
| 172 | -//// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 173 | -//// fCant += 1F | |
| 174 | -//// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 175 | -//// viewAdapter.notifyDataSetChanged() | |
| 176 | -//// } else { | |
| 177 | -// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 178 | -// MaterialDialog(requireContext()).show { | |
| 179 | -// title(R.string.sTituloNueva) | |
| 180 | -// message(R.string.sCantidadNueva) | |
| 181 | -// input { materialDialog, charSequence -> | |
| 182 | -// fCant = 0F | |
| 183 | -// fCant = charSequence.toString().toFloat() | |
| 184 | -// } | |
| 185 | -// positiveButton(R.string.btnOk) { | |
| 186 | -// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 187 | -// viewAdapter.notifyDataSetChanged() | |
| 188 | -// dismiss() | |
| 189 | -// } | |
| 190 | -// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 191 | -//// } | |
| 192 | -// | |
| 193 | -// } else if | |
| 194 | -// (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
| 166 | + } | |
| 167 | + 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 | |
| 195 | 197 | GlobalScope.launch(Dispatchers.Main) { |
| 196 | 198 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 197 | 199 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) |
| 198 | 200 | } |
| 199 | -// } | |
| 200 | - tCodigoBarras.focusable = View.FOCUSABLE | |
| 201 | - tCodigoBarras.setText("") | |
| 202 | - tCodigoBarras.selectAll() | |
| 203 | - return@setOnKeyListener true | |
| 201 | + // } | |
| 202 | + tCodigoBarras.focusable = View.FOCUSABLE | |
| 203 | + tCodigoBarras.setText("") | |
| 204 | + tCodigoBarras.selectAll() | |
| 205 | + return@setOnKeyListener true | |
| 206 | + } | |
| 207 | + 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** | |
| 208 | + indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice | |
| 209 | + //TODO Si no lo encuentra devuelve -1 | |
| 210 | + if (indiceDelArtEncontrado != -1) { | |
| 211 | + if (swSumaUno!!.isChecked) { | |
| 212 | + fCant = 0F | |
| 213 | + fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 214 | + fCant += 1F | |
| 215 | + //TODO ACTUALIZO LA CANTIDAD EN LA BD | |
| 216 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 217 | + //TODO ACTUALIZO LA CANTIDAD EN EL RV | |
| 218 | + listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 219 | + viewAdapter.notifyDataSetChanged() | |
| 220 | + } 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 | + fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 237 | + MaterialDialog(requireContext()).show { | |
| 238 | + title(R.string.sTituloNueva) | |
| 239 | + message(R.string.sCantidadNueva) | |
| 240 | + input { materialDialog, charSequence -> | |
| 241 | + fCant = 0F | |
| 242 | + fCant = charSequence.toString().toFloat() | |
| 243 | + } | |
| 244 | + positiveButton(R.string.btnOk) { | |
| 245 | + //TODO ACTUALIZO CANTIADAD EN BD | |
| 246 | + updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | |
| 247 | + //TODO ACTUALIZO CANTIDAD EN RV | |
| 248 | + listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 249 | + viewAdapter.notifyDataSetChanged() | |
| 250 | + dismiss() | |
| 251 | + } | |
| 252 | + }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 253 | + } | |
| 254 | + | |
| 255 | + } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | |
| 256 | + | |
| 257 | + GlobalScope.launch(Dispatchers.Main) { | |
| 258 | + //TODO BUSCO EN BASE DE DATOS | |
| 259 | + val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | |
| 260 | + ContinuarCargaCB(artEncontrado) | |
| 261 | + } | |
| 262 | + } | |
| 263 | + | |
| 264 | + tCodigoBarras.focusable = View.FOCUSABLE | |
| 265 | + tCodigoBarras.setText("") | |
| 266 | + tCodigoBarras.selectAll() | |
| 267 | + return@setOnKeyListener true | |
| 268 | + | |
| 269 | + | |
| 270 | + } | |
| 204 | 271 | } |
| 205 | 272 | } |
| 206 | 273 | return@setOnKeyListener false |
| ... | ... | @@ -246,6 +313,33 @@ class InventarioFragment : Fragment() { |
| 246 | 313 | } |
| 247 | 314 | }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 248 | 315 | } |
| 316 | + ivCamara.setOnClickListener { | |
| 317 | + if (!bFirst) { | |
| 318 | + iEstado = 1 | |
| 319 | + bFirst = true | |
| 320 | + } | |
| 321 | + | |
| 322 | + when (iEstado) { | |
| 323 | + 0 -> { | |
| 324 | + ivCamara.setImageResource(R.drawable.codbar) | |
| 325 | + etCodigoBarras.hint = "Busqueda por C. Barras" | |
| 326 | + swSumaUno.visibility = View.VISIBLE | |
| 327 | + iEstado = 1 | |
| 328 | + } | |
| 329 | + 1 -> { | |
| 330 | + ivCamara.setImageResource(R.drawable.desc) | |
| 331 | + etCodigoBarras.hint = "Busqueda por Descripción" | |
| 332 | + swSumaUno.visibility = View.GONE | |
| 333 | + iEstado = 2 | |
| 334 | + } | |
| 335 | + 2 -> { | |
| 336 | + ivCamara.setImageResource(R.drawable.cod_origen) | |
| 337 | + etCodigoBarras.hint = "Busqueda por C. Origen" | |
| 338 | + swSumaUno.visibility = View.GONE | |
| 339 | + iEstado = 0 | |
| 340 | + } | |
| 341 | + } | |
| 342 | + } | |
| 249 | 343 | } |
| 250 | 344 | |
| 251 | 345 | private fun BorrarInvActual() { |
| ... | ... | @@ -327,7 +421,7 @@ class InventarioFragment : Fragment() { |
| 327 | 421 | // artAcargar[0].codigo, |
| 328 | 422 | // artAcargar[0].descripcion, |
| 329 | 423 | // artAcargar[0].codBar, |
| 330 | -// artAcargar[0].codOrigen, | |
| 424 | +// artAcargar[0].cod_origen, | |
| 331 | 425 | // artAcargar[0].precio, |
| 332 | 426 | // artAcargar[0].costo, |
| 333 | 427 | // artAcargar[0].balanza, |
| ... | ... | @@ -424,7 +518,7 @@ class InventarioFragment : Fragment() { |
| 424 | 518 | } |
| 425 | 519 | indice += 1 |
| 426 | 520 | } |
| 427 | - } else {//TODO BUSQUEDA POR DESCRIPCION | |
| 521 | + } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION | |
| 428 | 522 | for (item in listArticulos) { |
| 429 | 523 | if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
| 430 | 524 | bEncontrado = true |
| ... | ... | @@ -432,6 +526,14 @@ class InventarioFragment : Fragment() { |
| 432 | 526 | } |
| 433 | 527 | indice += 1 |
| 434 | 528 | } |
| 529 | + }else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | |
| 530 | + for (item in listArticulos) { | |
| 531 | + if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | |
| 532 | + bEncontrado = true | |
| 533 | + break | |
| 534 | + } | |
| 535 | + indice += 1 | |
| 536 | + } | |
| 435 | 537 | } |
| 436 | 538 | return if (bEncontrado) indice |
| 437 | 539 | else -1 |
| ... | ... | @@ -457,7 +559,7 @@ class InventarioFragment : Fragment() { |
| 457 | 559 | fun cargarRecicler(articulos: Articles, cant: Float) { |
| 458 | 560 | |
| 459 | 561 | //TODO CARGO EN LE RV |
| 460 | - val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar) | |
| 562 | + val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar,articulos.codOrigen) | |
| 461 | 563 | listArticulos.add(item) |
| 462 | 564 | |
| 463 | 565 | viewAdapter = ProductosListAdapter(listArticulos) |
| ... | ... | @@ -468,32 +570,32 @@ class InventarioFragment : Fragment() { |
| 468 | 570 | layoutManager = viewManager |
| 469 | 571 | } |
| 470 | 572 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { |
| 471 | - override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 472 | - return false | |
| 473 | - } | |
| 573 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 574 | + return false | |
| 575 | + } | |
| 474 | 576 | |
| 475 | - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
| 476 | - (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
| 477 | - viewAdapter.notifyDataSetChanged() | |
| 478 | - } | |
| 577 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | |
| 578 | + (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | |
| 579 | + viewAdapter.notifyDataSetChanged() | |
| 580 | + } | |
| 479 | 581 | |
| 480 | - override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 481 | - val itemView = viewHolder.itemView | |
| 482 | - val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
| 483 | - c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 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()) | |
| 484 | 586 | |
| 485 | - if (dX > 0) { | |
| 587 | + if (dX > 0) { | |
| 486 | 588 | |
| 487 | - if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
| 488 | - else c.drawColor(Color.RED) | |
| 489 | - deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
| 490 | - } else { | |
| 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 { | |
| 491 | 593 | |
| 492 | - } | |
| 594 | + } | |
| 493 | 595 | |
| 494 | - super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 495 | - deleteIcon.draw(c) | |
| 496 | - } | |
| 596 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 597 | + deleteIcon.draw(c) | |
| 598 | + } | |
| 497 | 599 | } |
| 498 | 600 | |
| 499 | 601 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ItemDescripcion.kt
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ItemsRecycler.kt
| 1 | 1 | package com.focasoftware.deboinventariov20.ui.inventario |
| 2 | 2 | |
| 3 | -data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?) | |
| 4 | 3 | \ No newline at end of file |
| 4 | +data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?) | |
| 5 | 5 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ProductosListAdapter.kt
| ... | ... | @@ -38,6 +38,7 @@ class ProductosListAdapter(private val productos: ArrayList<ItemsRecycler>) : Re |
| 38 | 38 | val descripcion = view.tvDescripcion |
| 39 | 39 | val cantCont = view.tvCantidad |
| 40 | 40 | val codigoBarras = view.tvCodigoBarras |
| 41 | + val codigoOrigen = view.tvCodigoOrigen | |
| 41 | 42 | |
| 42 | 43 | fun bind(pro: ItemsRecycler) { |
| 43 | 44 | sector.text = pro.sector |
| ... | ... | @@ -45,6 +46,7 @@ class ProductosListAdapter(private val productos: ArrayList<ItemsRecycler>) : Re |
| 45 | 46 | descripcion.text = pro.descripcion |
| 46 | 47 | cantCont.text = pro.cantTomada.toString() |
| 47 | 48 | codigoBarras.text = pro.codigoBarras |
| 49 | + codigoOrigen.text = pro.codigoOrigen | |
| 48 | 50 | } |
| 49 | 51 | } |
| 50 | 52 | |
| ... | ... | @@ -60,7 +62,4 @@ class ProductosListAdapter(private val productos: ArrayList<ItemsRecycler>) : Re |
| 60 | 62 | notifyItemInserted(removePosition) |
| 61 | 63 | }.show() |
| 62 | 64 | } |
| 63 | -// interface OnItemClickListener{ | |
| 64 | -// fun OnImageClick(position: Int) | |
| 65 | -// } | |
| 66 | 65 | } |
| 67 | 66 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
| ... | ... | @@ -91,7 +91,7 @@ class MainFragment : Fragment(), InventarioListAdapter.OnItemClickListener { |
| 91 | 91 | override fun OnItemClick(position: Int) { |
| 92 | 92 | val editor = sharedPreferences.edit() |
| 93 | 93 | var invSel:String = listIvn[position].inventario.toString() |
| 94 | - invSel=invSel.substring(13, 15) | |
| 94 | + invSel=invSel.substring(3, 5) | |
| 95 | 95 | editor?.putString("Inventario", invSel) |
| 96 | 96 | editor?.apply() |
| 97 | 97 | editor.commit() |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/AdapterServidores.kt
| ... | ... | @@ -6,14 +6,14 @@ import android.view.View |
| 6 | 6 | import android.view.ViewGroup |
| 7 | 7 | import androidx.recyclerview.widget.RecyclerView |
| 8 | 8 | import com.focasoftware.deboinventariov20.R |
| 9 | +import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | |
| 10 | +import com.google.android.material.snackbar.Snackbar | |
| 9 | 11 | import kotlinx.android.synthetic.main.item_servidores.view.* |
| 10 | 12 | |
| 11 | -class AdapterServidores( | |
| 12 | - private val servidor: ArrayList<ItemsServidores>, | |
| 13 | - private var contexto: Context | |
| 14 | -) : | |
| 13 | +class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, private var contexto: Context) : | |
| 15 | 14 | RecyclerView.Adapter<AdapterServidores.ViewHolder>() { |
| 16 | - | |
| 15 | + private var removePosition: Int = 0 | |
| 16 | + private var removedItem: ItemsServidores? = null | |
| 17 | 17 | |
| 18 | 18 | class ViewHolder(var vista: View) : RecyclerView.ViewHolder(vista) { |
| 19 | 19 | fun bind(itemsServidores: ItemsServidores) { |
| ... | ... | @@ -36,5 +36,16 @@ class AdapterServidores( |
| 36 | 36 | override fun onBindViewHolder(holder: ViewHolder, position: Int) { |
| 37 | 37 | holder.bind(servidor[position]) |
| 38 | 38 | } |
| 39 | + fun removeItem(viewHolder: RecyclerView.ViewHolder) { | |
| 40 | + removePosition = viewHolder.adapterPosition | |
| 41 | + removedItem = servidor[viewHolder.adapterPosition] | |
| 42 | + | |
| 43 | + servidor.removeAt(viewHolder.adapterPosition) | |
| 44 | + notifyItemRemoved(viewHolder.adapterPosition) | |
| 39 | 45 | |
| 46 | + Snackbar.make(viewHolder.itemView, "El articulo fue ${removedItem!!.descripcion} eliminado", Snackbar.LENGTH_LONG).setAction("Rehacer") { | |
| 47 | + servidor.add(removePosition, removedItem!!) | |
| 48 | + notifyItemInserted(removePosition) | |
| 49 | + }.show() | |
| 50 | + } | |
| 40 | 51 | } |
| 41 | 52 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ServidoresFragment.kt
| 1 | 1 | package com.focasoftware.deboinventariov20.ui.servidores |
| 2 | 2 | |
| 3 | +import android.graphics.Canvas | |
| 4 | +import android.graphics.Color | |
| 5 | +import android.graphics.drawable.Drawable | |
| 3 | 6 | import android.os.Bundle |
| 4 | -import androidx.fragment.app.Fragment | |
| 5 | 7 | import android.view.LayoutInflater |
| 6 | 8 | import android.view.View |
| 7 | 9 | import android.view.ViewGroup |
| 8 | -import android.widget.Button | |
| 10 | +import androidx.core.content.ContextCompat | |
| 11 | +import androidx.fragment.app.Fragment | |
| 12 | +import androidx.lifecycle.lifecycleScope | |
| 9 | 13 | import androidx.recyclerview.widget.DefaultItemAnimator |
| 14 | +import androidx.recyclerview.widget.ItemTouchHelper | |
| 10 | 15 | import androidx.recyclerview.widget.LinearLayoutManager |
| 11 | 16 | import androidx.recyclerview.widget.RecyclerView |
| 12 | 17 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
| 13 | 18 | import com.focasoftware.deboinventariov20.Model.ServeInv |
| 14 | 19 | import com.focasoftware.deboinventariov20.R |
| 20 | +import com.focasoftware.deboinventariov20.ui.inventario.ProductosListAdapter | |
| 15 | 21 | import kotlinx.android.synthetic.main.fragment_servidores.* |
| 16 | -import kotlinx.coroutines.GlobalScope | |
| 17 | -import kotlinx.coroutines.launch | |
| 22 | +import kotlinx.coroutines.* | |
| 23 | +import java.text.FieldPosition | |
| 18 | 24 | |
| 19 | 25 | class ServidoresFragment : Fragment() { |
| 20 | - val servidorNuevo = ArrayList<ItemsServidores>() | |
| 21 | - var index=0 | |
| 22 | - | |
| 23 | - override fun onCreateView( | |
| 24 | - inflater: LayoutInflater, | |
| 25 | - container: ViewGroup?, | |
| 26 | - savedInstanceState: Bundle? | |
| 27 | - ): View? { | |
| 28 | - val v = inflater.inflate(R.layout.fragment_servidores, container, false) | |
| 26 | + private val servidorNuevo = ArrayList<ItemsServidores>() | |
| 27 | + private var index = 0 | |
| 28 | + private lateinit var rvServidores: RecyclerView | |
| 29 | + private lateinit var viewAdapter: RecyclerView.Adapter<*> | |
| 30 | + private lateinit var viewManager: RecyclerView.LayoutManager | |
| 31 | + private var listIvn = java.util.ArrayList<ItemsServidores>() | |
| 32 | + private lateinit var servidores: List<ServeInv> | |
| 33 | + private lateinit var deleteIcon: Drawable | |
| 34 | + | |
| 35 | + override fun onCreate(savedInstanceState: Bundle?) { | |
| 36 | + super.onCreate(savedInstanceState) | |
| 37 | + buscaEnBD() | |
| 38 | + } | |
| 29 | 39 | |
| 30 | - val btnGuardarServidores = v.findViewById<Button>(R.id.btnGuardarServidores) | |
| 31 | - val rvServidores = v.findViewById<RecyclerView>(R.id.rvServidores) | |
| 40 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| 41 | + super.onViewCreated(view, savedInstanceState) | |
| 32 | 42 | |
| 33 | 43 | rvServidores.layoutManager = LinearLayoutManager(context) |
| 34 | 44 | rvServidores.itemAnimator = DefaultItemAnimator() |
| 35 | 45 | |
| 36 | 46 | btnGuardarServidores.setOnClickListener { |
| 37 | - rvServidores.adapter = AdapterServidores(ingregarDatos(), requireContext()) | |
| 47 | + if (etNombreServidor.text.isNullOrBlank()){ | |
| 48 | + etNombreServidor.error="Nombre no valido" | |
| 49 | + etNombreServidor.requestFocus() | |
| 50 | + etNombreServidor.hint="Nombre no valido" | |
| 51 | + } | |
| 52 | + if (etDireccionServidor.text.isNullOrBlank()){ | |
| 53 | + etDireccionServidor.error="Dirección no valida" | |
| 54 | + etDireccionServidor.requestFocus() | |
| 55 | + etDireccionServidor.hint="Dirección no valida" | |
| 56 | + } | |
| 57 | + if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()){ | |
| 58 | + btnGuardarServidores.isEnabled=true | |
| 59 | + buscaEnBD() | |
| 60 | + rvServidores.adapter = AdapterServidores(ingresarDatos(), requireContext()) | |
| 61 | + btnGuardarServidores.isEnabled=false | |
| 62 | + } | |
| 38 | 63 | } |
| 39 | - return v | |
| 40 | 64 | } |
| 65 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| 66 | + val v = inflater.inflate(R.layout.fragment_servidores, container, false) | |
| 67 | + rvServidores = v.findViewById(R.id.rvServidores) | |
| 41 | 68 | |
| 42 | - fun ingregarDatos(): ArrayList<ItemsServidores> { | |
| 69 | + return v | |
| 70 | + } | |
| 43 | 71 | |
| 44 | - val item=ItemsServidores(etNombreServidor.text.toString(),etDireccionServidor.text.toString(),"0") | |
| 72 | + fun ingresarDatos(): ArrayList<ItemsServidores> { | |
| 45 | 73 | |
| 46 | - val servidor = ServeInv( | |
| 47 | - etNombreServidor.text.toString(), | |
| 48 | - etDireccionServidor.text.toString(), | |
| 49 | - "0") | |
| 50 | - index+=index | |
| 74 | + val item = ItemsServidores(etNombreServidor.text.toString(), etDireccionServidor.text.toString(), "0") | |
| 75 | + val servidor = ServeInv(etNombreServidor.text.toString(), etDireccionServidor.text.toString(), "0") | |
| 76 | + index += index | |
| 51 | 77 | servidorNuevo.add(item) |
| 52 | 78 | val Job = GlobalScope.launch { |
| 53 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) | |
| 54 | - } | |
| 79 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) | |
| 80 | + } | |
| 55 | 81 | |
| 56 | 82 | return servidorNuevo |
| 57 | 83 | } |
| 58 | -} | |
| 59 | 84 | \ No newline at end of file |
| 85 | + | |
| 86 | + suspend fun buscarEnBD(): List<ServeInv> { | |
| 87 | + //TODO BUSQUEDA POR DESCRIPCION | |
| 88 | + var busqueda: List<ServeInv> | |
| 89 | + return GlobalScope.async(Dispatchers.IO) { | |
| 90 | + busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() | |
| 91 | + return@async busqueda | |
| 92 | + }.await() | |
| 93 | + } | |
| 94 | + | |
| 95 | + fun buscaEnBD() { | |
| 96 | + GlobalScope.launch(Dispatchers.Main) { | |
| 97 | + servidores = buscarEnBD() | |
| 98 | + for ((i, item) in servidores.withIndex()) { | |
| 99 | + val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | |
| 100 | + cargarRecicler(ser) | |
| 101 | + } | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + fun cargarRecicler(ser: ServeInv) { | |
| 106 | + //TODO CARGO EN LE RV | |
| 107 | + deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | |
| 108 | + val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado) | |
| 109 | + index += index | |
| 110 | + listIvn.add(item) | |
| 111 | + | |
| 112 | + viewAdapter = AdapterServidores(listIvn, requireContext()) | |
| 113 | + viewManager = LinearLayoutManager(requireContext()) | |
| 114 | + | |
| 115 | + rvServidores.apply { | |
| 116 | + adapter = viewAdapter | |
| 117 | + layoutManager = viewManager | |
| 118 | + } | |
| 119 | + val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | |
| 120 | + override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | |
| 121 | + return false | |
| 122 | + } | |
| 123 | + | |
| 124 | + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | |
| 125 | + BorrarInvActual(viewHolder.adapterPosition.toLong()) | |
| 126 | + | |
| 127 | + (viewAdapter as AdapterServidores).removeItem(viewHolder) | |
| 128 | + viewAdapter.notifyDataSetChanged() | |
| 129 | + } | |
| 130 | + | |
| 131 | + override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | |
| 132 | + val itemView = viewHolder.itemView | |
| 133 | + val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | |
| 134 | + c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | |
| 135 | + | |
| 136 | + if (dX > 0) { | |
| 137 | + | |
| 138 | + if (dX < c.width / 2) c.drawColor(Color.GREEN) | |
| 139 | + else c.drawColor(Color.RED) | |
| 140 | + deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
| 141 | + } else { } | |
| 142 | + | |
| 143 | + super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | |
| 144 | + deleteIcon.draw(c) | |
| 145 | + | |
| 146 | + } | |
| 147 | + } | |
| 148 | + | |
| 149 | + val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | |
| 150 | + itemTouchHelper.attachToRecyclerView(rvServidores) | |
| 151 | + } | |
| 152 | + private fun BorrarInvActual(idServer: Long) { | |
| 153 | + lifecycleScope.launch { | |
| 154 | + withContext(Dispatchers.IO) { | |
| 155 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(idServer) | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } | |
| 159 | +} |
app/src/main/res/drawable-v24/boton_borde_redondeado.xml
app/src/main/res/drawable/boton_redondo.xml
app/src/main/res/drawable/cod_origen.png
2.17 KB
app/src/main/res/drawable/codbar.png
1.53 KB
app/src/main/res/drawable/desc.png
2.24 KB
app/src/main/res/layout/fragment_actua_maestros.xml
| ... | ... | @@ -98,6 +98,9 @@ |
| 98 | 98 | android:layout_margin="20dp" |
| 99 | 99 | android:text="@string/btnConfirmarAct" |
| 100 | 100 | android:textSize="@dimen/NormalText" |
| 101 | + android:textColor="@android:color/white" | |
| 102 | + android:padding="10dp" | |
| 103 | + android:background="@drawable/boton_borde_redondeado" | |
| 101 | 104 | app:layout_constraintBottom_toBottomOf="parent" |
| 102 | 105 | app:layout_constraintEnd_toEndOf="parent" |
| 103 | 106 | app:layout_constraintStart_toStartOf="parent" /> |
| ... | ... | @@ -118,4 +121,5 @@ |
| 118 | 121 | app:layout_constraintEnd_toEndOf="parent" |
| 119 | 122 | app:layout_constraintStart_toStartOf="parent" |
| 120 | 123 | app:layout_constraintTop_toTopOf="parent" /> |
| 124 | + | |
| 121 | 125 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/fragment_configuracion.xml
| ... | ... | @@ -68,7 +68,9 @@ |
| 68 | 68 | android:id="@+id/btnValidarServidor" |
| 69 | 69 | android:layout_width="wrap_content" |
| 70 | 70 | android:layout_height="wrap_content" |
| 71 | - | |
| 71 | + android:textColor="@android:color/white" | |
| 72 | + android:padding="10dp" | |
| 73 | + android:background="@drawable/boton_borde_redondeado" | |
| 72 | 74 | android:text="@string/btnValidarServidor" |
| 73 | 75 | android:textSize="@dimen/NormalText" |
| 74 | 76 | app:layout_constraintBottom_toTopOf="@+id/btnAgregarServidor" |
| ... | ... | @@ -85,6 +87,9 @@ |
| 85 | 87 | android:layout_marginEnd="@dimen/MarginBotAgreSer" |
| 86 | 88 | android:text="@string/btnAgregarServidor" |
| 87 | 89 | android:textSize="@dimen/NormalText" |
| 90 | + android:textColor="@android:color/white" | |
| 91 | + android:padding="10dp" | |
| 92 | + android:background="@drawable/boton_borde_redondeado" | |
| 88 | 93 | app:layout_constraintBottom_toTopOf="@+id/tvUbicacionCarpetas" |
| 89 | 94 | app:layout_constraintEnd_toEndOf="parent" |
| 90 | 95 | app:layout_constraintStart_toStartOf="parent" |
| ... | ... | @@ -115,6 +120,9 @@ |
| 115 | 120 | android:layout_height="37dp" |
| 116 | 121 | android:layout_margin="10dp" |
| 117 | 122 | android:src="@drawable/search" |
| 123 | + android:textColor="@android:color/white" | |
| 124 | + android:padding="10dp" | |
| 125 | + android:background="@drawable/boton_borde_redondeado" | |
| 118 | 126 | app:layout_constraintEnd_toStartOf="@+id/etRuta" |
| 119 | 127 | app:layout_constraintStart_toStartOf="parent" |
| 120 | 128 | app:layout_constraintTop_toBottomOf="@+id/tvUbicacionCarpetas" /> |
| ... | ... | @@ -351,7 +359,9 @@ |
| 351 | 359 | android:text="@string/btnGuardar" |
| 352 | 360 | android:textSize="@dimen/NormalText" |
| 353 | 361 | app:layout_constraintEnd_toEndOf="parent" |
| 354 | - | |
| 362 | + android:textColor="@android:color/white" | |
| 363 | + android:padding="10dp" | |
| 364 | + android:background="@drawable/boton_borde_redondeado" | |
| 355 | 365 | app:layout_constraintStart_toStartOf="parent" |
| 356 | 366 | app:layout_constraintTop_toBottomOf="@+id/cbMostrarPrecio" /> |
| 357 | 367 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/fragment_descripcion.xml
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | xmlns:tools="http://schemas.android.com/tools" |
| 8 | 8 | android:layout_width="match_parent" |
| 9 | 9 | android:layout_height="match_parent" |
| 10 | - tools:context=".ui.inventario.DescripcionFragment"> | |
| 10 | + tools:context=".ui.descripcionFragment.DescripcionFragment"> | |
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | <androidx.recyclerview.widget.RecyclerView |
| ... | ... | @@ -27,6 +27,9 @@ app:layout_constraintTop_toBottomOf="@id/guideline4" |
| 27 | 27 | android:layout_width="0dp" |
| 28 | 28 | android:layout_height="wrap_content" |
| 29 | 29 | android:text="@string/btnCancelar" |
| 30 | + android:textColor="@android:color/white" | |
| 31 | + android:padding="10dp" | |
| 32 | + android:background="@drawable/boton_borde_redondeado" | |
| 30 | 33 | app:layout_constraintBottom_toBottomOf="@+id/guideline6" |
| 31 | 34 | app:layout_constraintEnd_toEndOf="parent" |
| 32 | 35 | app:layout_constraintHorizontal_chainStyle="spread" |
app/src/main/res/layout/fragment_inventario.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<androidx.constraintlayout.widget.ConstraintLayout | |
| 3 | - xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 5 | 4 | xmlns:tools="http://schemas.android.com/tools" |
| 6 | 5 | android:id="@+id/frameLayout" |
| ... | ... | @@ -31,64 +30,59 @@ |
| 31 | 30 | app:layout_constraintTop_toTopOf="@id/guideline" /> |
| 32 | 31 | |
| 33 | 32 | |
| 34 | - <androidx.appcompat.widget.AppCompatTextView | |
| 35 | - android:id="@+id/tvCodigoBarras" | |
| 36 | - android:layout_width="wrap_content" | |
| 37 | - android:layout_height="wrap_content" | |
| 38 | - android:layout_marginStart="5dp" | |
| 39 | - android:text="@string/invCodigoBarras" | |
| 40 | - android:textColor="@color/colorAccent" | |
| 41 | - android:textSize="@dimen/subTitulos" | |
| 42 | - app:fontFamily="sans-serif-condensed" | |
| 43 | - app:layout_constraintBottom_toTopOf="@+id/guideline3" | |
| 44 | - app:layout_constraintEnd_toStartOf="@+id/etCodigoBarras" | |
| 45 | - app:layout_constraintHorizontal_bias="0.0" | |
| 46 | - app:layout_constraintHorizontal_chainStyle="packed" | |
| 47 | - app:layout_constraintStart_toStartOf="parent" | |
| 48 | - app:layout_constraintTop_toTopOf="@id/guideline2" /> | |
| 33 | + <ImageButton | |
| 34 | + android:id="@+id/ivCamara" | |
| 35 | + android:layout_width="80dp" | |
| 36 | + android:layout_height="80dp" | |
| 37 | + | |
| 38 | + android:clickable="true" | |
| 39 | + android:contentDescription="@string/ibBusCB" | |
| 40 | + android:elevation="5dp" | |
| 41 | + android:background="@drawable/boton_redondo" | |
| 42 | + android:layout_margin="10dp" | |
| 43 | + android:focusable="false" | |
| 44 | + android:scaleType="fitEnd" | |
| 45 | + app:layout_constraintCircleRadius="40dp" | |
| 46 | + android:src="@drawable/codbar" | |
| 47 | + app:layout_constraintBottom_toTopOf="@id/guideline3" | |
| 48 | + app:layout_constraintEnd_toStartOf="@+id/etCodigoBarras" | |
| 49 | + app:layout_constraintHorizontal_bias="0.0" | |
| 50 | + app:layout_constraintStart_toStartOf="parent" | |
| 51 | + app:layout_constraintTop_toBottomOf="@+id/guideline2" /> | |
| 49 | 52 | |
| 50 | 53 | <EditText |
| 51 | 54 | android:id="@+id/etCodigoBarras" |
| 52 | - android:layout_width="wrap_content" | |
| 55 | + android:layout_width="0dp" | |
| 53 | 56 | android:layout_height="wrap_content" |
| 57 | + android:autofillHints="" | |
| 54 | 58 | android:clickable="true" |
| 55 | 59 | android:ems="10" |
| 56 | 60 | android:focusable="true" |
| 57 | - android:textAllCaps="true" | |
| 61 | + android:hint="@string/ibBusCB" | |
| 58 | 62 | android:inputType="textPersonName" |
| 59 | 63 | android:lines="1" |
| 60 | - android:text="" | |
| 64 | + android:textAllCaps="true" | |
| 61 | 65 | android:textSize="20sp" |
| 62 | - app:layout_constraintBaseline_toBaselineOf="@+id/tvCodigoBarras" | |
| 63 | - app:layout_constraintEnd_toEndOf="parent" | |
| 66 | + app:layout_constraintBottom_toTopOf="@+id/guideline3" | |
| 67 | + app:layout_constraintEnd_toStartOf="@+id/swSumaUno" | |
| 68 | + app:layout_constraintHorizontal_bias="0.49" | |
| 64 | 69 | app:layout_constraintHorizontal_chainStyle="packed" |
| 65 | - app:layout_constraintStart_toEndOf="@id/tvCodigoBarras" | |
| 66 | - android:autofillHints="" /> | |
| 70 | + app:layout_constraintStart_toEndOf="@+id/ivCamara" | |
| 71 | + app:layout_constraintTop_toBottomOf="@+id/guideline2" /> | |
| 72 | + | |
| 67 | 73 | |
| 68 | 74 | <Switch |
| 69 | 75 | android:id="@+id/swSumaUno" |
| 70 | 76 | android:layout_width="wrap_content" |
| 71 | 77 | android:layout_height="wrap_content" |
| 72 | - android:layout_marginStart="5dp" | |
| 73 | 78 | android:text="@string/switch_1" |
| 74 | 79 | app:layout_constraintBottom_toTopOf="@+id/guideline3" |
| 75 | 80 | app:layout_constraintEnd_toEndOf="parent" |
| 76 | 81 | app:layout_constraintStart_toEndOf="@id/etCodigoBarras" |
| 77 | 82 | app:layout_constraintTop_toTopOf="@id/guideline2" |
| 83 | + app:layout_constraintVertical_bias="1.0" | |
| 78 | 84 | tools:ignore="UseSwitchCompatOrMaterialXml" /> |
| 79 | 85 | |
| 80 | - <ImageButton | |
| 81 | - android:id="@+id/ivCamara" | |
| 82 | - android:layout_width="74dp" | |
| 83 | - android:layout_height="wrap_content" | |
| 84 | - android:layout_margin="10dp" | |
| 85 | - android:clickable="true" | |
| 86 | - android:contentDescription="TODO" | |
| 87 | - android:src="@drawable/camera" | |
| 88 | - app:layout_constraintBottom_toTopOf="@+id/guideline4" | |
| 89 | - app:layout_constraintStart_toStartOf="parent" | |
| 90 | - app:layout_constraintTop_toTopOf="@id/guideline3" /> | |
| 91 | - | |
| 92 | 86 | <androidx.recyclerview.widget.RecyclerView |
| 93 | 87 | android:id="@+id/rcInventarios" |
| 94 | 88 | android:layout_width="match_parent" |
| ... | ... | @@ -97,8 +91,8 @@ |
| 97 | 91 | app:layout_constraintBottom_toBottomOf="@+id/guideline5" |
| 98 | 92 | app:layout_constraintEnd_toEndOf="parent" |
| 99 | 93 | app:layout_constraintStart_toStartOf="parent" |
| 100 | - tools:listitem="@layout/item" | |
| 101 | - app:layout_constraintTop_toBottomOf="@+id/guideline4" /> | |
| 94 | + app:layout_constraintTop_toBottomOf="@+id/guideline4" | |
| 95 | + tools:listitem="@layout/item" /> | |
| 102 | 96 | |
| 103 | 97 | |
| 104 | 98 | <Button |
| ... | ... | @@ -106,6 +100,9 @@ |
| 106 | 100 | android:layout_width="wrap_content" |
| 107 | 101 | android:layout_height="wrap_content" |
| 108 | 102 | android:text="@string/btnExportarInv" |
| 103 | + android:textColor="@android:color/white" | |
| 104 | + android:padding="10dp" | |
| 105 | + android:background="@drawable/boton_borde_redondeado" | |
| 109 | 106 | app:layout_constraintBottom_toBottomOf="@+id/guideline6" |
| 110 | 107 | app:layout_constraintEnd_toEndOf="parent" |
| 111 | 108 | app:layout_constraintHorizontal_chainStyle="spread" |
| ... | ... | @@ -121,6 +118,9 @@ |
| 121 | 118 | app:layout_constraintEnd_toStartOf="@id/btnExportarInv" |
| 122 | 119 | app:layout_constraintHorizontal_chainStyle="spread" |
| 123 | 120 | app:layout_constraintStart_toStartOf="parent" |
| 121 | + android:textColor="@android:color/white" | |
| 122 | + android:padding="10dp" | |
| 123 | + android:background="@drawable/boton_borde_redondeado" | |
| 124 | 124 | app:layout_constraintTop_toBottomOf="@+id/guideline5" /> |
| 125 | 125 | |
| 126 | 126 | <androidx.constraintlayout.widget.Guideline |
| ... | ... | @@ -128,14 +128,14 @@ |
| 128 | 128 | android:layout_width="wrap_content" |
| 129 | 129 | android:layout_height="wrap_content" |
| 130 | 130 | android:orientation="horizontal" |
| 131 | - app:layout_constraintGuide_percent="0.05" /> | |
| 131 | + app:layout_constraintGuide_percent="0.02" /> | |
| 132 | 132 | |
| 133 | 133 | <androidx.constraintlayout.widget.Guideline |
| 134 | 134 | android:id="@+id/guideline2" |
| 135 | 135 | android:layout_width="wrap_content" |
| 136 | 136 | android:layout_height="wrap_content" |
| 137 | 137 | android:orientation="horizontal" |
| 138 | - app:layout_constraintGuide_percent="0.15" /> | |
| 138 | + app:layout_constraintGuide_percent="0.12" /> | |
| 139 | 139 | |
| 140 | 140 | <androidx.constraintlayout.widget.Guideline |
| 141 | 141 | android:id="@+id/guideline3" |
| ... | ... | @@ -165,14 +165,5 @@ |
| 165 | 165 | android:orientation="horizontal" |
| 166 | 166 | app:layout_constraintGuide_percent="0.97" /> |
| 167 | 167 | |
| 168 | - <ToggleButton | |
| 169 | - android:id="@+id/toggleButton" | |
| 170 | - android:layout_width="wrap_content" | |
| 171 | - android:layout_height="wrap_content" | |
| 172 | - android:text="ToggleButton" | |
| 173 | - app:layout_constraintBottom_toTopOf="@+id/rcInventarios" | |
| 174 | - app:layout_constraintEnd_toEndOf="parent" | |
| 175 | - app:layout_constraintStart_toEndOf="@+id/ivCamara" /> | |
| 176 | - | |
| 177 | 168 | |
| 178 | 169 | </androidx.constraintlayout.widget.ConstraintLayout> |
| 179 | 170 | \ No newline at end of file |
app/src/main/res/layout/fragment_servidores.xml
| ... | ... | @@ -119,6 +119,9 @@ |
| 119 | 119 | android:layout_width="0dp" |
| 120 | 120 | android:layout_height="wrap_content" |
| 121 | 121 | android:text="@string/btnGuardarServidores" |
| 122 | + android:textColor="@android:color/white" | |
| 123 | + android:padding="10dp" | |
| 124 | + android:background="@drawable/boton_borde_redondeado" | |
| 122 | 125 | app:layout_constraintBottom_toBottomOf="@+id/guideline6" |
| 123 | 126 | app:layout_constraintEnd_toEndOf="parent" |
| 124 | 127 | app:layout_constraintStart_toStartOf="parent" /> |
app/src/main/res/layout/ingresar_cantidad.xml
| ... | ... | @@ -75,9 +75,11 @@ |
| 75 | 75 | android:layout_marginBottom="20dp" |
| 76 | 76 | android:clickable="true" |
| 77 | 77 | android:focusable="true" |
| 78 | + android:textColor="@android:color/white" | |
| 79 | + android:padding="10dp" | |
| 80 | + android:background="@drawable/boton_borde_redondeado" | |
| 78 | 81 | android:text="@string/btnConfirmar" |
| 79 | 82 | android:textAlignment="center" |
| 80 | - android:textColor="@android:color/black" | |
| 81 | 83 | android:textSize="20sp" |
| 82 | 84 | android:textStyle="bold" |
| 83 | 85 | app:cardBackgroundColor="@android:color/darker_gray" |
app/src/main/res/layout/item.xml
| ... | ... | @@ -145,7 +145,22 @@ |
| 145 | 145 | app:layout_constraintEnd_toEndOf="parent" |
| 146 | 146 | app:layout_constraintStart_toEndOf="@+id/textView85" |
| 147 | 147 | app:layout_constraintTop_toBottomOf="@+id/tvCodigo" /> |
| 148 | - | |
| 148 | + <TextView | |
| 149 | + android:id="@+id/tvCodigoOrigen" | |
| 150 | + android:layout_width="match_parent" | |
| 151 | + android:layout_height="wrap_content" | |
| 152 | + android:layout_marginStart="3dp" | |
| 153 | + android:layout_marginTop="8dp" | |
| 154 | + android:maxLines="2" | |
| 155 | + android:text="" | |
| 156 | + android:textAppearance="@style/TextAppearance.AppCompat.Large" | |
| 157 | + android:textSize="14sp" | |
| 158 | + android:visibility="gone" | |
| 159 | + android:textStyle="bold" | |
| 160 | + app:layout_constraintBaseline_toBaselineOf="@+id/textView85" | |
| 161 | + app:layout_constraintEnd_toEndOf="parent" | |
| 162 | + app:layout_constraintStart_toEndOf="@+id/textView85" | |
| 163 | + app:layout_constraintTop_toBottomOf="@+id/tvCodigo" /> | |
| 149 | 164 | </androidx.constraintlayout.widget.ConstraintLayout> |
| 150 | 165 | |
| 151 | 166 | </androidx.cardview.widget.CardView> |
| 152 | 167 | \ No newline at end of file |
app/src/main/res/layout/login_dialog.xml
| ... | ... | @@ -145,7 +145,9 @@ |
| 145 | 145 | android:id="@+id/dialogLoginBtn" |
| 146 | 146 | style="@style/Base.Widget.AppCompat.Button.Colored" |
| 147 | 147 | android:layout_width="wrap_content" |
| 148 | + android:textColor="@android:color/white" | |
| 148 | 149 | android:padding="20dp" |
| 150 | + android:background="@drawable/boton_borde_redondeado" | |
| 149 | 151 | android:layout_margin="5dp" |
| 150 | 152 | android:layout_height="wrap_content" |
| 151 | 153 | android:text="@string/btnOk" /> |
| ... | ... | @@ -153,7 +155,9 @@ |
| 153 | 155 | <Button |
| 154 | 156 | android:id="@+id/dialogCancelBtn" |
| 155 | 157 | style="@style/Base.Widget.AppCompat.Button.Colored" |
| 158 | + android:textColor="@android:color/white" | |
| 156 | 159 | android:padding="20dp" |
| 160 | + android:background="@drawable/boton_borde_redondeado" | |
| 157 | 161 | android:layout_margin="5dp" |
| 158 | 162 | android:layout_width="wrap_content" |
| 159 | 163 | android:layout_height="wrap_content" |
app/src/main/res/navigation/mobile_navigation.xml
| ... | ... | @@ -91,7 +91,7 @@ |
| 91 | 91 | </fragment> |
| 92 | 92 | <fragment |
| 93 | 93 | android:id="@+id/descripcionFragment" |
| 94 | - android:name="com.focasoftware.deboinventariov20.ui.inventario.DescripcionFragment" | |
| 94 | + android:name="com.focasoftware.deboinventariov20.ui.descripcionFragment.DescripcionFragment" | |
| 95 | 95 | android:label="Productos Encontrados"> |
| 96 | 96 | |
| 97 | 97 | <action |
app/src/main/res/values/colors.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <resources> |
| 3 | - <color name="colorPrimaryDark">#3700B3</color> | |
| 4 | - <color name="colorAccent">#03DAC5</color> | |
| 3 | + <color name="colorPrimaryDark">#085394</color> | |
| 4 | + <color name="colorAccent">#3F51B5</color> | |
| 5 | 5 | <color name="colorPrimary">#085394</color> |
| 6 | 6 | <color name="backMenu">#dddddd</color> |
| 7 | 7 | <color name="LightGray">#E0E0E0</color> |
app/src/main/res/values/strings.xml
| ... | ... | @@ -43,12 +43,15 @@ |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | <!-- Fragment Inventario--> |
| 46 | - <string name="invTitulo">Inventarios Dinamicos</string> | |
| 46 | + <string name="invTitulo">Inventarios Dinámicos</string> | |
| 47 | 47 | <string name="invTituloV">Inventarios de Ventas</string> |
| 48 | 48 | <string name="invTituloD">Inventarios de Depositos</string> |
| 49 | 49 | <string name="invCodigoBarras">Código Barras:</string> |
| 50 | 50 | <string name="btnExportarInv">Exportar Inventario</string> |
| 51 | 51 | <string name="btnBorrarInv">Borrar Inventario</string> |
| 52 | + <string name="ibBusDesc">Busqueda por Descripción</string> | |
| 53 | + <string name="ibBusCB">Busqueda por C. Barras</string> | |
| 54 | + <string name="ibBusCO">Busqueda por Código de Origen</string> | |
| 52 | 55 | <string name="switch_1">+ 1</string> |
| 53 | 56 | |
| 54 | 57 | <!-- Fragmento Configuraciones--> |