Commit 7483a587d551113ac6342b2e7b461d48da2b717f
1 parent
a0d8dd74dd
Exists in
master
01092020 1658
Showing
8 changed files
with
68 additions
and
35 deletions
Show diff stats
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
... | ... | @@ -91,4 +91,7 @@ interface ServeInvDao { |
91 | 91 | |
92 | 92 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") |
93 | 93 | suspend fun UpdateServerPre(description: String, dir: String) |
94 | + | |
95 | + @Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE =:sOne") | |
96 | + suspend fun fetchServerPreOne(sOne: String): ServeInv | |
94 | 97 | } |
95 | 98 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/Model/ProductosService.kt
1 | 1 | package com.focasoftware.deboinventariov20.Model |
2 | 2 | |
3 | +import com.focasoftware.deboinventariov20.ui.actualizacionMaestros.BASE_URL | |
3 | 4 | import retrofit2.Retrofit |
4 | 5 | import retrofit2.converter.gson.GsonConverterFactory |
5 | 6 | |
6 | 7 | object ProductosService { |
7 | - private val BASE_URL ="http://10.0.2.2:3000/" | |
8 | - //"http://192.168.0.2:3000/" | |
8 | +// private val BASE_URL ="http://10.0.2.2:3000/" | |
9 | +// // //"http://192.168.0.2:3000/" | |
9 | 10 | |
10 | 11 | |
11 | 12 | fun getProductosService(): ProductosApi { |
app/src/main/java/com/focasoftware/deboinventariov20/ui/actualizacionMaestros/ActuaMaestrosFragment.kt
... | ... | @@ -10,10 +10,12 @@ import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
10 | 10 | import com.focasoftware.deboinventariov20.Model.Articles |
11 | 11 | import com.focasoftware.deboinventariov20.Model.Productos |
12 | 12 | import com.focasoftware.deboinventariov20.Model.ProductosService |
13 | +import com.focasoftware.deboinventariov20.Model.ServeInv | |
13 | 14 | import com.focasoftware.deboinventariov20.R |
14 | 15 | import kotlinx.android.synthetic.main.fragment_actua_maestros.* |
15 | 16 | import kotlinx.coroutines.* |
16 | 17 | |
18 | +var BASE_URL ="" | |
17 | 19 | class ActuaMaestrosFragment : Fragment() { |
18 | 20 | |
19 | 21 | var job: Job? = null |
... | ... | @@ -21,11 +23,23 @@ class ActuaMaestrosFragment : Fragment() { |
21 | 23 | |
22 | 24 | override fun onCreate(savedInstanceState: Bundle?) { |
23 | 25 | super.onCreate(savedInstanceState) |
26 | + GlobalScope.launch(Dispatchers.Main) { | |
27 | + BASE_URL = fetchServerPre().direccion.toString() | |
28 | + } | |
29 | + mostrarArticulos() | |
30 | + } | |
24 | 31 | |
25 | - | |
26 | - //mostrarArticulos() | |
32 | + suspend fun fetchServerPre(): ServeInv { | |
33 | + var busqueda: ServeInv | |
34 | + return GlobalScope.async(Dispatchers.IO) { | |
35 | + busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchServerPreOne("1") | |
36 | + return@async busqueda | |
37 | + }.await() | |
27 | 38 | } |
28 | 39 | |
40 | +// return "http://10.0.2.2:3000/" | |
41 | +// } | |
42 | + | |
29 | 43 | |
30 | 44 | override fun onCreateView( |
31 | 45 | inflater: LayoutInflater, container: ViewGroup?, |
app/src/main/java/com/focasoftware/deboinventariov20/ui/configuracion/ConfiguracionFragment.kt
... | ... | @@ -8,10 +8,13 @@ import android.view.View |
8 | 8 | import android.view.ViewGroup |
9 | 9 | import android.widget.* |
10 | 10 | import androidx.fragment.app.Fragment |
11 | +import androidx.navigation.NavController | |
12 | +import androidx.navigation.Navigation | |
11 | 13 | import androidx.navigation.fragment.findNavController |
12 | 14 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
13 | 15 | import com.focasoftware.deboinventariov20.Model.ServeInv |
14 | 16 | import com.focasoftware.deboinventariov20.R |
17 | +import com.focasoftware.deboinventariov20.ui.servidores.ItemsServidores | |
15 | 18 | import kotlinx.android.synthetic.main.fragment_configuracion.* |
16 | 19 | import kotlinx.coroutines.Dispatchers |
17 | 20 | import kotlinx.coroutines.GlobalScope |
... | ... | @@ -21,15 +24,23 @@ import kotlinx.coroutines.launch |
21 | 24 | class ConfiguracionFragment : Fragment() { |
22 | 25 | |
23 | 26 | lateinit var sharedPreferences: SharedPreferences |
24 | - | |
27 | + private lateinit var navController: NavController | |
28 | + private lateinit var listaServers : MutableMap<Int,String> | |
25 | 29 | override fun onCreate(savedInstanceState: Bundle?) { |
26 | 30 | super.onCreate(savedInstanceState) |
27 | 31 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
28 | 32 | } |
29 | 33 | |
34 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
35 | + super.onViewCreated(view, savedInstanceState) | |
36 | + navController = Navigation.findNavController(view) | |
37 | + } | |
38 | + | |
30 | 39 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
31 | - val v = inflater.inflate(R.layout.fragment_configuracion, container, false) | |
32 | 40 | |
41 | + var index=0 | |
42 | + val listServerDescription = arrayListOf<String>() | |
43 | + val v = inflater.inflate(R.layout.fragment_configuracion, container, false) | |
33 | 44 | val etRuta = v.findViewById<EditText>(R.id.etRuta) |
34 | 45 | val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) |
35 | 46 | val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) |
... | ... | @@ -47,17 +58,16 @@ class ConfiguracionFragment : Fragment() { |
47 | 58 | val spServidor = v.findViewById<Spinner>(R.id.spServidor) |
48 | 59 | val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) |
49 | 60 | |
50 | - if (sharedPreferences.contains("etRuta")) etRuta.setText(sharedPreferences.getString("etRuta", "").toString()) | |
51 | - | |
52 | - if (sharedPreferences.contains("rbProInclu")) { | |
53 | - if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { | |
54 | - rbProInclu.isChecked = false | |
55 | - rbProNoInclu.isChecked = true | |
56 | - } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { | |
57 | - rbProInclu.isChecked = true | |
58 | - rbProNoInclu.isChecked = false | |
59 | - } | |
60 | - } else (sharedPreferences.getString("rbProInclu", "").toString() == "") | |
61 | + if (sharedPreferences.contains("etRuta")) | |
62 | + if (sharedPreferences.contains("rbProInclu")) { | |
63 | + if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { | |
64 | + rbProInclu.isChecked = false | |
65 | + rbProNoInclu.isChecked = true | |
66 | + } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { | |
67 | + rbProInclu.isChecked = true | |
68 | + rbProNoInclu.isChecked = false | |
69 | + } | |
70 | + } else (sharedPreferences.getString("rbProInclu", "").toString() == "") | |
61 | 71 | |
62 | 72 | if (sharedPreferences.contains("rbProNoInclu")) { |
63 | 73 | if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { |
... | ... | @@ -69,7 +79,6 @@ class ConfiguracionFragment : Fragment() { |
69 | 79 | } |
70 | 80 | } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") |
71 | 81 | |
72 | - | |
73 | 82 | if (sharedPreferences.contains("cbHabiLectura")) { |
74 | 83 | if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { |
75 | 84 | cbHabiLectura.isChecked = false |
... | ... | @@ -78,7 +87,6 @@ class ConfiguracionFragment : Fragment() { |
78 | 87 | } |
79 | 88 | } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") |
80 | 89 | |
81 | - | |
82 | 90 | if (sharedPreferences.contains("cbMostrarStock")) { |
83 | 91 | if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { |
84 | 92 | cbMostrarStock.isChecked = false |
... | ... | @@ -87,7 +95,6 @@ class ConfiguracionFragment : Fragment() { |
87 | 95 | } |
88 | 96 | } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") |
89 | 97 | |
90 | - | |
91 | 98 | if (sharedPreferences.contains("rbVentas")) { |
92 | 99 | if (sharedPreferences.getString("rbVentas", "").toString() == "0") { |
93 | 100 | rbVentas.isChecked = false |
... | ... | @@ -127,6 +134,7 @@ class ConfiguracionFragment : Fragment() { |
127 | 134 | rbCodigoOrigen.isChecked = true |
128 | 135 | } |
129 | 136 | } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") |
137 | + | |
130 | 138 | if (sharedPreferences.contains("rbCodigoBarras")) { |
131 | 139 | if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { |
132 | 140 | rbCodigoBarras.isChecked = false |
... | ... | @@ -135,7 +143,6 @@ class ConfiguracionFragment : Fragment() { |
135 | 143 | } |
136 | 144 | } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") |
137 | 145 | |
138 | - | |
139 | 146 | if (sharedPreferences.contains("cbMostrarExistencia")) { |
140 | 147 | if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { |
141 | 148 | cbMostrarExistencia.isChecked = false |
... | ... | @@ -144,7 +151,6 @@ class ConfiguracionFragment : Fragment() { |
144 | 151 | } |
145 | 152 | } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") |
146 | 153 | |
147 | - | |
148 | 154 | if (sharedPreferences.contains("cbMostrarPrecio")) { |
149 | 155 | if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { |
150 | 156 | cbMostrarPrecio.isChecked = false |
... | ... | @@ -156,21 +162,31 @@ class ConfiguracionFragment : Fragment() { |
156 | 162 | btnGuardar.setOnClickListener { |
157 | 163 | guardarPreferencias() |
158 | 164 | Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() |
165 | + navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) | |
159 | 166 | } |
160 | 167 | btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } |
168 | + btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Direcciรณn correcta", Toast.LENGTH_LONG).show() } | |
161 | 169 | |
162 | 170 | GlobalScope.launch(Dispatchers.Main) { |
163 | - val listServerDescription = arrayListOf<String>() | |
171 | + | |
164 | 172 | for (any in getDescServers()) { |
165 | 173 | listServerDescription.add(any.descripcion.toString()) |
174 | + listaServers[index]=(any.direccion.toString()) | |
175 | + index+=index | |
166 | 176 | } |
177 | + | |
167 | 178 | if (spServidor != null) { |
168 | 179 | val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, listServerDescription) |
169 | 180 | spServidor.adapter = adapter |
170 | 181 | } |
171 | 182 | } |
172 | - btnValidarServidor.setOnClickListener { | |
173 | - Toast.makeText(requireContext(), "Direcciรณn correcta", Toast.LENGTH_LONG).show() | |
183 | + if (sharedPreferences.contains("ServerPredeterminado")) { | |
184 | + spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) | |
185 | + | |
186 | + } else (spServidor.setSelection(2)) | |
187 | + | |
188 | + spServidor.setOnItemClickListener { adapterView, view, i, l -> | |
189 | + | |
174 | 190 | } |
175 | 191 | return v |
176 | 192 | } |
... | ... | @@ -199,15 +215,14 @@ class ConfiguracionFragment : Fragment() { |
199 | 215 | if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") |
200 | 216 | if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") |
201 | 217 | if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") |
218 | + editor?.putString("ServerPredeterminado", spServidor.selectedItemId.toString()) | |
202 | 219 | |
203 | 220 | editor?.apply() |
204 | 221 | editor.commit() |
205 | - GlobalScope.launch(Dispatchers.Main) { | |
206 | 222 | |
207 | - | |
208 | - } | |
209 | 223 | } catch (e: Exception) { |
210 | 224 | e.printStackTrace() |
211 | 225 | } |
212 | 226 | } |
227 | + | |
213 | 228 | } |
214 | 229 | \ No newline at end of file |
app/src/main/java/com/focasoftware/deboinventariov20/ui/detalleProducto/DetalleArtFragment.kt
... | ... | @@ -17,10 +17,8 @@ import kotlinx.coroutines.GlobalScope |
17 | 17 | import kotlinx.coroutines.async |
18 | 18 | import kotlinx.coroutines.launch |
19 | 19 | |
20 | - | |
21 | 20 | class DetalleArtFragment : Fragment() { |
22 | 21 | |
23 | - private lateinit var navController: NavController | |
24 | 22 | private var Inventario: Int = 0 |
25 | 23 | private var sector: String? = null |
26 | 24 | private var codigo: String? = null |
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/ServidoresFragment.kt
... | ... | @@ -75,7 +75,6 @@ class ServidoresFragment : Fragment() { |
75 | 75 | } |
76 | 76 | |
77 | 77 | suspend fun buscarEnBD(): List<ServeInv> { |
78 | - //TODO BUSQUEDA POR DESCRIPCION | |
79 | 78 | var busqueda: List<ServeInv> |
80 | 79 | return GlobalScope.async(Dispatchers.IO) { |
81 | 80 | busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() |
app/src/main/res/layout/fragment_configuracion.xml
... | ... | @@ -52,16 +52,16 @@ |
52 | 52 | android:fadeScrollbars="true" |
53 | 53 | android:foregroundTint="@android:color/holo_orange_dark" |
54 | 54 | android:soundEffectsEnabled="true" |
55 | - android:spinnerMode="dialog" | |
56 | - android:splitMotionEvents="false" | |
57 | - android:textAlignment="center" | |
55 | + android:spinnerMode="dropdown" | |
56 | + | |
57 | + android:splitMotionEvents="true" | |
58 | + android:textAlignment="textStart" | |
58 | 59 | android:textSize="@dimen/NormalText" |
59 | 60 | app:layout_constraintBottom_toTopOf="@+id/btnAgregarServidor" |
60 | 61 | app:layout_constraintEnd_toStartOf="@+id/btnValidarServidor" |
61 | 62 | app:layout_constraintHorizontal_chainStyle="packed" |
62 | 63 | app:layout_constraintStart_toStartOf="parent" |
63 | 64 | app:layout_constraintTop_toBottomOf="@+id/tvSeleccioneServidor" |
64 | - android:entries="@array/spinnerServidor" | |
65 | 65 | android:prompt="@string/leyendaSpinner"/> |
66 | 66 | |
67 | 67 | <Button |
app/src/main/res/navigation/mobile_navigation.xml
... | ... | @@ -91,6 +91,9 @@ |
91 | 91 | app:popExitAnim="@anim/slide_out_right" |
92 | 92 | app:enterAnim="@anim/slide_in_right" |
93 | 93 | app:exitAnim="@anim/slide_out_left" /> |
94 | + <action | |
95 | + android:id="@+id/action_configuracionFragment_to_mainFragment2" | |
96 | + app:destination="@id/mainFragment2" /> | |
94 | 97 | </fragment> |
95 | 98 | <fragment |
96 | 99 | android:id="@+id/descripcionFragment" |