Commit a0d8dd74dd0d924dbcc9e0a269fb346485ef05f8
1 parent
15c37e974e
Exists in
master
01092020 0128
Showing
10 changed files
with
98 additions
and
112 deletions
Show diff stats
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
| ... | ... | @@ -77,12 +77,18 @@ interface ServeInvDao { |
| 77 | 77 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
| 78 | 78 | fun insertServer(servidor: ServeInv) |
| 79 | 79 | |
| 80 | - @Query("SELECT * FROM ServeInv") | |
| 80 | + @Query("SELECT * FROM $TABLA_SERV_INV") | |
| 81 | 81 | suspend fun fetchAllServers(): List<ServeInv> |
| 82 | 82 | |
| 83 | - @Query("DELETE FROM ServeInv WHERE SER_NUM = :number") | |
| 84 | - suspend fun deleteServer(number: Long) | |
| 83 | + @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") | |
| 84 | + suspend fun deleteServer(description: String, dir: String) | |
| 85 | 85 | |
| 86 | - @Query("SELECT SER_NUM FROM ServeInv ORDER BY SER_NUM DESC") | |
| 87 | - suspend fun findLastSer(): Long | |
| 86 | + @Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC") | |
| 87 | + suspend fun findLastServer(): Int | |
| 88 | + | |
| 89 | + @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0") | |
| 90 | + suspend fun UpdateServerPreInZero() | |
| 91 | + | |
| 92 | + @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") | |
| 93 | + suspend fun UpdateServerPre(description: String, dir: String) | |
| 88 | 94 | } |
| 89 | 95 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/Model/Tablas.kt
| ... | ... | @@ -81,10 +81,12 @@ data class InvBody(@ColumnInfo(name = "INV_NUM") var invNum: Int, |
| 81 | 81 | |
| 82 | 82 | @Entity(tableName = TABLA_SERV_INV) |
| 83 | 83 | data class ServeInv( |
| 84 | - | |
| 85 | - @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "SER_NUM") var SER_NUM: Long, | |
| 86 | 84 | @ColumnInfo(name = "SER_DESC") var descripcion: String?, |
| 87 | 85 | @ColumnInfo(name = "SER_DIR") var direccion: String?, |
| 88 | - @ColumnInfo(name = "SER_PRE") var predeterminado: String?) | |
| 86 | + @ColumnInfo(name = "SER_PRE") var predeterminado: String?): | |
| 87 | + Serializable { @PrimaryKey(autoGenerate = true) | |
| 88 | +@ColumnInfo(name = "SER_NUM") | |
| 89 | +var servNum: Int=0 | |
| 90 | +} | |
| 89 | 91 | |
| 90 | 92 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/actualizacionMaestros/ActuaMaestrosFragment.kt
| ... | ... | @@ -36,7 +36,7 @@ class ActuaMaestrosFragment : Fragment() { |
| 36 | 36 | val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) |
| 37 | 37 | bConfirmarAct.setOnClickListener { |
| 38 | 38 | loading_view.visibility = View.VISIBLE |
| 39 | - countriesList.text = "Obteniendo Maestros Aguarde,por favor." | |
| 39 | + countriesList.text = "Obteniendo Maestros de artículos, aguarde por favor." | |
| 40 | 40 | obtenerArticulos() |
| 41 | 41 | } |
| 42 | 42 | return v |
app/src/main/java/com/focasoftware/deboinventariov20/ui/configuracion/ConfiguracionFragment.kt
| ... | ... | @@ -3,14 +3,20 @@ package com.focasoftware.deboinventariov20.ui.configuracion |
| 3 | 3 | import android.content.Context |
| 4 | 4 | import android.content.SharedPreferences |
| 5 | 5 | import android.os.Bundle |
| 6 | -import androidx.fragment.app.Fragment | |
| 7 | 6 | import android.view.LayoutInflater |
| 8 | 7 | import android.view.View |
| 9 | 8 | import android.view.ViewGroup |
| 10 | 9 | import android.widget.* |
| 10 | +import androidx.fragment.app.Fragment | |
| 11 | 11 | import androidx.navigation.fragment.findNavController |
| 12 | +import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | |
| 13 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
| 12 | 14 | import com.focasoftware.deboinventariov20.R |
| 13 | 15 | import kotlinx.android.synthetic.main.fragment_configuracion.* |
| 16 | +import kotlinx.coroutines.Dispatchers | |
| 17 | +import kotlinx.coroutines.GlobalScope | |
| 18 | +import kotlinx.coroutines.async | |
| 19 | +import kotlinx.coroutines.launch | |
| 14 | 20 | |
| 15 | 21 | class ConfiguracionFragment : Fragment() { |
| 16 | 22 | |
| ... | ... | @@ -21,10 +27,7 @@ class ConfiguracionFragment : Fragment() { |
| 21 | 27 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | - override fun onCreateView( | |
| 25 | - inflater: LayoutInflater, container: ViewGroup?, | |
| 26 | - savedInstanceState: Bundle? | |
| 27 | - ): View? { | |
| 30 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| 28 | 31 | val v = inflater.inflate(R.layout.fragment_configuracion, container, false) |
| 29 | 32 | |
| 30 | 33 | val etRuta = v.findViewById<EditText>(R.id.etRuta) |
| ... | ... | @@ -41,14 +44,14 @@ class ConfiguracionFragment : Fragment() { |
| 41 | 44 | val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) |
| 42 | 45 | val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) |
| 43 | 46 | val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) |
| 47 | + val spServidor = v.findViewById<Spinner>(R.id.spServidor) | |
| 48 | + val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) | |
| 44 | 49 | |
| 45 | - if (sharedPreferences.contains("etRuta")) etRuta.setText( | |
| 46 | - sharedPreferences.getString("etRuta", "").toString() | |
| 47 | - ) | |
| 50 | + if (sharedPreferences.contains("etRuta")) etRuta.setText(sharedPreferences.getString("etRuta", "").toString()) | |
| 48 | 51 | |
| 49 | 52 | if (sharedPreferences.contains("rbProInclu")) { |
| 50 | 53 | if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { |
| 51 | - rbProInclu.isChecked=false | |
| 54 | + rbProInclu.isChecked = false | |
| 52 | 55 | rbProNoInclu.isChecked = true |
| 53 | 56 | } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { |
| 54 | 57 | rbProInclu.isChecked = true |
| ... | ... | @@ -62,14 +65,14 @@ class ConfiguracionFragment : Fragment() { |
| 62 | 65 | rbProInclu.isChecked = true |
| 63 | 66 | } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { |
| 64 | 67 | rbProNoInclu.isChecked = true |
| 65 | - rbProInclu.isChecked=false | |
| 68 | + rbProInclu.isChecked = false | |
| 66 | 69 | } |
| 67 | 70 | } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") |
| 68 | 71 | |
| 69 | 72 | |
| 70 | 73 | if (sharedPreferences.contains("cbHabiLectura")) { |
| 71 | 74 | if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { |
| 72 | - cbHabiLectura.isChecked=false | |
| 75 | + cbHabiLectura.isChecked = false | |
| 73 | 76 | } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { |
| 74 | 77 | cbHabiLectura.isChecked = true |
| 75 | 78 | } |
| ... | ... | @@ -87,7 +90,7 @@ class ConfiguracionFragment : Fragment() { |
| 87 | 90 | |
| 88 | 91 | if (sharedPreferences.contains("rbVentas")) { |
| 89 | 92 | if (sharedPreferences.getString("rbVentas", "").toString() == "0") { |
| 90 | - rbVentas.isChecked=false | |
| 93 | + rbVentas.isChecked = false | |
| 91 | 94 | rbDeposito.isChecked = true |
| 92 | 95 | } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { |
| 93 | 96 | rbVentas.isChecked = true |
| ... | ... | @@ -101,15 +104,13 @@ class ConfiguracionFragment : Fragment() { |
| 101 | 104 | rbVentas.isChecked = true |
| 102 | 105 | } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { |
| 103 | 106 | rbDeposito.isChecked = true |
| 104 | - rbVentas.isChecked=false | |
| 107 | + rbVentas.isChecked = false | |
| 105 | 108 | } |
| 106 | 109 | } else (sharedPreferences.getString("rbDeposito", "").toString() == "") |
| 107 | 110 | |
| 108 | - | |
| 109 | - | |
| 110 | 111 | if (sharedPreferences.contains("rbCodigoDebo")) { |
| 111 | 112 | if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { |
| 112 | - rbCodigoDebo.isChecked=false | |
| 113 | + rbCodigoDebo.isChecked = false | |
| 113 | 114 | rbCodigoOrigen.isChecked = false |
| 114 | 115 | rbCodigoBarras.isChecked = false |
| 115 | 116 | } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { |
| ... | ... | @@ -137,7 +138,7 @@ class ConfiguracionFragment : Fragment() { |
| 137 | 138 | |
| 138 | 139 | if (sharedPreferences.contains("cbMostrarExistencia")) { |
| 139 | 140 | if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { |
| 140 | - cbMostrarExistencia.isChecked=false | |
| 141 | + cbMostrarExistencia.isChecked = false | |
| 141 | 142 | } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { |
| 142 | 143 | cbMostrarExistencia.isChecked = true |
| 143 | 144 | } |
| ... | ... | @@ -154,17 +155,32 @@ class ConfiguracionFragment : Fragment() { |
| 154 | 155 | |
| 155 | 156 | btnGuardar.setOnClickListener { |
| 156 | 157 | guardarPreferencias() |
| 157 | - Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG) | |
| 158 | - .show() | |
| 158 | + Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() | |
| 159 | 159 | } |
| 160 | - btnAgregarServidor.setOnClickListener { | |
| 160 | + btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } | |
| 161 | 161 | |
| 162 | - findNavController().navigate(R.id.servidoresFragment) | |
| 162 | + GlobalScope.launch(Dispatchers.Main) { | |
| 163 | + val listServerDescription = arrayListOf<String>() | |
| 164 | + for (any in getDescServers()) { | |
| 165 | + listServerDescription.add(any.descripcion.toString()) | |
| 166 | + } | |
| 167 | + if (spServidor != null) { | |
| 168 | + val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, listServerDescription) | |
| 169 | + spServidor.adapter = adapter | |
| 170 | + } | |
| 171 | + } | |
| 172 | + btnValidarServidor.setOnClickListener { | |
| 173 | + Toast.makeText(requireContext(), "Dirección correcta", Toast.LENGTH_LONG).show() | |
| 163 | 174 | } |
| 164 | - | |
| 165 | 175 | return v |
| 166 | 176 | } |
| 167 | 177 | |
| 178 | + suspend fun getDescServers(): List<ServeInv> { | |
| 179 | + return GlobalScope.async(Dispatchers.IO) { | |
| 180 | + return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() | |
| 181 | + }.await() | |
| 182 | + } | |
| 183 | + | |
| 168 | 184 | fun guardarPreferencias() { |
| 169 | 185 | try { |
| 170 | 186 | val editor = sharedPreferences.edit() |
| ... | ... | @@ -174,36 +190,22 @@ class ConfiguracionFragment : Fragment() { |
| 174 | 190 | if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") |
| 175 | 191 | if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") |
| 176 | 192 | |
| 177 | - if (cbHabiLectura.isChecked) editor?.putString( | |
| 178 | - "cbHabiLectura", "1" | |
| 179 | - ) else editor?.putString("cbHabiLectura", "0") | |
| 180 | - if (cbMostrarStock.isChecked) editor?.putString( | |
| 181 | - "cbMostrarStock", "1" | |
| 182 | - ) else editor?.putString("cbMostrarStock", "0") | |
| 183 | - if (rbVentas.isChecked) editor?.putString( | |
| 184 | - "rbVentas", "1" | |
| 185 | - ) else editor?.putString("rbVentas", "0") | |
| 186 | - if (rbDeposito.isChecked) editor?.putString( | |
| 187 | - "rbDeposito", "1" | |
| 188 | - ) else editor?.putString("rbDeposito", "0") | |
| 189 | - if (rbCodigoDebo.isChecked) editor?.putString( | |
| 190 | - "rbCodigoDebo", "1" | |
| 191 | - ) else editor?.putString("rbCodigoDebo", "0") | |
| 192 | - if (rbCodigoOrigen.isChecked) editor?.putString( | |
| 193 | - "rbCodigoOrigen", "1" | |
| 194 | - ) else editor?.putString("rbCodigoOrigen", "0") | |
| 195 | - if (rbCodigoBarras.isChecked) editor?.putString( | |
| 196 | - "rbCodigoBarras", "1" | |
| 197 | - ) else editor?.putString("rbCodigoBarras", "0") | |
| 198 | - if (cbMostrarExistencia.isChecked) editor?.putString( | |
| 199 | - "cbMostrarExistencia", "1" | |
| 200 | - ) else editor?.putString("cbMostrarExistencia", "0") | |
| 201 | - if (cbMostrarPrecio.isChecked) editor?.putString( | |
| 202 | - "cbMostrarPrecio", "1" | |
| 203 | - ) else editor?.putString("cbMostrarPrecio", "0") | |
| 193 | + if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") | |
| 194 | + if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") | |
| 195 | + if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") | |
| 196 | + if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") | |
| 197 | + if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") | |
| 198 | + if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") | |
| 199 | + if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") | |
| 200 | + if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") | |
| 201 | + if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") | |
| 204 | 202 | |
| 205 | 203 | editor?.apply() |
| 206 | 204 | editor.commit() |
| 205 | + GlobalScope.launch(Dispatchers.Main) { | |
| 206 | + | |
| 207 | + | |
| 208 | + } | |
| 207 | 209 | } catch (e: Exception) { |
| 208 | 210 | e.printStackTrace() |
| 209 | 211 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
| ... | ... | @@ -6,10 +6,7 @@ import android.os.Bundle |
| 6 | 6 | import android.view.LayoutInflater |
| 7 | 7 | import android.view.View |
| 8 | 8 | import android.view.ViewGroup |
| 9 | -import android.widget.CheckBox | |
| 10 | -import android.widget.ImageView | |
| 11 | -import android.widget.LinearLayout | |
| 12 | -import android.widget.TextView | |
| 9 | +import android.widget.* | |
| 13 | 10 | import androidx.fragment.app.Fragment |
| 14 | 11 | import androidx.navigation.NavController |
| 15 | 12 | import androidx.navigation.Navigation |
| ... | ... | @@ -47,8 +44,8 @@ private var listIvn2 = ArrayList<InvHead>() |
| 47 | 44 | val v = inflater.inflate(R.layout.fragment_main, container, false) |
| 48 | 45 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) |
| 49 | 46 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) |
| 50 | - val ivSort19= v.findViewById<ImageView>(R.id.ivSort19) | |
| 51 | - val ivSort91= v.findViewById<ImageView>(R.id.ivSort91) | |
| 47 | + val ivSort19= v.findViewById<ImageButton>(R.id.ivSort19) | |
| 48 | + val ivSort91= v.findViewById<ImageButton>(R.id.ivSort91) | |
| 52 | 49 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) |
| 53 | 50 | val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) |
| 54 | 51 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/AdapterServidores.kt
| ... | ... | @@ -42,10 +42,5 @@ class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, privat |
| 42 | 42 | |
| 43 | 43 | servidor.removeAt(viewHolder.adapterPosition) |
| 44 | 44 | notifyItemRemoved(viewHolder.adapterPosition) |
| 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 | 45 | } |
| 51 | 46 | } |
| 52 | 47 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ItemsServidores.kt
| 1 | 1 | package com.focasoftware.deboinventariov20.ui.servidores |
| 2 | 2 | |
| 3 | -data class ItemsServidores(val ID: Long?, val descripcion: String?, var direccion: String?, var predeterminado: String?) | |
| 4 | 3 | \ No newline at end of file |
| 4 | +data class ItemsServidores(val descripcion: String?, var direccion: String?, var predeterminado: String?) | |
| 5 | 5 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ServidoresFragment.kt
| ... | ... | @@ -25,7 +25,7 @@ class ServidoresFragment : Fragment() { |
| 25 | 25 | private lateinit var rvServidores: RecyclerView |
| 26 | 26 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
| 27 | 27 | private lateinit var viewManager: RecyclerView.LayoutManager |
| 28 | - private var listIvn = java.util.ArrayList<ItemsServidores>() | |
| 28 | + private var listServ = ArrayList<ItemsServidores>() | |
| 29 | 29 | private lateinit var servidores: List<ServeInv> |
| 30 | 30 | private lateinit var deleteIcon: Drawable |
| 31 | 31 | |
| ... | ... | @@ -37,9 +37,6 @@ class ServidoresFragment : Fragment() { |
| 37 | 37 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 38 | 38 | super.onViewCreated(view, savedInstanceState) |
| 39 | 39 | |
| 40 | -// rvServidores.layoutManager = LinearLayoutManager(context) | |
| 41 | -// rvServidores.itemAnimator = DefaultItemAnimator() | |
| 42 | - | |
| 43 | 40 | btnGuardarServidores.setOnClickListener { |
| 44 | 41 | if (etNombreServidor.text.isNullOrBlank()) { |
| 45 | 42 | etNombreServidor.error = "Nombre no valido" |
| ... | ... | @@ -52,15 +49,15 @@ class ServidoresFragment : Fragment() { |
| 52 | 49 | etDireccionServidor.hint = "Dirección no valida" |
| 53 | 50 | } |
| 54 | 51 | if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()) { |
| 52 | +// GlobalScope.launch(Dispatchers.Main) { | |
| 53 | +// ServerNew =AppDb.getAppDb(requireContext())?.ServeInvDao()?.findLastServer()?.plus(1) ?: 1 | |
| 54 | + val servidor = ServeInv(etNombreServidor.text.toString(), "http://${etDireccionServidor.text}/", "0") | |
| 55 | + ingresarDatos(servidor) | |
| 56 | + cargarRecicler(servidor) | |
| 55 | 57 | Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() |
| 56 | - GlobalScope.launch(Dispatchers.Main) { | |
| 57 | - val num: Long = buscaUltimoNroEnBD() | |
| 58 | - val servidor = ServeInv(num, etNombreServidor.text.toString(), "http://${etDireccionServidor.text}/", "0") | |
| 59 | - ingresarDatos(servidor) | |
| 60 | - cargarRecicler(servidor) | |
| 61 | - } | |
| 62 | 58 | etNombreServidor.text.clear() |
| 63 | 59 | etDireccionServidor.text.clear() |
| 60 | +// } | |
| 64 | 61 | } |
| 65 | 62 | } |
| 66 | 63 | } |
| ... | ... | @@ -71,17 +68,7 @@ class ServidoresFragment : Fragment() { |
| 71 | 68 | return v |
| 72 | 69 | } |
| 73 | 70 | |
| 74 | - | |
| 75 | - suspend fun buscaUltimoNroEnBD(): Long { | |
| 76 | - | |
| 77 | - var busqueda: Long | |
| 78 | - return GlobalScope.async(Dispatchers.IO) { | |
| 79 | - busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.findLastSer() | |
| 80 | - return@async busqueda | |
| 81 | - }.await() | |
| 82 | - } | |
| 83 | - | |
| 84 | - fun ingresarDatos(servidor:ServeInv) { | |
| 71 | + fun ingresarDatos(servidor: ServeInv) { | |
| 85 | 72 | val Job = GlobalScope.launch { |
| 86 | 73 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) |
| 87 | 74 | } |
| ... | ... | @@ -100,7 +87,7 @@ class ServidoresFragment : Fragment() { |
| 100 | 87 | GlobalScope.launch(Dispatchers.Main) { |
| 101 | 88 | servidores = buscarEnBD() |
| 102 | 89 | for ((i, item) in servidores.withIndex()) { |
| 103 | - val ser = ServeInv(servidores[i].SER_NUM, servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | |
| 90 | + val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | |
| 104 | 91 | cargarRecicler(ser) |
| 105 | 92 | } |
| 106 | 93 | } |
| ... | ... | @@ -109,11 +96,11 @@ class ServidoresFragment : Fragment() { |
| 109 | 96 | fun cargarRecicler(ser: ServeInv) { |
| 110 | 97 | //TODO CARGO EN LE RV |
| 111 | 98 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! |
| 112 | - val item = ItemsServidores(ser.SER_NUM, ser.descripcion, ser.direccion, ser.predeterminado) | |
| 99 | + val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado) | |
| 113 | 100 | |
| 114 | - listIvn.add(item) | |
| 101 | + listServ.add(item) | |
| 115 | 102 | |
| 116 | - viewAdapter = AdapterServidores(listIvn, requireContext()) | |
| 103 | + viewAdapter = AdapterServidores(listServ, requireContext()) | |
| 117 | 104 | viewManager = LinearLayoutManager(requireContext()) |
| 118 | 105 | |
| 119 | 106 | rvServidores.apply { |
| ... | ... | @@ -126,11 +113,12 @@ class ServidoresFragment : Fragment() { |
| 126 | 113 | } |
| 127 | 114 | |
| 128 | 115 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { |
| 129 | -// viewManager[ | |
| 130 | -// BorrarInvActual(viewHolder.adapterPosition.toInt()) | |
| 116 | + GlobalScope.launch(Dispatchers.Main) { | |
| 117 | + deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) | |
| 131 | 118 | |
| 132 | - (viewAdapter as AdapterServidores).removeItem(viewHolder) | |
| 133 | - viewAdapter.notifyDataSetChanged() | |
| 119 | + (viewAdapter as AdapterServidores).removeItem(viewHolder) | |
| 120 | + viewAdapter.notifyDataSetChanged() | |
| 121 | + } | |
| 134 | 122 | } |
| 135 | 123 | |
| 136 | 124 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
| ... | ... | @@ -145,10 +133,8 @@ class ServidoresFragment : Fragment() { |
| 145 | 133 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) |
| 146 | 134 | } else { |
| 147 | 135 | } |
| 148 | - | |
| 149 | 136 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
| 150 | 137 | deleteIcon.draw(c) |
| 151 | - | |
| 152 | 138 | } |
| 153 | 139 | } |
| 154 | 140 | |
| ... | ... | @@ -156,10 +142,10 @@ class ServidoresFragment : Fragment() { |
| 156 | 142 | itemTouchHelper.attachToRecyclerView(rvServidores) |
| 157 | 143 | } |
| 158 | 144 | |
| 159 | - private fun BorrarInvActual(idServer: Long) { | |
| 145 | + suspend fun deleteServer(serverName: String, serverDir: String) { | |
| 160 | 146 | lifecycleScope.launch { |
| 161 | 147 | withContext(Dispatchers.IO) { |
| 162 | - AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(idServer) | |
| 148 | + AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) | |
| 163 | 149 | } |
| 164 | 150 | } |
| 165 | 151 | } |
app/src/main/res/layout/fragment_main.xml
| ... | ... | @@ -23,13 +23,12 @@ |
| 23 | 23 | app:layout_constraintStart_toStartOf="parent" |
| 24 | 24 | app:layout_constraintTop_toTopOf="parent" /> |
| 25 | 25 | |
| 26 | - <ImageView | |
| 26 | + <androidx.appcompat.widget.AppCompatImageButton | |
| 27 | 27 | android:id="@+id/ivSort19" |
| 28 | - android:layout_width="35dp" | |
| 29 | - android:layout_height="35dp" | |
| 28 | + android:layout_width="50dp" | |
| 29 | + android:layout_height="50dp" | |
| 30 | 30 | android:layout_margin="10dp" |
| 31 | 31 | android:padding="5dp" |
| 32 | - android:contentDescription=" " | |
| 33 | 32 | android:visibility="gone" |
| 34 | 33 | android:src="@drawable/ic_sort19" |
| 35 | 34 | app:layout_constraintHorizontal_bias="0.0" |
| ... | ... | @@ -37,14 +36,13 @@ |
| 37 | 36 | app:layout_constraintStart_toStartOf="parent" |
| 38 | 37 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
| 39 | 38 | |
| 40 | - <ImageView | |
| 39 | + <androidx.appcompat.widget.AppCompatImageButton | |
| 41 | 40 | android:id="@+id/ivSort91" |
| 42 | - android:layout_width="35dp" | |
| 43 | - android:layout_height="35dp" | |
| 41 | + android:layout_width="50dp" | |
| 42 | + android:layout_height="50dp" | |
| 44 | 43 | android:layout_margin="10dp" |
| 45 | 44 | android:padding="5dp" |
| 46 | 45 | android:layout_marginTop="12dp" |
| 47 | - android:contentDescription="Fecha" | |
| 48 | 46 | android:visibility="gone" |
| 49 | 47 | android:src="@drawable/ic_sort91" |
| 50 | 48 | app:layout_constraintHorizontal_bias="1.0" |
app/src/main/res/values/strings.xml
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | |
| 26 | 26 | <!-- inventarios dinamicos--> |
| 27 | 27 | <string name="invDinamicoVenta">Inventarios Dinamicos</string> |
| 28 | - <string name="invDinamicoCompra">Inventarios Importados(0)+</string> | |
| 28 | + <string name="invDinamicoCompra">Inventarios Importados(0) +</string> | |
| 29 | 29 | |
| 30 | 30 | <!-- ventana emergente--> |
| 31 | 31 | <string name="adv">Ingrese la cantidad contada</string> |