Commit 8ed3753b482c8a5882ecec396a6c372329313b04

Authored by Mauricio Sanchez
1 parent ea89488e54
Exists in master

17092020 1900

app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
1 package com.focasoftware.deboinventariov20.DB.DAO 1 package com.focasoftware.deboinventariov20.DB.DAO
2 2
3 import androidx.room.Dao 3 import androidx.room.Dao
4 import androidx.room.Insert 4 import androidx.room.Insert
5 import androidx.room.OnConflictStrategy 5 import androidx.room.OnConflictStrategy
6 import androidx.room.Query 6 import androidx.room.Query
7 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART 7 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART
8 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B 8 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B
9 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H 9 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H
10 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV 10 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV
11 import com.focasoftware.deboinventariov20.Model.Articles 11 import com.focasoftware.deboinventariov20.Model.Articles
12 import com.focasoftware.deboinventariov20.Model.InvBody 12 import com.focasoftware.deboinventariov20.Model.InvBody
13 import com.focasoftware.deboinventariov20.Model.InvHead 13 import com.focasoftware.deboinventariov20.Model.InvHead
14 import com.focasoftware.deboinventariov20.Model.ServeInv 14 import com.focasoftware.deboinventariov20.Model.ServeInv
15 15
16 @Dao 16 @Dao
17 interface ArticulosDAO { 17 interface ArticulosDAO {
18 18
19 // TABLA ARTICULOS 19 // TABLA ARTICULOS
20 @Insert(onConflict = OnConflictStrategy.REPLACE) 20 @Insert(onConflict = OnConflictStrategy.REPLACE)
21 suspend fun insertArticulos(articulos: Articles?) 21 suspend fun insertArticulos(articulos: Articles?)
22 22
23 @Query("SELECT * FROM $TABLA_ART ORDER BY DETART DESC") 23 @Query("SELECT * FROM $TABLA_ART ORDER BY DETART DESC")
24 suspend fun findAllArticulos(): List<Articles> 24 suspend fun findAllArticulos(): List<Articles>
25 25
26 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DETART LIKE '%' || :description || '%' GROUP BY DETART ORDER BY DETART") 26 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DETART LIKE '%' || :description || '%' GROUP BY DETART ORDER BY DETART")
27 suspend fun findArticuloByDesc(description: String?, dep: Boolean): List<Articles> 27 suspend fun findArticuloByDesc(description: String?, dep: Boolean): List<Articles>
28 28
29 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(CODBAR) = :codBarra") 29 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(CODBAR) = :codBarra")
30 suspend fun findArticuloByCodBar(codBarra: String, dep: Boolean): Articles 30 suspend fun findArticuloByCodBar(codBarra: String, dep: Boolean): Articles
31 31
32 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(COO) LIKE :CodOrigen") 32 @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(COO) LIKE :CodOrigen")
33 suspend fun findArticuloByCodOri(CodOrigen: String?, dep: Boolean): List<Articles> 33 suspend fun findArticuloByCodOri(CodOrigen: String?, dep: Boolean): List<Articles>
34 34
35 @Query("DELETE FROM $TABLA_ART") 35 @Query("DELETE FROM $TABLA_ART")
36 suspend fun deleteAllArticulos() 36 suspend fun deleteAllArticulos()
37 37
38 @Query("SELECT * FROM $TABLA_ART WHERE CODSEC=:sector AND CODART=:codigo") 38 @Query("SELECT * FROM $TABLA_ART WHERE CODSEC=:sector AND CODART=:codigo")
39 suspend fun fetchArticuloByCodSec(sector: String?, codigo: String?): Articles? 39 suspend fun fetchArticuloByCodSec(sector: String?, codigo: String?): Articles?
40 } 40 }
41 41
42 @Dao 42 @Dao
43 interface InvHeadDAO { 43 interface InvHeadDAO {
44 @Insert() 44 @Insert()
45 suspend fun insertInvHead(invHead: InvHead?) 45 suspend fun insertInvHead(invHead: InvHead?)
46 46
47 @Query("SELECT INV_NUM FROM $TABLA_INV_H ORDER BY INV_NUM DESC") 47 @Query("SELECT INV_NUM FROM $TABLA_INV_H ORDER BY INV_NUM DESC")
48 suspend fun findLastInv(): Int 48 suspend fun findLastInv(): Int
49 49
50 @Query("DELETE FROM $TABLA_INV_H") 50 @Query("DELETE FROM $TABLA_INV_H")
51 suspend fun deleteAllArticulos() 51 suspend fun deleteAllArticulos()
52 52
53 @Query("DELETE FROM $TABLA_INV_H WHERE INV_NUM=:inven") 53 @Query("DELETE FROM $TABLA_INV_H WHERE INV_NUM=:inven")
54 suspend fun deleteinvHead(inven: Int) 54 suspend fun deleteinvHead(inven: Int)
55 55
56 @Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI") 56 @Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI")
57 suspend fun fetchAllInvHead(): List<InvHead> 57 suspend fun fetchAllInvHead(): List<InvHead>
58 58
59 @Query("SELECT INV_LUG FROM $TABLA_INV_H WHERE INV_NUM=:inven") 59 @Query("SELECT INV_LUG FROM $TABLA_INV_H WHERE INV_NUM=:inven")
60 suspend fun fetchAreaInvH (inven: Int): Boolean 60 suspend fun fetchAreaInvH (inven: Int): Boolean
61 61
62 @Query("SELECT INV_PRODCONT FROM $TABLA_INV_H WHERE INV_NUM=:inven") 62 @Query("SELECT INV_PRODCONT FROM $TABLA_INV_H WHERE INV_NUM=:inven")
63 suspend fun consultaCantidadInvH (inven: Int): Int 63 suspend fun consultaCantidadInvH (inven: Int): Int
64 64
65 @Query("UPDATE $TABLA_INV_H SET INV_PRODCONT=:cant WHERE INV_NUM=:inven") 65 @Query("UPDATE $TABLA_INV_H SET INV_PRODCONT=:cant WHERE INV_NUM=:inven")
66 suspend fun updateInvBody(inven: Int,cant: Int) 66 suspend fun updateInvBody(inven: Int,cant: Int)
67 } 67 }
68 68
69 @Dao 69 @Dao
70 interface InvBodyDAO { 70 interface InvBodyDAO {
71 @Insert() 71 @Insert()
72 suspend fun insertInvBody(invBody: InvBody?) 72 suspend fun insertInvBody(invBody: InvBody?)
73 73
74 @Query("DELETE FROM $TABLA_INV_B") 74 @Query("DELETE FROM $TABLA_INV_B")
75 suspend fun deleteAllInvBody() 75 suspend fun deleteAllInvBody()
76 76
77 @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven") 77 @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven")
78 suspend fun deleteInvBody(inven: Int) 78 suspend fun deleteInvBody(inven: Int)
79 79
80 @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod") 80 @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod")
81 suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) 81 suspend fun UpdateInvBody(cant: Float, sec: String, cod: String)
82 82
83 @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") 83 @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC")
84 suspend fun fetchAllInvBody(inven: Int): List<InvBody> 84 suspend fun fetchAllInvBody(inven: Int): List<InvBody>
85 85
86 @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") 86 @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo")
87 suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody 87 suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody
88 88
89 @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") 89 @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo")
90 suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int 90 suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int
91 } 91 }
92 92
93 @Dao 93 @Dao
94 interface ServeInvDao { 94 interface ServeInvDao {
95 @Insert(onConflict = OnConflictStrategy.REPLACE) 95 @Insert(onConflict = OnConflictStrategy.REPLACE)
96 fun insertServer(servidor: ServeInv) 96 fun insertServer(servidor: ServeInv)
97 97
98 @Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM") 98 @Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM")
99 suspend fun fetchAllServers(): List<ServeInv> 99 suspend fun fetchAllServers(): List<ServeInv>
100 100
101 @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") 101 @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir")
102 suspend fun deleteServer(description: String, dir: String) 102 suspend fun deleteServer(description: String, dir: String)
103 103
104 @Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC") 104 @Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC")
105 suspend fun findLastServer(): Int 105 suspend fun findLastServer(): Int
106 106
107 @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0") 107 @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0")
108 suspend fun UpdateServerPreInZero() 108 suspend fun UpdateServerPreInZero()
109 109
110 @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_NUM = :numero") 110 @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_NUM = :numero")
111 suspend fun UpdateServerPre(numero: Int) 111 suspend fun UpdateServerPre(numero: Int)
112 112
113 @Query("SELECT SER_DIR FROM $TABLA_SERV_INV WHERE SER_PRE= 1") 113 @Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE= 1")
114 suspend fun fetchServerPreOne(): String 114 suspend fun fetchServerPreOne(): ServeInv
115 } 115 }
app/src/main/java/com/focasoftware/deboinventariov20/Model/Tablas.kt
1 package com.focasoftware.deboinventariov20.Model 1 package com.focasoftware.deboinventariov20.Model
2 2
3 import androidx.room.ColumnInfo 3 import androidx.room.ColumnInfo
4 import androidx.room.Entity 4 import androidx.room.Entity
5 import androidx.room.PrimaryKey 5 import androidx.room.PrimaryKey
6 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART 6 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART
7 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B 7 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B
8 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H 8 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H
9 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV 9 import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV
10 import com.google.gson.annotations.SerializedName 10 import com.google.gson.annotations.SerializedName
11 import java.io.Serializable 11 import java.io.Serializable
12 12
13 //data class Productos(@SerializedName("SEC") var sector: String?, 13 //data class Productos(@SerializedName("SEC") var sector: String?,
14 // @SerializedName("COD") var codigo: String?, 14 // @SerializedName("COD") var codigo: String?,
15 // @SerializedName("DESC") var descripcion: String?, 15 // @SerializedName("DESC") var descripcion: String?,
16 // @SerializedName("CB") var codBar: String?, 16 // @SerializedName("CB") var codBar: String?,
17 // @SerializedName("CBC") var codOrigen: String?, 17 // @SerializedName("CBC") var codOrigen: String?,
18 // @SerializedName("PRE_VTA") var precio: String?, 18 // @SerializedName("PRE_VTA") var precio: String?,
19 // @SerializedName("PRE_COS") var costo: String?, 19 // @SerializedName("PRE_COS") var costo: String?,
20 // @SerializedName( "EV") var exiVenta: String?, 20 // @SerializedName( "EV") var exiVenta: String?,
21 // @SerializedName( "ED") var exiDeposito: String?, 21 // @SerializedName( "ED") var exiDeposito: String?,
22 // @SerializedName( "DE") var de: String?, 22 // @SerializedName( "DE") var de: String?,
23 // @SerializedName( "BAL") var balanza: Int?, 23 // @SerializedName( "BAL") var balanza: Int?,
24 // @SerializedName("DEPSN") var depSn: Int?, 24 // @SerializedName("DEPSN") var depSn: Int?,
25 // @SerializedName("FOTO") var imagen: String?) 25 // @SerializedName("FOTO") var imagen: String?)
26 data class Productos(@SerializedName("CODSEC") var sector: String?, 26 data class Productos(@SerializedName("CODSEC") var sector: String?,
27 @SerializedName("CODART") var codigo: String?, 27 @SerializedName("CODART") var codigo: String?,
28 @SerializedName("DETART") var descripcion: String?, 28 @SerializedName("DETART") var descripcion: String?,
29 @SerializedName("CODBAR") var codBar: String?, 29 @SerializedName("CODBAR") var codBar: String?,
30 @SerializedName("COO") var codOrigen: String?, 30 @SerializedName("COO") var codOrigen: String?,
31 @SerializedName("PREVEN") var precio: String?, 31 @SerializedName("PREVEN") var precio: String?,
32 @SerializedName("COSTO") var costo: String?, 32 @SerializedName("COSTO") var costo: String?,
33 @SerializedName( "EXIVTA") var exiVenta: String?, 33 @SerializedName( "EXIVTA") var exiVenta: String?,
34 @SerializedName( "EXIDEP") var exiDeposito: String?, 34 @SerializedName( "EXIDEP") var exiDeposito: String?,
35 @SerializedName( "DVE") var de: String?, 35 @SerializedName( "DVE") var de: String?,
36 @SerializedName( "UNIVEN") var balanza: Int?, 36 @SerializedName( "UNIVEN") var balanza: Int?,
37 @SerializedName("DEPSN") var depSn: Boolean?, 37 @SerializedName("DEPSN") var depSn: Boolean?,
38 @SerializedName("FOTO") var imagen: String?) 38 @SerializedName("FOTO") var imagen: String?)
39 //@Entity(tableName = TABLA_ART) 39 //@Entity(tableName = TABLA_ART)
40 //data class Articles(@ColumnInfo(name = "SEC") var sector: String?, 40 //data class Articles(@ColumnInfo(name = "SEC") var sector: String?,
41 // @ColumnInfo(name = "COD") var codigo: String?, 41 // @ColumnInfo(name = "COD") var codigo: String?,
42 // @ColumnInfo(name = "DES") var descripcion: String?, 42 // @ColumnInfo(name = "DES") var descripcion: String?,
43 // @ColumnInfo(name = "CB") var codBar: String?, 43 // @ColumnInfo(name = "CB") var codBar: String?,
44 // @ColumnInfo(name = "CBC") var codOrigen: String?, 44 // @ColumnInfo(name = "CBC") var codOrigen: String?,
45 // @ColumnInfo(name = "PRE_VTA") var precio: String?, 45 // @ColumnInfo(name = "PRE_VTA") var precio: String?,
46 // @ColumnInfo(name = "PRE_COS") var costo: String?, 46 // @ColumnInfo(name = "PRE_COS") var costo: String?,
47 // @ColumnInfo(name = "EV") var exiVenta: String?, 47 // @ColumnInfo(name = "EV") var exiVenta: String?,
48 // @ColumnInfo(name = "ED") var exiDeposito: String?, 48 // @ColumnInfo(name = "ED") var exiDeposito: String?,
49 // @ColumnInfo(name = "DE") var de: String?, 49 // @ColumnInfo(name = "DE") var de: String?,
50 // @ColumnInfo(name = "BAL") var balanza: Int?, 50 // @ColumnInfo(name = "BAL") var balanza: Int?,
51 // @ColumnInfo(name = "DEPSN") var depSn: Int?, 51 // @ColumnInfo(name = "DEPSN") var depSn: Int?,
52 // @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable { 52 // @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable {
53 // @PrimaryKey(autoGenerate = true) 53 // @PrimaryKey(autoGenerate = true)
54 // @ColumnInfo(name = "id") 54 // @ColumnInfo(name = "id")
55 // var id: Long = 0 55 // var id: Long = 0
56 //} 56 //}
57 @Entity(tableName = TABLA_ART) 57 @Entity(tableName = TABLA_ART)
58 data class Articles(@ColumnInfo(name = "CODSEC") var sector: String?, 58 data class Articles(@ColumnInfo(name = "CODSEC") var sector: String?,
59 @ColumnInfo(name = "CODART") var codigo: String?, 59 @ColumnInfo(name = "CODART") var codigo: String?,
60 @ColumnInfo(name = "DETART") var descripcion: String?, 60 @ColumnInfo(name = "DETART") var descripcion: String?,
61 @ColumnInfo(name = "CODBAR") var codBar: String?, 61 @ColumnInfo(name = "CODBAR") var codBar: String?,
62 @ColumnInfo(name = "COO") var codOrigen: String?, 62 @ColumnInfo(name = "COO") var codOrigen: String?,
63 @ColumnInfo(name = "PREVEN") var precio: String?, 63 @ColumnInfo(name = "PREVEN") var precio: String?,
64 @ColumnInfo(name = "COSTO") var costo: String?, 64 @ColumnInfo(name = "COSTO") var costo: String?,
65 @ColumnInfo(name = "EXIVTA") var exiVenta: String?, 65 @ColumnInfo(name = "EXIVTA") var exiVenta: String?,
66 @ColumnInfo(name = "EXIDEP") var exiDeposito: String?, 66 @ColumnInfo(name = "EXIDEP") var exiDeposito: String?,
67 @ColumnInfo(name = "DVE") var de: String?, 67 @ColumnInfo(name = "DVE") var de: String?,
68 @ColumnInfo(name = "UNIVEN") var balanza: Int?, 68 @ColumnInfo(name = "UNIVEN") var balanza: Int?,
69 @ColumnInfo(name = "DEPSN") var depSn: Boolean?, 69 @ColumnInfo(name = "DEPSN") var depSn: Boolean?,
70 @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable { 70 @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable {
71 @PrimaryKey(autoGenerate = true) 71 @PrimaryKey(autoGenerate = true)
72 @ColumnInfo(name = "id") 72 @ColumnInfo(name = "id")
73 var id: Long = 0 73 var id: Long = 0
74 } 74 }
75 75
76 @Entity(tableName = TABLA_INV_H) 76 @Entity(tableName = TABLA_INV_H)
77 data class InvHead(@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "INV_NUM") var invNum: Int, 77 data class InvHead(@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "INV_NUM") var invNum: Int,
78 @ColumnInfo(name = "INV_DESC") var descripcion: String?, 78 @ColumnInfo(name = "INV_DESC") var descripcion: String?,
79 @ColumnInfo(name = "ESTADO") var estado: Int?, 79 @ColumnInfo(name = "ESTADO") var estado: Int?,
80 @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, 80 @ColumnInfo(name = "INV_FEI") var fechaInicio: String?,
81 @ColumnInfo(name = "INV_FEF") var fechaFinal: String?, 81 @ColumnInfo(name = "INV_FEF") var fechaFinal: String?,
82 // productos contados en el inventario 82 // productos contados en el inventario
83 @ColumnInfo(name = "INV_PRODCONT") var prodContados: Long?, 83 @ColumnInfo(name = "INV_PRODCONT") var prodContados: Long?,
84 @ColumnInfo(name = "INV_LUG") var lugar: Boolean?, 84 @ColumnInfo(name = "INV_LUG") var lugar: Boolean?,
85 // Solo se ajustan los productos incluidos en el conteo=0 85 // Solo se ajustan los productos incluidos en el conteo=0
86 // Ajusta productos no incluidos en el conteo con stock en cero=1 86 // Ajusta productos no incluidos en el conteo con stock en cero=1
87 @ColumnInfo(name = "PRO_NO_CONTA") var stDesc: Int?, 87 @ColumnInfo(name = "PRO_NO_CONTA") var stDesc: Int?,
88 // Mostror stock en el sistema al momento de la descarga del maestro. 88 // Mostror stock en el sistema al momento de la descarga del maestro.
89 @ColumnInfo(name = "MOSTRAR_STOCK") var proNoCont: Int?) 89 @ColumnInfo(name = "MOSTRAR_STOCK") var proNoCont: Int?)
90 90
91 91
92 @Entity(tableName = TABLA_INV_B) 92 @Entity(tableName = TABLA_INV_B)
93 data class InvBody(@ColumnInfo(name = "INV_NUM") var invNum: Int, 93 data class InvBody(@ColumnInfo(name = "INV_NUM") var invNum: Int,
94 @ColumnInfo(name = "SEC") var sector: String?, 94 @ColumnInfo(name = "SEC") var sector: String?,
95 @ColumnInfo(name = "COD") var codigo: String?, 95 @ColumnInfo(name = "COD") var codigo: String?,
96 @ColumnInfo(name = "DES") var descripcion: String?, 96 @ColumnInfo(name = "DES") var descripcion: String?,
97 @ColumnInfo(name = "CANT") var cantTomada: String?, 97 @ColumnInfo(name = "CANT") var cantTomada: String?,
98 @ColumnInfo(name = "CB") var codBar: String?, 98 @ColumnInfo(name = "CB") var codBar: String?,
99 @ColumnInfo(name = "CBC") var codOrigen: String?, 99 @ColumnInfo(name = "CBC") var codOrigen: String?,
100 @ColumnInfo(name = "PRE_VTA") var precio: String?, 100 @ColumnInfo(name = "PRE_VTA") var precio: String?,
101 @ColumnInfo(name = "PRE_COS") var costo: String?, 101 @ColumnInfo(name = "PRE_COS") var costo: String?,
102 @ColumnInfo(name = "BAL") var balanza: Int?, 102 @ColumnInfo(name = "BAL") var balanza: Int?,
103 @ColumnInfo(name = "DSN") var depSn: Boolean?, 103 @ColumnInfo(name = "DSN") var depSn: Boolean?,
104 @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, 104 @ColumnInfo(name = "INV_FEI") var fechaInicio: String?,
105 @ColumnInfo(name = "INV_FEF") var fechaFinal: String?) : Serializable { 105 @ColumnInfo(name = "INV_FEF") var fechaFinal: String?) : Serializable {
106 @PrimaryKey(autoGenerate = true) 106 @PrimaryKey(autoGenerate = true)
107 @ColumnInfo(name = "id") 107 @ColumnInfo(name = "id")
108 var id: Long = 0 108 var id: Long = 0
109 } 109 }
110 110
111 @Entity(tableName = TABLA_SERV_INV) 111 @Entity(tableName = TABLA_SERV_INV)
112 data class ServeInv( 112 data class ServeInv(
113 @ColumnInfo(name = "SER_DESC") var descripcion: String?, 113 @ColumnInfo(name = "SER_DESC") var descripcion: String?,
114 @ColumnInfo(name = "SER_DIR") var direccion: String?, 114 @ColumnInfo(name = "SER_DIR") var direccion: String?,
115 @ColumnInfo(name = "SER_PUERTO") var puerto: String?,
115 @ColumnInfo(name = "SER_PRE") var predeterminado: Int?): 116 @ColumnInfo(name = "SER_PRE") var predeterminado: Int?):
116 Serializable { @PrimaryKey(autoGenerate = true) 117 Serializable { @PrimaryKey(autoGenerate = true)
117 @ColumnInfo(name = "SER_NUM") 118 @ColumnInfo(name = "SER_NUM")
118 var servNum: Int=0 119 var servNum: Int=0
119 } 120 }
120 121
121 122
122 123
app/src/main/java/com/focasoftware/deboinventariov20/UI/Utils/Utils.kt
1 package com.focasoftware.deboinventariov20.UI.Utils 1 package com.focasoftware.deboinventariov20.UI.Utils
2 2
3 import android.app.AlertDialog 3 import android.app.AlertDialog
4 import android.app.Dialog 4 import android.app.Dialog
5 import android.content.Context 5 import android.content.Context
6 import android.os.Bundle 6 import android.os.Bundle
7 import androidx.fragment.app.DialogFragment 7 import androidx.fragment.app.DialogFragment
8 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb 8 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb
9 import kotlinx.coroutines.Dispatchers 9 import kotlinx.coroutines.Dispatchers
10 import kotlinx.coroutines.GlobalScope 10 import kotlinx.coroutines.GlobalScope
11 import kotlinx.coroutines.async 11 import kotlinx.coroutines.async
12 import java.io.IOException
13 import java.net.UnknownHostException
12 14
13 fun modificarCantidadEnCabecera(inventarioActual: Int, b: Boolean,context: Context) { 15 fun modificarCantidadEnCabecera(inventarioActual: Int, b: Boolean,context: Context) {
14 GlobalScope.async(Dispatchers.IO) { 16 GlobalScope.async(Dispatchers.IO) {
15 var cantProductos = 0 17 var cantProductos = 0
16 cantProductos = AppDb.getAppDb(context)!!.InvHeadDAO()!!.consultaCantidadInvH(inventarioActual) 18 cantProductos = AppDb.getAppDb(context)!!.InvHeadDAO()!!.consultaCantidadInvH(inventarioActual)
17 if (b) { 19 if (b) {
18 AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos + 1) 20 AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos + 1)
19 } else { 21 } else {
20 AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos - 1) 22 AppDb.getAppDb(context)!!.InvHeadDAO()!!.updateInvBody(inventarioActual, cantProductos - 1)
21 } 23 }
22 } 24 }
23 } 25 }
24 26
25 open class AlertDialogBorrarInv : DialogFragment() { 27 open class AlertDialogBorrarInv : DialogFragment() {
26 28
27 interface OnBorrarInvClickListener { 29 interface OnBorrarInvClickListener {
28 fun onPositiveClick() 30 fun onPositiveClick()
29 fun onCancelClick() 31 fun onCancelClick()
30 } 32 }
31 33
32 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 34 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
33 return activity?.let { 35 return activity?.let {
34 val title = "Borrar Inventario" 36 val title = "Borrar Inventario"
35 val content = "¿Seguro que desea Borrar el inventario?" 37 val content = "¿Seguro que desea Borrar el inventario?"
36 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) 38 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity())
37 builder.setTitle(title).setMessage(content) 39 builder.setTitle(title).setMessage(content)
38 .setPositiveButton(android.R.string.ok) { _, _ -> 40 .setPositiveButton(android.R.string.ok) { _, _ ->
39 val listener = activity as OnBorrarInvClickListener? 41 val listener = activity as OnBorrarInvClickListener?
40 listener!!.onPositiveClick() 42 listener!!.onPositiveClick()
41 } 43 }
42 .setNegativeButton(android.R.string.cancel) { _, _ -> 44 .setNegativeButton(android.R.string.cancel) { _, _ ->
43 val listener = activity as OnBorrarInvClickListener? 45 val listener = activity as OnBorrarInvClickListener?
44 listener!!.onCancelClick() 46 listener!!.onCancelClick()
45 } 47 }
46 return builder.create() 48 return builder.create()
47 } ?: throw IllegalStateException("Activity cannot be null") 49 } ?: throw IllegalStateException("Activity cannot be null")
48 } 50 }
49 public fun Int.twoDigits() = 51 public fun Int.twoDigits() =
50 if (this <= 9) "0$this" else this.toString()} 52 if (this <= 9) "0$this" else this.toString()}
51 53
52 public class NoEncontradoSimple : DialogFragment() { 54 public class NoEncontradoSimple : DialogFragment() {
53 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 55 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
54 return activity?.let { 56 return activity?.let {
55 val title = "" 57 val title = ""
56 val content = "¡El producto buscado NO fue encontrado!" 58 val content = "¡El producto buscado NO fue encontrado!"
57 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) 59 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity())
58 builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ -> 60 builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ ->
59 //Todo OK click 61 //Todo OK click
60 } 62 }
61 63
62 return builder.create() 64 return builder.create()
63 } ?: throw IllegalStateException("Activity cannot be null") 65 } ?: throw IllegalStateException("Activity cannot be null")
64 } 66 }
65 } 67 }
66 public class noServerConf : DialogFragment() { 68 public class noServerConf : DialogFragment() {
67 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 69 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
68 return activity?.let { 70 return activity?.let {
69 val title = "" 71 val title = ""
70 val content = "¡Antes de importar debe configurar un servidor!" 72 val content = "¡Antes de importar debe configurar un servidor!"
71 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) 73 val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity())
72 builder.setTitle(title).setMessage(content) 74 builder.setTitle(title).setMessage(content)
73 .setPositiveButton(android.R.string.ok) { _, _ -> 75 .setPositiveButton(android.R.string.ok) { _, _ ->
74 activity?.onBackPressed(); 76 activity?.onBackPressed();
75 } 77 }
76 78
77 return builder.create() 79 return builder.create()
78 } ?: throw IllegalStateException("Activity cannot be null") 80 } ?: throw IllegalStateException("Activity cannot be null")
79 } 81 }
80 }
82 }
83 fun isConnectedToThisServer(host: String): Boolean {
84
85 val runtime = Runtime.getRuntime()
86 try {
87 val ipProcess = runtime.exec("/system/bin/ping -c 1 $host")
88 val exitValue = ipProcess.waitFor()
89 ipProcess.destroy()
90 return exitValue == 0
91 } catch (e: UnknownHostException) {
92 e.printStackTrace()
93 } catch (e: IOException) {
94 e.printStackTrace()
95 } catch (e: InterruptedException) {
96 e.printStackTrace()
97 }
98
99 return false
100 }
app/src/main/java/com/focasoftware/deboinventariov20/UI/actualizacionMaestros/ActuaMaestrosFragment.kt
1 package com.focasoftware.deboinventariov20.UI.actualizacionMaestros 1 package com.focasoftware.deboinventariov20.UI.actualizacionMaestros
2 2
3 import android.os.Bundle 3 import android.os.Bundle
4 import android.view.LayoutInflater 4 import android.view.LayoutInflater
5 import android.view.View 5 import android.view.View
6 import android.view.ViewGroup 6 import android.view.ViewGroup
7 import android.widget.Button 7 import android.widget.Button
8 import androidx.fragment.app.Fragment 8 import androidx.fragment.app.Fragment
9 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb 9 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb
10 import com.focasoftware.deboinventariov20.Model.Articles 10 import com.focasoftware.deboinventariov20.Model.Articles
11 import com.focasoftware.deboinventariov20.Model.ProductosService 11 import com.focasoftware.deboinventariov20.Model.ProductosService
12 import com.focasoftware.deboinventariov20.Model.ServeInv
12 import com.focasoftware.deboinventariov20.R 13 import com.focasoftware.deboinventariov20.R
13 import com.focasoftware.deboinventariov20.UI.Utils.noServerConf 14 import com.focasoftware.deboinventariov20.UI.Utils.noServerConf
14 import kotlinx.android.synthetic.main.fragment_actua_maestros.* 15 import kotlinx.android.synthetic.main.fragment_actua_maestros.*
15 import kotlinx.coroutines.* 16 import kotlinx.coroutines.*
16 import kotlinx.coroutines.Dispatchers.IO 17 import kotlinx.coroutines.Dispatchers.IO
17 import kotlinx.coroutines.Dispatchers.Main 18 import kotlinx.coroutines.Dispatchers.Main
18 import java.util.ArrayList 19 import java.util.ArrayList
19 20
20 var BASE_URL = "" 21 var BASE_URL = ""
21 22
22 class ActuaMaestrosFragment : Fragment() { 23 class ActuaMaestrosFragment : Fragment() {
23 24
24 override fun onCreate(savedInstanceState: Bundle?) { 25 override fun onCreate(savedInstanceState: Bundle?) {
25 super.onCreate(savedInstanceState) 26 super.onCreate(savedInstanceState)
26 GlobalScope.launch(Main) { 27 GlobalScope.launch(Main) {
27 val serverPre = fetchServerPreOne() 28 val serverPre = fetchServerPreOne()
28 if (serverPre.isNullOrEmpty()) { 29 if (serverPre!!.direccion.isNullOrEmpty()) {
29 val modalDialog = noServerConf() 30 val modalDialog = noServerConf()
30 modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") 31 modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog")
31 } else { 32 } else {
32 BASE_URL = serverPre.toString() 33 BASE_URL = serverPre.direccion.toString()+":"+serverPre.puerto.toString()+"/"
33 } 34 }
34 } 35 }
35 // mostrarArticulos() 36 // mostrarArticulos()
36 } 37 }
37 38
38 private suspend fun fetchServerPreOne(): String? { 39 private suspend fun fetchServerPreOne(): ServeInv? {
39 return GlobalScope.async(IO) { 40 return GlobalScope.async(IO) {
40 return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne() 41 return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne()
41 }.await() 42 }.await()
42 } 43 }
43 44
44 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 45 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
45 // Inflate the layout for this fragment 46 // Inflate the layout for this fragment
46 val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false) 47 val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false)
47 val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) 48 val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct)
48 bConfirmarAct.setOnClickListener { 49 bConfirmarAct.setOnClickListener {
49 loading_view.visibility = View.VISIBLE 50 loading_view.visibility = View.VISIBLE
50 countriesList.text = "Obteniendo artículos del servidor $BASE_URL, aguarde por favor." 51 countriesList.text = "Obteniendo artículos del servidor $BASE_URL, aguarde por favor."
51 GlobalScope.launch(Main) { 52 GlobalScope.launch(Main) {
52 obtenerArticulos() 53 obtenerArticulos()
53 } 54 }
54 } 55 }
55 return v 56 return v
56 } 57 }
57 58
58 private suspend fun obtenerArticulos() { 59 private suspend fun obtenerArticulos() {
59 60
60 val productosService = ProductosService.getProductosService() 61 val productosService = ProductosService.getProductosService()
61 var index: Long = 1 62 var index: Long = 1
62 withContext(IO) { 63 withContext(IO) {
63 val job = CoroutineScope(IO).launch { 64 val job = CoroutineScope(IO).launch {
64 // TODO: BORRO TODO LOS ARTICULOS DE LA BASE PARA CARGARLOS DE NUEVO 65 // TODO: BORRO TODO LOS ARTICULOS DE LA BASE PARA CARGARLOS DE NUEVO
65 AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.deleteAllArticulos() 66 AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.deleteAllArticulos()
66 67
67 val response = productosService.getProductos() 68 val response = productosService.getProductos()
68 if (response.isSuccessful) { 69 if (response.isSuccessful) {
69 70
70 for (pro in response.body()!!) { 71 for (pro in response.body()!!) {
71 val artiAcargar = Articles(pro.sector, 72 val artiAcargar = Articles(pro.sector,
72 pro.codigo, 73 pro.codigo,
73 pro.descripcion, 74 pro.descripcion,
74 pro.codBar, 75 pro.codBar,
75 pro.codOrigen, 76 pro.codOrigen,
76 pro.precio, 77 pro.precio,
77 pro.costo, 78 pro.costo,
78 pro.exiVenta, 79 pro.exiVenta,
79 pro.exiDeposito, 80 pro.exiDeposito,
80 pro.de, 81 pro.de,
81 pro.balanza, 82 pro.balanza,
82 pro.depSn, 83 pro.depSn,
83 pro.imagen) 84 pro.imagen)
84 index += index 85 index += index
85 AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.insertArticulos(artiAcargar) 86 AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!.insertArticulos(artiAcargar)
86 } 87 }
87 withContext(Main) { 88 withContext(Main) {
88 countriesList.visibility = View.VISIBLE 89 countriesList.visibility = View.VISIBLE
89 countriesList.text = "¡Datos Importados Correctamente!" 90 countriesList.text = "¡Datos Importados Correctamente!"
90 loading_view.visibility = View.GONE 91 loading_view.visibility = View.GONE
91 } 92 }
92 }else{ 93 }else{
93 withContext(Main) { 94 withContext(Main) {
94 countriesList.visibility = View.VISIBLE 95 countriesList.visibility = View.VISIBLE
95 countriesList.text = "¡Error!" 96 countriesList.text = "¡Error!"
96 loading_view.visibility = View.GONE 97 loading_view.visibility = View.GONE
97 } 98 }
98 } 99 }
99 } 100 }
100 if (job == null) { 101 if (job == null) {
101 withContext(Main) { 102 withContext(Main) {
102 countriesList.visibility = View.VISIBLE 103 countriesList.visibility = View.VISIBLE
103 countriesList.text = "No se puedo realizar la conexión al Servidor" 104 countriesList.text = "No se puedo realizar la conexión al Servidor"
104 loading_view.visibility = View.GONE 105 loading_view.visibility = View.GONE
105 } 106 }
106 } 107 }
107 } 108 }
108 109
109 110
110 // withContext(Dispatchers.Main) { 111 // withContext(Dispatchers.Main) {
111 // if (response.isSuccessful) { 112 // if (response.isSuccessful) {
112 // val call = WebService 113 // val call = WebService
113 // .instance 114 // .instance
114 // ?.createService(WebServiceApi::class.java) 115 // ?.createService(WebServiceApi::class.java)
115 // ?.articulos 116 // ?.articulos
116 // call?.enqueue(object : Callback<List<productos?>?> { 117 // call?.enqueue(object : Callback<List<productos?>?> {
117 // override fun onResponse( 118 // override fun onResponse(
118 // call: Call<List<productos?>?>, 119 // call: Call<List<productos?>?>,
119 // response: Response<List<productos?>?> 120 // response: Response<List<productos?>?>
120 // ) { 121 // ) {
121 // if (response.code() == 200) { 122 // if (response.code() == 200) {
122 // for (i in response.body()!!.indices) { 123 // for (i in response.body()!!.indices) {
123 // //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i]) 124 // //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i])
124 // cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "") 125 // cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "")
125 //// Log.d( 126 //// Log.d(
126 //// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector 127 //// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector
127 //// + "Codigo Profesor: " + response.body()!![i]?.descripcion 128 //// + "Codigo Profesor: " + response.body()!![i]?.descripcion
128 //// ) 129 //// )
129 // mostrarArticulos() 130 // mostrarArticulos()
130 // } 131 // }
131 // } else if (response.code() == 404) { 132 // } else if (response.code() == 404) {
132 // Log.d("TAG1", "No hay cursos") 133 // Log.d("TAG1", "No hay cursos")
133 // } 134 // }
134 // 135 //
135 // } 136 // }
136 // 137 //
137 // override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {} 138 // override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {}
138 // }) 139 // })
139 } 140 }
140 141
141 fun mostrarArticulos() { 142 fun mostrarArticulos() {
142 val Job = GlobalScope.launch { 143 val Job = GlobalScope.launch {
143 var listArticulos: List<Articles>? = null 144 var listArticulos: List<Articles>? = null
144 var temp: String = "" 145 var temp: String = ""
145 listArticulos = AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos() 146 listArticulos = AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos()
146 if (listArticulos != null) { 147 if (listArticulos != null) {
147 148
148 for (i in listArticulos.indices) temp += listArticulos[i].codigo.toString() 149 for (i in listArticulos.indices) temp += listArticulos[i].codigo.toString()
149 } 150 }
150 withContext(Dispatchers.Main) { 151 withContext(Dispatchers.Main) {
151 countriesList.visibility = View.VISIBLE 152 countriesList.visibility = View.VISIBLE
152 loading_view.visibility = View.GONE 153 loading_view.visibility = View.GONE
153 countriesList?.text = temp 154 countriesList?.text = temp
154 } 155 }
155 } 156 }
156 // for (professor in listArticulos!!) { 157 // for (professor in listArticulos!!) {
157 // editT.text= professor.id.toString() 158 // editT.text= professor.id.toString()
158 // } 159 // }
159 } 160 }
160 161
161 162
162 // fun observeViewModel() { 163 // fun observeViewModel() {
163 // 164 //
164 // val productosService = ProductosService.getProductosService() 165 // val productosService = ProductosService.getProductosService()
165 // var job: Job? = null 166 // var job: Job? = null
166 // 167 //
167 // 168 //
168 // //countriesList.text="Procesando..." 169 // //countriesList.text="Procesando..."
169 // //countriesList.visibility = View.VISIBLE 170 // //countriesList.visibility = View.VISIBLE
170 // // GlobalScope1.launch(Dispatchers.IO) { 171 // // GlobalScope1.launch(Dispatchers.IO) {
171 // val response = productosService.getProductos() 172 // val response = productosService.getProductos()
172 // if (response.isSuccessful) { 173 // if (response.isSuccessful) {
173 //// countriesList.layoutManager = LinearLayoutManager(context) 174 //// countriesList.layoutManager = LinearLayoutManager(context)
174 //// countriesList.itemAnimator = DefaultItemAnimator() 175 //// countriesList.itemAnimator = DefaultItemAnimator()
175 // 176 //
176 //// ProductAdapter.updateCountries(it) 177 //// ProductAdapter.updateCountries(it)
177 // // cargarArticulos(response.body()) 178 // // cargarArticulos(response.body())
178 // 179 //
179 // 180 //
180 // val artiAcargar: Articulos? = null 181 // val artiAcargar: Articulos? = null
181 // var index: Long = 1 182 // var index: Long = 1
182 // 183 //
183 // for (pro in response.body()!!) { 184 // for (pro in response.body()!!) {
184 // //artiAcargar.id =index+1 185 // //artiAcargar.id =index+1
185 // artiAcargar!!.sector = pro.sector 186 // artiAcargar!!.sector = pro.sector
186 // artiAcargar.codigo = pro.codigo 187 // artiAcargar.codigo = pro.codigo
187 // artiAcargar.descripcion = pro.descripcion 188 // artiAcargar.descripcion = pro.descripcion
188 // artiAcargar.codBar = pro.codBar 189 // artiAcargar.codBar = pro.codBar
189 // artiAcargar.precio = pro.precio 190 // artiAcargar.precio = pro.precio
190 // artiAcargar.costo = pro.costo 191 // artiAcargar.costo = pro.costo
191 // artiAcargar.balanza = pro.balanza 192 // artiAcargar.balanza = pro.balanza
192 // artiAcargar.depSn = pro.depSn 193 // artiAcargar.depSn = pro.depSn
193 // artiAcargar.imagen = pro.imagen 194 // artiAcargar.imagen = pro.imagen
194 // index += index 195 // index += index
195 // 196 //
196 // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! 197 // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!
197 // .insertArticulos(artiAcargar) 198 // .insertArticulos(artiAcargar)
198 // } 199 // }
199 // } 200 // }
200 // // } 201 // // }
201 // 202 //
202 // //job.cancel() 203 // //job.cancel()
203 // 204 //
204 // 205 //
205 // } 206 // }
206 207
207 // fun cargarArticulos(Productos: List<Productos>?) { 208 // fun cargarArticulos(Productos: List<Productos>?) {
208 // val artiAcargar: Articulos? = null 209 // val artiAcargar: Articulos? = null
209 // var index: Long = 1 210 // var index: Long = 1
210 // //val job4 = CoroutineScope(Dispatchers.Default).launch { 211 // //val job4 = CoroutineScope(Dispatchers.Default).launch {
211 // for (pro in Productos!!) { 212 // for (pro in Productos!!) {
212 // //artiAcargar.id =index+1 213 // //artiAcargar.id =index+1
213 // artiAcargar!!.sector = pro.sector 214 // artiAcargar!!.sector = pro.sector
214 // artiAcargar.codigo = pro.codigo 215 // artiAcargar.codigo = pro.codigo
215 // artiAcargar.descripcion = pro.descripcion 216 // artiAcargar.descripcion = pro.descripcion
216 // artiAcargar.codBar = pro.codBar 217 // artiAcargar.codBar = pro.codBar
217 // artiAcargar.precio = pro.precio 218 // artiAcargar.precio = pro.precio
218 // artiAcargar.costo = pro.costo 219 // artiAcargar.costo = pro.costo
219 // artiAcargar.balanza = pro.balanza 220 // artiAcargar.balanza = pro.balanza
220 // artiAcargar.depSn = pro.depSn 221 // artiAcargar.depSn = pro.depSn
221 // artiAcargar.imagen = pro.imagen 222 // artiAcargar.imagen = pro.imagen
222 // index += index 223 // index += index
223 // 224 //
224 // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! 225 // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!!
225 // .insertArticulos(artiAcargar) 226 // .insertArticulos(artiAcargar)
226 // } 227 // }
227 // } 228 // }
228 } 229 }
229 230
230 231
app/src/main/java/com/focasoftware/deboinventariov20/UI/configuracion/ConfiguracionFragment.kt
1 package com.focasoftware.deboinventariov20.UI.configuracion 1 package com.focasoftware.deboinventariov20.UI.configuracion
2 2
3 import android.content.Context 3 import android.content.Context
4 import android.content.SharedPreferences 4 import android.content.SharedPreferences
5 import android.os.Bundle 5 import android.os.Bundle
6 import android.view.LayoutInflater 6 import android.view.LayoutInflater
7 import android.view.View 7 import android.view.View
8 import android.view.ViewGroup 8 import android.view.ViewGroup
9 import android.widget.* 9 import android.widget.*
10 import androidx.fragment.app.Fragment 10 import androidx.fragment.app.Fragment
11 import androidx.fragment.app.FragmentActivity 11 import androidx.fragment.app.FragmentActivity
12 import androidx.lifecycle.lifecycleScope 12 import androidx.lifecycle.lifecycleScope
13 import androidx.navigation.NavController 13 import androidx.navigation.NavController
14 import androidx.navigation.Navigation 14 import androidx.navigation.Navigation
15 import androidx.navigation.fragment.findNavController 15 import androidx.navigation.fragment.findNavController
16 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb 16 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb
17 import com.focasoftware.deboinventariov20.Model.ServeInv 17 import com.focasoftware.deboinventariov20.Model.ServeInv
18 import com.focasoftware.deboinventariov20.R 18 import com.focasoftware.deboinventariov20.R
19 import com.focasoftware.deboinventariov20.UI.Utils.isConnectedToThisServer
19 import kotlinx.android.synthetic.main.fragment_configuracion.* 20 import kotlinx.android.synthetic.main.fragment_configuracion.*
20 import kotlinx.coroutines.* 21 import kotlinx.coroutines.*
21 import kotlinx.coroutines.Dispatchers.Main 22 import kotlinx.coroutines.Dispatchers.Main
22 23
23 class ConfiguracionFragment : Fragment() { 24 class ConfiguracionFragment : Fragment() {
24 25
25 lateinit var sharedPreferences: SharedPreferences 26 lateinit var sharedPreferences: SharedPreferences
26 private lateinit var navController: NavController 27 private lateinit var navController: NavController
27 var itemSelect: Int = 0 28 var itemSelect: Int = 0
28 var indexSelect: Int = 0 29 var indexSelect: Int = 0
29 30
30 override fun onCreate(savedInstanceState: Bundle?) { 31 override fun onCreate(savedInstanceState: Bundle?) {
31 super.onCreate(savedInstanceState) 32 super.onCreate(savedInstanceState)
32 sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) 33 sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE)
33 } 34 }
34 35
35 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 36 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
36 super.onViewCreated(view, savedInstanceState) 37 super.onViewCreated(view, savedInstanceState)
37 navController = Navigation.findNavController(view) 38 navController = Navigation.findNavController(view)
38 GlobalScope.launch(Main) { 39 GlobalScope.launch(Main) {
39 val listServer = mutableListOf<String>() 40 val listServer = mutableListOf<String>()
40 for (server in getDescServers()) { 41 for (server in getDescServers()) {
41 listServer.add((if (server.servNum < 9) "0" + server.servNum.toString() else server.servNum.toString()) + " - " + server.descripcion.toString()) 42 listServer.add((if (server.servNum < 9) "0" + server.servNum.toString() else server.servNum.toString()) + " - " + server.descripcion.toString())
42 } 43 }
43 val adapterSpServer = ArrayAdapter(requireContext(), R.layout.support_simple_spinner_dropdown_item, listServer) 44 val adapterSpServer = ArrayAdapter(
45 requireContext(),
46 R.layout.support_simple_spinner_dropdown_item,
47 listServer
48 )
44 spServidor.adapter = adapterSpServer 49 spServidor.adapter = adapterSpServer
45 if (sharedPreferences.contains("ServerPredeterminado")) { 50 if (sharedPreferences.contains("ServerPredeterminado")) {
46 spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) 51 spServidor.setSelection(
52 sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()
53 )
47 } else (spServidor.setSelection(0)) 54 } else (spServidor.setSelection(0))
48 } 55 }
49 } 56 }
50 57
51 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 58 override fun onCreateView(
59 inflater: LayoutInflater,
60 container: ViewGroup?,
61 savedInstanceState: Bundle?
62 ): View? {
52 63
53 val v = inflater.inflate(R.layout.fragment_configuracion, container, false) 64 val v = inflater.inflate(R.layout.fragment_configuracion, container, false)
54 val etRuta = v.findViewById<EditText>(R.id.etRuta) 65 val etRuta = v.findViewById<EditText>(R.id.etRuta)
55 val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) 66 val btnGuardar = v.findViewById<Button>(R.id.btnGuardar)
56 val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) 67 val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu)
57 val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu) 68 val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu)
58 val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura) 69 val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura)
59 val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock) 70 val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock)
60 val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras) 71 val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras)
61 val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo) 72 val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo)
62 val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen) 73 val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen)
63 val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito) 74 val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito)
64 val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas) 75 val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas)
65 val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) 76 val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia)
66 val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) 77 val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio)
67 val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) 78 val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor)
68 val spServidor = v.findViewById<Spinner>(R.id.spServidor) 79 val spServidor = v.findViewById<Spinner>(R.id.spServidor)
69 val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) 80 val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor)
70 81
71 if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) { 82 if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) {
72 if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { 83 if (sharedPreferences.getString("rbProInclu", "").toString() == "0") {
73 rbProInclu.isChecked = false 84 rbProInclu.isChecked = false
74 rbProNoInclu.isChecked = true 85 rbProNoInclu.isChecked = true
75 } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { 86 } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") {
76 rbProInclu.isChecked = true 87 rbProInclu.isChecked = true
77 rbProNoInclu.isChecked = false 88 rbProNoInclu.isChecked = false
78 } 89 }
79 } else (sharedPreferences.getString("rbProInclu", "").toString() == "") 90 } else (sharedPreferences.getString("rbProInclu", "").toString() == "")
80 91
81 if (sharedPreferences.contains("rbProNoInclu")) { 92 if (sharedPreferences.contains("rbProNoInclu")) {
82 if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { 93 if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") {
83 rbProNoInclu.isChecked = false 94 rbProNoInclu.isChecked = false
84 rbProInclu.isChecked = true 95 rbProInclu.isChecked = true
85 } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { 96 } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") {
86 rbProNoInclu.isChecked = true 97 rbProNoInclu.isChecked = true
87 rbProInclu.isChecked = false 98 rbProInclu.isChecked = false
88 } 99 }
89 } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") 100 } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "")
90 101
91 if (sharedPreferences.contains("cbHabiLectura")) { 102 if (sharedPreferences.contains("cbHabiLectura")) {
92 if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { 103 if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") {
93 cbHabiLectura.isChecked = false 104 cbHabiLectura.isChecked = false
94 } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { 105 } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") {
95 cbHabiLectura.isChecked = true 106 cbHabiLectura.isChecked = true
96 } 107 }
97 } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") 108 } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "")
98 109
99 if (sharedPreferences.contains("cbMostrarStock")) { 110 if (sharedPreferences.contains("cbMostrarStock")) {
100 if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { 111 if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") {
101 cbMostrarStock.isChecked = false 112 cbMostrarStock.isChecked = false
102 } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") { 113 } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") {
103 cbMostrarStock.isChecked = true 114 cbMostrarStock.isChecked = true
104 } 115 }
105 } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") 116 } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "")
106 117
107 if (sharedPreferences.contains("rbVentas")) { 118 if (sharedPreferences.contains("rbVentas")) {
108 if (sharedPreferences.getString("rbVentas", "").toString() == "0") { 119 if (sharedPreferences.getString("rbVentas", "").toString() == "0") {
109 rbVentas.isChecked = false 120 rbVentas.isChecked = false
110 rbDeposito.isChecked = true 121 rbDeposito.isChecked = true
111 } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { 122 } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") {
112 rbVentas.isChecked = true 123 rbVentas.isChecked = true
113 rbDeposito.isChecked = false 124 rbDeposito.isChecked = false
114 } 125 }
115 } else (sharedPreferences.getString("rbVentas", "").toString() == "") 126 } else (sharedPreferences.getString("rbVentas", "").toString() == "")
116 127
117 if (sharedPreferences.contains("rbDeposito")) { 128 if (sharedPreferences.contains("rbDeposito")) {
118 if (sharedPreferences.getString("rbDeposito", "").toString() == "0") { 129 if (sharedPreferences.getString("rbDeposito", "").toString() == "0") {
119 rbDeposito.isChecked = false 130 rbDeposito.isChecked = false
120 rbVentas.isChecked = true 131 rbVentas.isChecked = true
121 } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { 132 } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") {
122 rbDeposito.isChecked = true 133 rbDeposito.isChecked = true
123 rbVentas.isChecked = false 134 rbVentas.isChecked = false
124 } 135 }
125 } else (sharedPreferences.getString("rbDeposito", "").toString() == "") 136 } else (sharedPreferences.getString("rbDeposito", "").toString() == "")
126 137
127 if (sharedPreferences.contains("rbCodigoDebo")) { 138 if (sharedPreferences.contains("rbCodigoDebo")) {
128 if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { 139 if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") {
129 rbCodigoDebo.isChecked = false 140 rbCodigoDebo.isChecked = false
130 rbCodigoOrigen.isChecked = false 141 rbCodigoOrigen.isChecked = false
131 rbCodigoBarras.isChecked = false 142 rbCodigoBarras.isChecked = false
132 } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { 143 } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") {
133 rbCodigoDebo.isChecked = true 144 rbCodigoDebo.isChecked = true
134 rbCodigoOrigen.isChecked = false 145 rbCodigoOrigen.isChecked = false
135 rbCodigoBarras.isChecked = false 146 rbCodigoBarras.isChecked = false
136 } 147 }
137 } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "") 148 } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "")
138 149
139 if (sharedPreferences.contains("rbCodigoOrigen")) { 150 if (sharedPreferences.contains("rbCodigoOrigen")) {
140 if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") { 151 if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") {
141 rbCodigoOrigen.isChecked = false 152 rbCodigoOrigen.isChecked = false
142 } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") { 153 } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") {
143 rbCodigoOrigen.isChecked = true 154 rbCodigoOrigen.isChecked = true
144 } 155 }
145 } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") 156 } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "")
146 157
147 if (sharedPreferences.contains("rbCodigoBarras")) { 158 if (sharedPreferences.contains("rbCodigoBarras")) {
148 if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { 159 if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") {
149 rbCodigoBarras.isChecked = false 160 rbCodigoBarras.isChecked = false
150 } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") { 161 } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") {
151 rbCodigoBarras.isChecked = true 162 rbCodigoBarras.isChecked = true
152 } 163 }
153 } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") 164 } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "")
154 165
155 if (sharedPreferences.contains("cbMostrarExistencia")) { 166 if (sharedPreferences.contains("cbMostrarExistencia")) {
156 if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { 167 if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") {
157 cbMostrarExistencia.isChecked = false 168 cbMostrarExistencia.isChecked = false
158 } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { 169 } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") {
159 cbMostrarExistencia.isChecked = true 170 cbMostrarExistencia.isChecked = true
160 } 171 }
161 } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") 172 } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "")
162 173
163 if (sharedPreferences.contains("cbMostrarPrecio")) { 174 if (sharedPreferences.contains("cbMostrarPrecio")) {
164 if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { 175 if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") {
165 cbMostrarPrecio.isChecked = false 176 cbMostrarPrecio.isChecked = false
166 } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") { 177 } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") {
167 cbMostrarPrecio.isChecked = true 178 cbMostrarPrecio.isChecked = true
168 } 179 }
169 } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "") 180 } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "")
170 181
171 btnGuardar.setOnClickListener { 182 btnGuardar.setOnClickListener {
172 guardarPreferencias() 183 guardarPreferencias()
173 Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() 184 Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG)
185 .show()
174 navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) 186 navController.navigate(R.id.action_configuracionFragment_to_mainFragment2)
175 } 187 }
176 btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } 188 btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) }
177 189
178 btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Dirección correcta", Toast.LENGTH_LONG).show() } 190 btnValidarServidor.setOnClickListener {
191 GlobalScope.launch(Main) {
192 val serverPre = fetchServerPreOne()
193 if (isConnectedToThisServer(serverPre!!.direccion.toString().substring(7,serverPre.direccion.toString().length))) {
194 Toast.makeText(requireContext(), "¡Dirección Valida!", Toast.LENGTH_LONG).show()
195 } else {
196 Toast.makeText(requireContext(), "¡Verifique la Dirección!", Toast.LENGTH_LONG)
197 .show()
198 }
199 }
200 }
179 201
180 spServidor.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { 202 spServidor.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
181 override fun onNothingSelected(parent: AdapterView<*>?) {} 203 override fun onNothingSelected(parent: AdapterView<*>?) {}
182 override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { 204 override fun onItemSelected(
205 parent: AdapterView<*>?,
206 view: View?,
207 position: Int,
208 id: Long
209 ) {
183 itemSelect = parent!!.getItemAtPosition(position).toString().substring(0, 2).toInt() 210 itemSelect = parent!!.getItemAtPosition(position).toString().substring(0, 2).toInt()
184 indexSelect=position 211 indexSelect = position
185 } 212 }
186 } 213 }
187 return v 214 return v
188 } 215 }
189 216
190 suspend fun getDescServers(): List<ServeInv> { 217 suspend fun getDescServers(): List<ServeInv> {
191 return GlobalScope.async(Dispatchers.IO) { 218 return GlobalScope.async(Dispatchers.IO) {
192 return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() 219 return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers()
193 }.await() 220 }.await()
194 } 221 }
195 222
196 fun guardarPreferencias() { 223 fun guardarPreferencias() {
197 // try { 224 // try {
198 val editor = sharedPreferences.edit() 225 val editor = sharedPreferences.edit()
199 226
200 if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString()) 227 if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString())
201 228
202 if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") 229 if (rbProInclu.isChecked) editor?.putString(
203 if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") 230 "rbProInclu",
204 231 "1"
205 if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") 232 ) else editor?.putString("rbProInclu", "0")
206 if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") 233 if (rbProNoInclu.isChecked) editor?.putString(
207 if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") 234 "rbProNoInclu",
208 if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") 235 "1"
209 if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") 236 ) else editor?.putString("rbProNoInclu", "0")
210 if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") 237
211 if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") 238 if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString(
212 if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") 239 "cbHabiLectura",
213 if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") 240 "0"
241 )
242 if (cbMostrarStock.isChecked) editor?.putString(
243 "cbMostrarStock",
244 "1"
245 ) else editor?.putString("cbMostrarStock", "0")
246 if (rbVentas.isChecked) editor?.putString(
247 "rbVentas",
248 "1"
249 ) else editor?.putString("rbVentas", "0")
250 if (rbDeposito.isChecked) editor?.putString(
251 "rbDeposito",
252 "1"
253 ) else editor?.putString("rbDeposito", "0")
254 if (rbCodigoDebo.isChecked) editor?.putString(
255 "rbCodigoDebo",
256 "1"
257 ) else editor?.putString("rbCodigoDebo", "0")
258 if (rbCodigoOrigen.isChecked) editor?.putString(
259 "rbCodigoOrigen",
260 "1"
261 ) else editor?.putString("rbCodigoOrigen", "0")
262 if (rbCodigoBarras.isChecked) editor?.putString(
263 "rbCodigoBarras",
264 "1"
265 ) else editor?.putString("rbCodigoBarras", "0")
266 if (cbMostrarExistencia.isChecked) editor?.putString(
267 "cbMostrarExistencia",
268 "1"
269 ) else editor?.putString("cbMostrarExistencia", "0")
270 if (cbMostrarPrecio.isChecked) editor?.putString(
271 "cbMostrarPrecio",
272 "1"
273 ) else editor?.putString("cbMostrarPrecio", "0")
214 editor?.putString("ServerPredeterminado", indexSelect.toString()) 274 editor?.putString("ServerPredeterminado", indexSelect.toString())
215 updateServerPreInZero() 275 updateServerPreInZero()
216 updateServerPre(itemSelect) 276 updateServerPre(itemSelect)
217 277
218 editor?.apply() 278 editor?.apply()
219 editor.commit() 279 editor.commit()
220 280
221 // } catch (e: Exception) { 281 // } catch (e: Exception) {
222 // Toast.makeText(requireContext(), "Error ", Toast.LENGTH_LONG).show() 282 // Toast.makeText(requireContext(), "Error ", Toast.LENGTH_LONG).show()
223 // e.printStackTrace() 283 // e.printStackTrace()
224 // } 284 // }
225 } 285 }
226 286
227 private fun updateServerPreInZero() { 287 private fun updateServerPreInZero() {
228 lifecycleScope.launch { 288 lifecycleScope.launch {
229 withContext(Dispatchers.IO) { 289 withContext(Dispatchers.IO) {
230 val activity: FragmentActivity? = activity 290 val activity: FragmentActivity? = activity
231 if (activity != null && isAdded) { 291 if (activity != null && isAdded) {
232 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPreInZero() 292 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPreInZero()
233 } 293 }
234 } 294 }
235 } 295 }
236 } 296 }
237 297
238 private fun updateServerPre(server: Int) { 298 private fun updateServerPre(server: Int) {
239 lifecycleScope.launch { 299 lifecycleScope.launch {
240 withContext(Dispatchers.IO) { 300 withContext(Dispatchers.IO) {
241 val activity: FragmentActivity? = activity 301 val activity: FragmentActivity? = activity
242 if (activity != null) { 302 if (activity != null) {
243 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPre(server) 303 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPre(server)
244 } 304 }
245 } 305 }
246 } 306 }
247 } 307 }
308 private suspend fun fetchServerPreOne(): ServeInv? {
309 return GlobalScope.async(Dispatchers.IO) {
310 return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne()
311 }.await()
312 }
248 } 313 }
app/src/main/java/com/focasoftware/deboinventariov20/UI/inventario/ProductosListAdapter.kt
1 package com.focasoftware.deboinventariov20.UI.inventario 1 package com.focasoftware.deboinventariov20.UI.inventario
2 2
3 import android.content.Context 3 import android.content.Context
4 import android.view.LayoutInflater 4 import android.view.LayoutInflater
5 import android.view.View 5 import android.view.View
6 import android.view.ViewGroup 6 import android.view.ViewGroup
7 import androidx.recyclerview.widget.RecyclerView 7 import androidx.recyclerview.widget.RecyclerView
8 import com.focasoftware.deboinventariov20.R 8 import com.focasoftware.deboinventariov20.R
9 import com.focasoftware.deboinventariov20.UI.Utils.BaseViewHolder 9 import com.focasoftware.deboinventariov20.UI.Utils.BaseViewHolder
10 import kotlinx.android.synthetic.main.item.view.* 10 import kotlinx.android.synthetic.main.item.view.*
11 import java.io.IOException
12 import java.net.UnknownHostException
11 13
12 14
13 class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) : 15 class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) :
14 RecyclerView.Adapter<BaseViewHolder<*>>() { 16 RecyclerView.Adapter<BaseViewHolder<*>>() {
15 17
16 private var removePosition: Int = 0 18 private var removePosition: Int = 0
17 private var removedItem: ItemsRecycler? = null 19 private var removedItem: ItemsRecycler? = null
18 20
19 interface OnImageDotsClickListener { 21 interface OnImageDotsClickListener {
20 fun onImageDotsClick(sector: String?,codigo: String?) 22 fun onImageDotsClick(sector: String?,codigo: String?)
21 fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) 23 fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String)
22 } 24 }
23 25
24 override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) 26 override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false))
25 27
26 override fun getItemCount() = productos.size 28 override fun getItemCount() = productos.size
27 29
28 override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { 30 override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) {
29 when (holder) { 31 when (holder) {
30 is ItemsViewHolder -> { holder.bind(productos[position], position) } 32 is ItemsViewHolder -> { holder.bind(productos[position], position) }
31 33
32 } 34 }
33 } 35 }
34 inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) { 36 inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) {
35 override fun bind(item: ItemsRecycler, position: Int) { 37 override fun bind(item: ItemsRecycler, position: Int) {
36 itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) } 38 itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) }
37 itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) } 39 itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) }
38 40
39 itemView.tvSector.text=item.sector 41 itemView.tvSector.text=item.sector
40 itemView.tvCodigo.text=item.codigo 42 itemView.tvCodigo.text=item.codigo
41 itemView.tvDescripcion.text=item.descripcion 43 itemView.tvDescripcion.text=item.descripcion
42 itemView.tvCantidad.text=item.cantTomada.toString() 44 itemView.tvCantidad.text=item.cantTomada.toString()
43 itemView.tvCodigoBarras.text=item.sector 45 itemView.tvCodigoBarras.text=item.sector
44 itemView.tvCodigoOrigen.text=item.sector 46 itemView.tvCodigoOrigen.text=item.sector
45 itemView.ivPen.setImageResource(R.drawable.pen) 47 itemView.ivPen.setImageResource(R.drawable.pen)
46 itemView.ivDots.setImageResource(R.drawable.more) 48 itemView.ivDots.setImageResource(R.drawable.more)
47 } 49 }
48 } 50 }
49 51
50 fun removeItem(viewHolder: RecyclerView.ViewHolder) { 52 fun removeItem(viewHolder: RecyclerView.ViewHolder) {
51 removePosition = viewHolder.adapterPosition 53 removePosition = viewHolder.adapterPosition
52 removedItem = productos[viewHolder.adapterPosition] 54 removedItem = productos[viewHolder.adapterPosition]
53 55
54 productos.removeAt(viewHolder.adapterPosition) 56 productos.removeAt(viewHolder.adapterPosition)
55 notifyItemRemoved(viewHolder.adapterPosition) 57 notifyItemRemoved(viewHolder.adapterPosition)
56 } 58 }
59 }
57 60
58
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/AdapterServidores.kt
1 package com.focasoftware.deboinventariov20.UI.servidores 1 package com.focasoftware.deboinventariov20.UI.servidores
2 2
3 import android.content.Context 3 import android.content.Context
4 import android.view.LayoutInflater 4 import android.view.LayoutInflater
5 import android.view.View 5 import android.view.View
6 import android.view.ViewGroup 6 import android.view.ViewGroup
7 import androidx.recyclerview.widget.RecyclerView 7 import androidx.recyclerview.widget.RecyclerView
8 import com.focasoftware.deboinventariov20.R 8 import com.focasoftware.deboinventariov20.R
9 import kotlinx.android.synthetic.main.item_servidores.view.* 9 import kotlinx.android.synthetic.main.item_servidores.view.*
10 10
11 class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, private var contexto: Context) : 11 class AdapterServidores(private val servidor: ArrayList<ItemsServidores>, private var contexto: Context) :
12 RecyclerView.Adapter<AdapterServidores.ViewHolder>() { 12 RecyclerView.Adapter<AdapterServidores.ViewHolder>() {
13 private var removePosition: Int = 0 13 private var removePosition: Int = 0
14 private var removedItem: ItemsServidores? = null 14 private var removedItem: ItemsServidores? = null
15 15
16 class ViewHolder(var vista: View) : RecyclerView.ViewHolder(vista) { 16 class ViewHolder(var vista: View) : RecyclerView.ViewHolder(vista) {
17 fun bind(itemsServidores: ItemsServidores) { 17 fun bind(itemsServidores: ItemsServidores) {
18 vista.tvDescServidor.text = itemsServidores.descripcion 18 vista.tvDescServidor.text = itemsServidores.descripcion
19 vista.tvDireccionServidor.text = itemsServidores.direccion 19 vista.tvDireccionServidor.text = itemsServidores.direccion
20 vista.tvPuertoServidor.text = itemsServidores.puerto
20 21
21 } 22 }
22 } 23 }
23 24
24 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 25 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
25 return ViewHolder( 26 return ViewHolder(
26 LayoutInflater.from(parent.context).inflate(R.layout.item_servidores, parent, false) 27 LayoutInflater.from(parent.context).inflate(R.layout.item_servidores, parent, false)
27 ) 28 )
28 } 29 }
29 30
30 override fun getItemCount(): Int { 31 override fun getItemCount(): Int {
31 return servidor.size 32 return servidor.size
32 } 33 }
33 34
34 override fun onBindViewHolder(holder: ViewHolder, position: Int) { 35 override fun onBindViewHolder(holder: ViewHolder, position: Int) {
35 holder.bind(servidor[position]) 36 holder.bind(servidor[position])
36 } 37 }
37 fun removeItem(viewHolder: RecyclerView.ViewHolder) { 38 fun removeItem(viewHolder: RecyclerView.ViewHolder) {
38 removePosition = viewHolder.adapterPosition 39 removePosition = viewHolder.adapterPosition
39 removedItem = servidor[viewHolder.adapterPosition] 40 removedItem = servidor[viewHolder.adapterPosition]
40 41
41 servidor.removeAt(viewHolder.adapterPosition) 42 servidor.removeAt(viewHolder.adapterPosition)
42 notifyItemRemoved(viewHolder.adapterPosition) 43 notifyItemRemoved(viewHolder.adapterPosition)
43 } 44 }
44 } 45 }
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/ItemsServidores.kt
1 package com.focasoftware.deboinventariov20.UI.servidores 1 package com.focasoftware.deboinventariov20.UI.servidores
2 2
3 data class ItemsServidores(val descripcion: String?, var direccion: String?, var predeterminado: String?)
app/src/main/java/com/focasoftware/deboinventariov20/UI/servidores/ServidoresFragment.kt
1 package com.focasoftware.deboinventariov20.UI.servidores 1 package com.focasoftware.deboinventariov20.UI.servidores
2 2
3 import android.graphics.Canvas 3 import android.graphics.Canvas
4 import android.graphics.Color 4 import android.graphics.Color
5 import android.graphics.drawable.Drawable 5 import android.graphics.drawable.Drawable
6 import android.os.Bundle 6 import android.os.Bundle
7 import android.view.LayoutInflater 7 import android.view.LayoutInflater
8 import android.view.View 8 import android.view.View
9 import android.view.ViewGroup 9 import android.view.ViewGroup
10 import android.widget.Toast 10 import android.widget.Toast
11 import androidx.core.content.ContextCompat 11 import androidx.core.content.ContextCompat
12 import androidx.fragment.app.Fragment 12 import androidx.fragment.app.Fragment
13 import androidx.lifecycle.lifecycleScope 13 import androidx.lifecycle.lifecycleScope
14 import androidx.recyclerview.widget.ItemTouchHelper 14 import androidx.recyclerview.widget.ItemTouchHelper
15 import androidx.recyclerview.widget.LinearLayoutManager 15 import androidx.recyclerview.widget.LinearLayoutManager
16 import androidx.recyclerview.widget.RecyclerView 16 import androidx.recyclerview.widget.RecyclerView
17 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb 17 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb
18 import com.focasoftware.deboinventariov20.Model.ServeInv 18 import com.focasoftware.deboinventariov20.Model.ServeInv
19 import com.focasoftware.deboinventariov20.R 19 import com.focasoftware.deboinventariov20.R
20 import kotlinx.android.synthetic.main.fragment_servidores.* 20 import kotlinx.android.synthetic.main.fragment_servidores.*
21 import kotlinx.coroutines.* 21 import kotlinx.coroutines.*
22 22
23 class ServidoresFragment : Fragment() { 23 class ServidoresFragment : Fragment() {
24 24
25 private lateinit var rvServidores: RecyclerView 25 private lateinit var rvServidores: RecyclerView
26 private lateinit var viewAdapter: RecyclerView.Adapter<*> 26 private lateinit var viewAdapter: RecyclerView.Adapter<*>
27 private lateinit var viewManager: RecyclerView.LayoutManager 27 private lateinit var viewManager: RecyclerView.LayoutManager
28 private var listServ = ArrayList<ItemsServidores>() 28 private var listServ = ArrayList<ItemsServidores>()
29 private lateinit var servidores: List<ServeInv> 29 private lateinit var servidores: List<ServeInv>
30 private lateinit var deleteIcon: Drawable 30 private lateinit var deleteIcon: Drawable
31 31
32 override fun onCreate(savedInstanceState: Bundle?) { 32 override fun onCreate(savedInstanceState: Bundle?) {
33 super.onCreate(savedInstanceState) 33 super.onCreate(savedInstanceState)
34 CargarRV() 34 CargarRV()
35 } 35 }
36 36
37 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 37 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
38 super.onViewCreated(view, savedInstanceState) 38 super.onViewCreated(view, savedInstanceState)
39 39
40 btnGuardarServidores.setOnClickListener { 40 btnGuardarServidores.setOnClickListener {
41 if (etNombreServidor.text.isNullOrBlank()) { 41 if (etNombreServidor.text.isNullOrBlank()) {
42 etNombreServidor.error = "Nombre no valido" 42 etNombreServidor.error = "Nombre no valido"
43 etNombreServidor.requestFocus() 43 etNombreServidor.requestFocus()
44 etNombreServidor.hint = "Nombre no valido" 44 etNombreServidor.hint = "Nombre no valido"
45 } 45 }
46 if (etDireccionServidor.text.isNullOrBlank()) { 46 if (etDireccionServidor.text.isNullOrBlank()) {
47 etDireccionServidor.error = "Dirección no valida" 47 etDireccionServidor.error = "Dirección no valida"
48 etDireccionServidor.requestFocus() 48 etDireccionServidor.requestFocus()
49 etDireccionServidor.hint = "Dirección no valida" 49 etDireccionServidor.hint = "Dirección no valida"
50 } 50 }
51 if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()) { 51 if (!etDireccionServidor.text.isNullOrBlank() || !etNombreServidor.text.isNullOrBlank()) {
52 // GlobalScope.launch(Dispatchers.Main) { 52 // GlobalScope.launch(Dispatchers.Main) {
53 // ServerNew =AppDb.getAppDb(requireContext())?.ServeInvDao()?.findLastServer()?.plus(1) ?: 1 53 // ServerNew =AppDb.getAppDb(requireContext())?.ServeInvDao()?.findLastServer()?.plus(1) ?: 1
54 val servidor = ServeInv(etNombreServidor.text.toString(), "http://${etDireccionServidor.text}/", 0) 54 val servidor = ServeInv(etNombreServidor.text.toString(), "http://${etDireccionServidor.text}",
55 etPuerto.text.toString(),0)
55 ingresarDatos(servidor) 56 ingresarDatos(servidor)
56 cargarRecicler(servidor) 57 cargarRecicler(servidor)
57 Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() 58 Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show()
58 etNombreServidor.text.clear() 59 etNombreServidor.text.clear()
59 etDireccionServidor.text.clear() 60 etDireccionServidor.text.clear()
60 // } 61 // }
61 } 62 }
62 } 63 }
63 } 64 }
64 65
65 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 66 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
66 val v = inflater.inflate(R.layout.fragment_servidores, container, false) 67 val v = inflater.inflate(R.layout.fragment_servidores, container, false)
67 rvServidores = v.findViewById(R.id.rvServidores) 68 rvServidores = v.findViewById(R.id.rvServidores)
68 return v 69 return v
69 } 70 }
70 71
71 fun ingresarDatos(servidor: ServeInv) { 72 fun ingresarDatos(servidor: ServeInv) {
72 val Job = GlobalScope.launch { 73 val Job = GlobalScope.launch {
73 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) 74 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor)
74 } 75 }
75 } 76 }
76 77
77 suspend fun buscarEnBD(): List<ServeInv> { 78 suspend fun buscarEnBD(): List<ServeInv> {
78 var busqueda: List<ServeInv> 79 var busqueda: List<ServeInv>
79 return GlobalScope.async(Dispatchers.IO) { 80 return GlobalScope.async(Dispatchers.IO) {
80 busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() 81 busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers()
81 return@async busqueda 82 return@async busqueda
82 }.await() 83 }.await()
83 } 84 }
84 85
85 fun CargarRV() { 86 fun CargarRV() {
86 GlobalScope.launch(Dispatchers.Main) { 87 GlobalScope.launch(Dispatchers.Main) {
87 servidores = buscarEnBD() 88 servidores = buscarEnBD()
88 for ((i, item) in servidores.withIndex()) { 89 for ((i, item) in servidores.withIndex()) {
89 val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) 90 val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion,servidores[i].puerto, servidores[i].predeterminado)
90 cargarRecicler(ser) 91 cargarRecicler(ser)
91 } 92 }
92 } 93 }
93 } 94 }
94 95
95 fun cargarRecicler(ser: ServeInv) { 96 fun cargarRecicler(ser: ServeInv) {
96 //TODO CARGO EN LE RV 97 //TODO CARGO EN LE RV
97 deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! 98 deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!!
98 val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado.toString()) 99 val item = ItemsServidores(ser.descripcion, ser.direccion, ser.puerto.toString(),ser.predeterminado.toString())
99 100
100 listServ.add(item) 101 listServ.add(item)
101 102
102 viewAdapter = AdapterServidores(listServ, requireContext()) 103 viewAdapter = AdapterServidores(listServ, requireContext())
103 viewManager = LinearLayoutManager(requireContext()) 104 viewManager = LinearLayoutManager(requireContext())
104 105
105 rvServidores.apply { 106 rvServidores.apply {
106 adapter = viewAdapter 107 adapter = viewAdapter
107 layoutManager = viewManager 108 layoutManager = viewManager
108 } 109 }
109 val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { 110 val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
110 override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { 111 override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
111 return false 112 return false
112 } 113 }
113 114
114 override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { 115 override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) {
115 GlobalScope.launch(Dispatchers.Main) { 116 GlobalScope.launch(Dispatchers.Main) {
116 deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) 117 deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString())
117 118
118 (viewAdapter as AdapterServidores).removeItem(viewHolder) 119 (viewAdapter as AdapterServidores).removeItem(viewHolder)
119 viewAdapter.notifyDataSetChanged() 120 viewAdapter.notifyDataSetChanged()
120 } 121 }
121 } 122 }
122 123
123 override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { 124 override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
124 val itemView = viewHolder.itemView 125 val itemView = viewHolder.itemView
125 val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 126 val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2
126 c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) 127 c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat())
127 128
128 if (dX > 0) { 129 if (dX > 0) {
129 130
130 if (dX < c.width / 2) c.drawColor(Color.GREEN) 131 if (dX < c.width / 2) c.drawColor(Color.GREEN)
131 else c.drawColor(Color.RED) 132 else c.drawColor(Color.RED)
132 deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) 133 deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin)
133 } else { 134 } else {
134 } 135 }
135 super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) 136 super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
136 deleteIcon.draw(c) 137 deleteIcon.draw(c)
137 } 138 }
138 } 139 }
139 140
140 val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) 141 val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback)
141 itemTouchHelper.attachToRecyclerView(rvServidores) 142 itemTouchHelper.attachToRecyclerView(rvServidores)
142 } 143 }
143 144
144 suspend fun deleteServer(serverName: String, serverDir: String) { 145 suspend fun deleteServer(serverName: String, serverDir: String) {
145 lifecycleScope.launch { 146 lifecycleScope.launch {
146 withContext(Dispatchers.IO) { 147 withContext(Dispatchers.IO) {
147 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) 148 AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir)
148 } 149 }
149 } 150 }
150 } 151 }
151 } 152 }
152 153
app/src/main/res/layout-land/fragment_servidores.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.constraintlayout.widget.ConstraintLayout 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
5 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
6 android:layout_width="match_parent" 5 android:layout_width="match_parent"
7 android:layout_height="match_parent" 6 android:layout_height="match_parent"
8 tools:context=".UI.servidores.ServidoresFragment"> 7 tools:context=".UI.servidores.ServidoresFragment">
9 8
10 <androidx.appcompat.widget.AppCompatTextView 9 <androidx.appcompat.widget.AppCompatTextView
11 android:id="@+id/tvTitutloServer" 10 android:id="@+id/tvTitutloServer"
12 android:layout_width="match_parent" 11 android:layout_width="match_parent"
13 android:layout_height="40dp" 12 android:layout_height="90dp"
14 android:layout_marginStart="8dp" 13 android:layout_marginStart="8dp"
15 android:layout_marginTop="15dp" 14 android:layout_marginTop="15dp"
16 android:layout_marginEnd="8dp" 15 android:layout_marginEnd="8dp"
17 android:autoSizeMaxTextSize="100sp" 16 android:autoSizeMaxTextSize="100sp"
18 android:autoSizeMinTextSize="20sp" 17 android:autoSizeMinTextSize="20sp"
19 android:autoSizeStepGranularity="5sp" 18 android:autoSizeStepGranularity="5sp"
20 android:autoSizeTextType="uniform" 19 android:autoSizeTextType="uniform"
21 android:gravity="center" 20 android:gravity="center"
22 android:lines="1" 21 android:lines="1"
23 android:text="@string/tvTitutloServer" 22 android:text="@string/tvTitutloServer"
24 android:textColor="@color/colorAccent" 23 android:textColor="@color/colorAccent"
25 app:fontFamily="sans-serif-condensed" 24 app:fontFamily="sans-serif-condensed"
26 app:layout_constraintEnd_toEndOf="parent" 25 app:layout_constraintEnd_toEndOf="parent"
27 app:layout_constraintStart_toStartOf="parent" 26 app:layout_constraintStart_toStartOf="parent"
28 app:layout_constraintTop_toTopOf="parent" /> 27 app:layout_constraintTop_toTopOf="parent" />
29 28
29
30 <TextView 30 <TextView
31 android:id="@+id/tvDirServer" 31 android:id="@+id/tvNomServer"
32 android:layout_width="match_parent" 32 android:layout_width="match_parent"
33 android:layout_height="wrap_content" 33 android:layout_height="wrap_content"
34 34 android:layout_margin="10dp"
35 android:gravity="start" 35 android:gravity="start"
36 android:lines="1" 36 android:lines="1"
37 android:text="@string/tvDirServer" 37 android:text="@string/tvNomServer"
38 android:textColor="@android:color/black" 38 android:textColor="@android:color/black"
39 android:textSize="@dimen/SubTitulos" 39 android:textSize="@dimen/SubTitulos"
40 android:textStyle="bold|italic" 40 android:textStyle="bold|italic"
41 app:fontFamily="sans-serif-condensed" 41 app:fontFamily="sans-serif-condensed"
42 app:layout_constraintBottom_toTopOf="@+id/etDireccionServidor"
43 app:layout_constraintEnd_toEndOf="parent" 42 app:layout_constraintEnd_toEndOf="parent"
44 app:layout_constraintStart_toStartOf="parent" 43 app:layout_constraintStart_toStartOf="parent"
45 app:layout_constraintTop_toBottomOf="@id/tvTitutloServer" /> 44 app:layout_constraintTop_toBottomOf="@id/tvTitutloServer" />
46 45
47 <EditText 46 <EditText
48 android:id="@+id/etDireccionServidor" 47 android:id="@+id/etNombreServidor"
49 android:layout_width="0dp" 48 android:layout_width="match_parent"
50 android:layout_height="wrap_content" 49 android:layout_height="wrap_content"
51 android:clickable="true" 50 android:layout_margin="10dp"
51 android:autofillHints=""
52 android:clickable="true"
52 android:ems="10" 53 android:ems="10"
53 android:focusable="true" 54 android:focusable="true"
54 android:hint="192.168.10.1:9090" 55 android:hint="Servidor Local"
55 android:inputType="text" 56 android:inputType="text"
56 android:lines="1" 57 android:lines="1"
57 android:textSize="10sp" 58 android:textSize="15sp"
58 app:layout_constraintEnd_toEndOf="parent" 59 app:layout_constraintEnd_toEndOf="parent"
59 app:layout_constraintStart_toStartOf="parent" 60 app:layout_constraintStart_toStartOf="parent"
60 app:layout_constraintTop_toBottomOf="@id/tvDirServer" /> 61 app:layout_constraintTop_toBottomOf="@+id/tvNomServer" />
61 62
62 <TextView 63 <TextView
63 android:id="@+id/tvNomServer" 64 android:id="@+id/tvDirServer"
64 android:layout_width="match_parent" 65 android:layout_width="wrap_content"
65 android:layout_height="wrap_content" 66 android:layout_height="wrap_content"
67 android:layout_margin="10dp"
66 android:gravity="start" 68 android:gravity="start"
67 android:lines="1" 69 android:lines="1"
68 android:text="@string/tvNomServer" 70 android:text="@string/tvDirServer"
69 android:textColor="@android:color/black" 71 android:textColor="@android:color/black"
70 android:textSize="@dimen/SubTitulos" 72 android:textSize="@dimen/SubTitulos"
71 android:textStyle="bold|italic" 73 android:textStyle="bold|italic"
72 app:fontFamily="sans-serif-condensed" 74 app:fontFamily="sans-serif-condensed"
73 app:layout_constraintEnd_toEndOf="parent"
74 app:layout_constraintStart_toStartOf="parent" 75 app:layout_constraintStart_toStartOf="parent"
75 app:layout_constraintTop_toBottomOf="@id/etDireccionServidor" /> 76 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" />
76 77
77 <EditText 78 <EditText
78 android:id="@+id/etNombreServidor" 79 android:id="@+id/etDireccionServidor"
79 android:layout_width="match_parent" 80 android:layout_width="130dp"
80 android:layout_height="wrap_content" 81 android:layout_height="wrap_content"
81 android:autofillHints="" 82
82 android:clickable="true" 83 android:clickable="true"
83 android:ems="10" 84 android:ems="10"
84 android:focusable="true" 85 android:focusable="true"
86 android:hint="192.168.100.100"
85 android:inputType="text" 87 android:inputType="text"
86 android:lines="1" 88 android:lines="1"
87 android:hint="Servidor Local" 89 android:textSize="15sp"
88 android:textSize="10sp" 90 app:layout_constraintBaseline_toBaselineOf="@+id/tvDirServer"
89 app:layout_constraintEnd_toEndOf="parent" 91 app:layout_constraintStart_toEndOf="@+id/tvDirServer" />
90 app:layout_constraintStart_toStartOf="parent" 92
91 app:layout_constraintTop_toBottomOf="@+id/tvNomServer" /> 93 <TextView
94 android:id="@+id/tvPuerto"
95 android:layout_width="wrap_content"
96 android:layout_height="wrap_content"
97 android:layout_marginStart="10dp"
98 android:layout_marginTop="10dp"
99 android:gravity="start"
100 android:lines="1"
101 android:text="Puerto:"
102 android:textColor="@android:color/black"
103 android:textSize="@dimen/SubTitulos"
104 android:textStyle="bold|italic"
105 app:fontFamily="sans-serif-condensed"
106 app:layout_constraintStart_toEndOf="@+id/etDireccionServidor"
107 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" />
108
109 <EditText
110 android:id="@+id/etPuerto"
111 android:layout_width="80dp"
112 android:layout_height="wrap_content"
113 android:clickable="true"
114 android:ems="10"
115 android:focusable="true"
116 android:hint="9999"
117 android:inputType="text"
118 android:lines="1"
119 android:textSize="15sp"
120 app:layout_constraintBaseline_toBaselineOf="@+id/tvPuerto"
121 app:layout_constraintStart_toEndOf="@+id/tvPuerto"
122 android:autofillHints="" />
92 123
93 124
94 <androidx.recyclerview.widget.RecyclerView 125 <androidx.recyclerview.widget.RecyclerView
95 android:id="@+id/rvServidores" 126 android:id="@+id/rvServidores"
96 android:layout_width="0dp" 127 android:layout_width="match_parent"
97 android:layout_height="0dp" 128 android:layout_height="0dp"
98 android:layout_marginTop="10dp" 129 android:layout_marginTop="10dp"
99 android:background="@android:color/darker_gray" 130 android:background="@android:color/darker_gray"
100 app:layout_constraintBottom_toTopOf="@+id/btnGuardarServidores" 131 app:layout_constraintBottom_toTopOf="@+id/btnGuardarServidores"
101 app:layout_constraintEnd_toEndOf="parent" 132 app:layout_constraintEnd_toEndOf="parent"
102 app:layout_constraintHorizontal_bias="0.0"
103 app:layout_constraintStart_toStartOf="parent" 133 app:layout_constraintStart_toStartOf="parent"
104 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" 134 app:layout_constraintTop_toBottomOf="@+id/etPuerto"
105 app:layout_goneMarginEnd="10dp" 135 app:layout_goneMarginEnd="10dp"
106 tools:listitem="@layout/item_servidores" /> 136 tools:listitem="@layout/item_servidores" />
107 137
108 <Button 138 <Button
109 android:id="@+id/btnGuardarServidores" 139 android:id="@+id/btnGuardarServidores"
110 android:layout_width="0dp" 140 android:layout_width="0dp"
111 android:layout_height="wrap_content" 141 android:layout_height="wrap_content"
112 142 android:layout_marginTop="10dp"
143 android:layout_marginEnd="10dp"
144 android:background="@drawable/boton_borde_redondeado"
145 android:padding="10dp"
113 android:text="@string/btnGuardarServidores" 146 android:text="@string/btnGuardarServidores"
114 android:textColor="@android:color/white" 147 android:textColor="@android:color/white"
115 android:padding="5dp" 148 app:layout_constraintBottom_toBottomOf="parent"
116 android:background="@drawable/boton_borde_redondeado"
117 app:layout_constraintTop_toBottomOf="@+id/rvServidores"
app/src/main/res/layout/fragment_servidores.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.constraintlayout.widget.ConstraintLayout 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
5 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
6 android:layout_width="match_parent" 5 android:layout_width="match_parent"
7 android:layout_height="match_parent" 6 android:layout_height="match_parent"
8 tools:context=".UI.servidores.ServidoresFragment"> 7 tools:context=".UI.servidores.ServidoresFragment">
9 8
10 <androidx.appcompat.widget.AppCompatTextView 9 <androidx.appcompat.widget.AppCompatTextView
11 android:id="@+id/tvTitutloServer" 10 android:id="@+id/tvTitutloServer"
12 android:layout_width="match_parent" 11 android:layout_width="match_parent"
13 android:layout_height="90dp" 12 android:layout_height="90dp"
14 android:layout_marginStart="8dp" 13 android:layout_marginStart="8dp"
15 android:layout_marginTop="15dp" 14 android:layout_marginTop="15dp"
16 android:layout_marginEnd="8dp" 15 android:layout_marginEnd="8dp"
17 android:autoSizeMaxTextSize="100sp" 16 android:autoSizeMaxTextSize="100sp"
18 android:autoSizeMinTextSize="20sp" 17 android:autoSizeMinTextSize="20sp"
19 android:autoSizeStepGranularity="5sp" 18 android:autoSizeStepGranularity="5sp"
20 android:autoSizeTextType="uniform" 19 android:autoSizeTextType="uniform"
21 android:gravity="center" 20 android:gravity="center"
22 android:lines="1" 21 android:lines="1"
23 android:text="@string/tvTitutloServer" 22 android:text="@string/tvTitutloServer"
24 android:textColor="@color/colorAccent" 23 android:textColor="@color/colorAccent"
25 app:fontFamily="sans-serif-condensed" 24 app:fontFamily="sans-serif-condensed"
26 app:layout_constraintEnd_toEndOf="parent" 25 app:layout_constraintEnd_toEndOf="parent"
27 app:layout_constraintStart_toStartOf="parent" 26 app:layout_constraintStart_toStartOf="parent"
28 app:layout_constraintTop_toTopOf="parent" /> 27 app:layout_constraintTop_toTopOf="parent" />
29 28
29
30 <TextView 30 <TextView
31 android:id="@+id/tvDirServer" 31 android:id="@+id/tvNomServer"
32 android:layout_width="match_parent" 32 android:layout_width="match_parent"
33 android:layout_height="wrap_content" 33 android:layout_height="wrap_content"
34 android:layout_margin="10dp" 34 android:layout_margin="10dp"
35 android:gravity="start" 35 android:gravity="start"
36 android:lines="1" 36 android:lines="1"
37 android:text="@string/tvDirServer" 37 android:text="@string/tvNomServer"
38 android:textColor="@android:color/black" 38 android:textColor="@android:color/black"
39 android:textSize="@dimen/TitulosMedios" 39 android:textSize="@dimen/SubTitulos"
40 android:textStyle="bold|italic" 40 android:textStyle="bold|italic"
41 app:fontFamily="sans-serif-condensed" 41 app:fontFamily="sans-serif-condensed"
42 app:layout_constraintBottom_toTopOf="@+id/etDireccionServidor"
43 app:layout_constraintEnd_toEndOf="parent" 42 app:layout_constraintEnd_toEndOf="parent"
44 app:layout_constraintStart_toStartOf="parent" 43 app:layout_constraintStart_toStartOf="parent"
45 app:layout_constraintTop_toBottomOf="@id/tvTitutloServer" /> 44 app:layout_constraintTop_toBottomOf="@id/tvTitutloServer" />
46 45
47 <EditText 46 <EditText
48 android:id="@+id/etDireccionServidor" 47 android:id="@+id/etNombreServidor"
49 android:layout_width="0dp" 48 android:layout_width="match_parent"
50 android:layout_height="wrap_content" 49 android:layout_height="wrap_content"
51 android:layout_margin="10dp" 50 android:layout_margin="10dp"
51 android:autofillHints=""
52 android:clickable="true" 52 android:clickable="true"
53 android:ems="10" 53 android:ems="10"
54 android:focusable="true" 54 android:focusable="true"
55 android:hint="192.168.10.1:9090" 55 android:hint="Servidor Local"
56 android:inputType="text" 56 android:inputType="text"
57 android:lines="1" 57 android:lines="1"
58 android:textSize="15sp" 58 android:textSize="15sp"
59 app:layout_constraintEnd_toEndOf="parent" 59 app:layout_constraintEnd_toEndOf="parent"
60 app:layout_constraintStart_toStartOf="parent" 60 app:layout_constraintStart_toStartOf="parent"
61 app:layout_constraintTop_toBottomOf="@id/tvDirServer" /> 61 app:layout_constraintTop_toBottomOf="@+id/tvNomServer" />
62 62
63 <TextView 63 <TextView
64 android:id="@+id/tvNomServer" 64 android:id="@+id/tvDirServer"
65 android:layout_width="match_parent" 65 android:layout_width="wrap_content"
66 android:layout_height="wrap_content" 66 android:layout_height="wrap_content"
67 android:layout_margin="10dp" 67 android:layout_margin="10dp"
68 android:gravity="start" 68 android:gravity="start"
69 android:lines="1" 69 android:lines="1"
70 android:text="@string/tvNomServer" 70 android:text="@string/tvDirServer"
71 android:textColor="@android:color/black" 71 android:textColor="@android:color/black"
72 android:textSize="@dimen/TitulosMedios" 72 android:textSize="@dimen/SubTitulos"
73 android:textStyle="bold|italic" 73 android:textStyle="bold|italic"
74 app:fontFamily="sans-serif-condensed" 74 app:fontFamily="sans-serif-condensed"
75 app:layout_constraintEnd_toEndOf="parent"
76 app:layout_constraintStart_toStartOf="parent" 75 app:layout_constraintStart_toStartOf="parent"
77 app:layout_constraintTop_toBottomOf="@id/etDireccionServidor" /> 76 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" />
78 77
79 <EditText 78 <EditText
80 android:id="@+id/etNombreServidor" 79 android:id="@+id/etDireccionServidor"
81 android:layout_width="match_parent" 80 android:layout_width="130dp"
82 android:layout_height="wrap_content" 81 android:layout_height="wrap_content"
83 android:layout_margin="10dp"
84 android:autofillHints=""
85 android:clickable="true"
86 android:ems="10"
87 android:focusable="true"
88 android:inputType="text"
89 android:lines="1"
90 android:hint="Servidor Local"
91 android:textSize="15sp"
92 app:layout_constraintEnd_toEndOf="parent"
93 app:layout_constraintStart_toStartOf="parent"
94 app:layout_constraintTop_toBottomOf="@+id/tvNomServer" />
95 82
83 android:clickable="true"
84 android:ems="10"
85 android:focusable="true"
86 android:hint="192.168.100.100"
87 android:inputType="text"
88 android:lines="1"
89 android:textSize="15sp"
90 app:layout_constraintBaseline_toBaselineOf="@+id/tvDirServer"
91 app:layout_constraintStart_toEndOf="@+id/tvDirServer" />
96 92
97 <androidx.recyclerview.widget.RecyclerView 93 <TextView
94 android:id="@+id/tvPuerto"
95 android:layout_width="wrap_content"
96 android:layout_height="wrap_content"
97 android:layout_marginStart="10dp"
98 android:layout_marginTop="10dp"
99 android:gravity="start"
100 android:lines="1"
101 android:text="Puerto:"
102 android:textColor="@android:color/black"
103 android:textSize="@dimen/SubTitulos"
104 android:textStyle="bold|italic"
105 app:fontFamily="sans-serif-condensed"
106 app:layout_constraintStart_toEndOf="@+id/etDireccionServidor"
107 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" />
108
109 <EditText
110 android:id="@+id/etPuerto"
111 android:layout_width="80dp"
112 android:layout_height="wrap_content"
113 android:clickable="true"
114 android:ems="10"
115 android:focusable="true"
116 android:hint="9999"
117 android:inputType="text"
118 android:lines="1"
119 android:textSize="15sp"
120 app:layout_constraintBaseline_toBaselineOf="@+id/tvPuerto"
121 app:layout_constraintStart_toEndOf="@+id/tvPuerto"
122 android:autofillHints="" />
123
124
125 <androidx.recyclerview.widget.RecyclerView
98 android:id="@+id/rvServidores" 126 android:id="@+id/rvServidores"
99 android:layout_width="match_parent" 127 android:layout_width="match_parent"
100 android:layout_height="0dp" 128 android:layout_height="0dp"
101 android:layout_marginTop="10dp" 129 android:layout_marginTop="10dp"
102 app:layout_goneMarginEnd="10dp"
103 android:background="@android:color/darker_gray" 130 android:background="@android:color/darker_gray"
104 app:layout_constraintBottom_toTopOf="@+id/btnGuardarServidores" 131 app:layout_constraintBottom_toTopOf="@+id/btnGuardarServidores"
105 app:layout_constraintEnd_toEndOf="parent" 132 app:layout_constraintEnd_toEndOf="parent"
106 app:layout_constraintStart_toStartOf="parent" 133 app:layout_constraintStart_toStartOf="parent"
107 app:layout_constraintTop_toBottomOf="@+id/etNombreServidor" 134 app:layout_constraintTop_toBottomOf="@+id/etPuerto"
135 app:layout_goneMarginEnd="10dp"
108 tools:listitem="@layout/item_servidores" /> 136 tools:listitem="@layout/item_servidores" />
109 137
110 <Button 138 <Button
app/src/main/res/layout/item_servidores.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 2 <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 android:layout_height="wrap_content" 6 android:layout_height="wrap_content"
7 android:layout_margin="5dp" 7 android:layout_margin="5dp"
8 app:cardCornerRadius="2dp" 8 app:cardCornerRadius="2dp"
9 app:cardElevation="10dp" 9 app:cardElevation="10dp"
10 app:contentPadding="5dp" 10 app:contentPadding="5dp"
11 app:cardPreventCornerOverlap="false"> 11 app:cardPreventCornerOverlap="false">
12 12
13 <androidx.constraintlayout.widget.ConstraintLayout 13 <androidx.constraintlayout.widget.ConstraintLayout
14 android:layout_width="match_parent" 14 android:layout_width="match_parent"
15 android:layout_height="wrap_content"> 15 android:layout_height="wrap_content">
16 16
17 <TextView 17 <TextView
18 android:id="@+id/textView2" 18 android:id="@+id/textView2"
19 android:layout_width="wrap_content" 19 android:layout_width="wrap_content"
20 android:layout_height="wrap_content" 20 android:layout_height="wrap_content"
21 android:layout_marginStart="5dp" 21 android:layout_marginStart="5dp"
22 android:text="Descripción:" 22 android:text="Descripción:"
23 android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Large" 23 android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Large"
24 android:textSize="14sp" 24 android:textSize="14sp"
25 app:layout_constraintEnd_toStartOf="@+id/tvCodigo" 25 app:layout_constraintEnd_toStartOf="@+id/tvCodigo"
26 app:layout_constraintHorizontal_bias="0.01" 26 app:layout_constraintHorizontal_bias="0.01"
27 app:layout_constraintHorizontal_chainStyle="packed" 27 app:layout_constraintHorizontal_chainStyle="packed"
28 app:layout_constraintStart_toStartOf="parent" 28 app:layout_constraintStart_toStartOf="parent"
29 app:layout_constraintTop_toTopOf="parent" /> 29 app:layout_constraintTop_toTopOf="parent" />
30 30
31
32 <TextView 31 <TextView
33 android:id="@+id/tvDescServidor" 32 android:id="@+id/tvDescServidor"
34 android:layout_width="0dp" 33 android:layout_width="0dp"
35 android:layout_height="match_parent" 34 android:layout_height="match_parent"
36 android:layout_marginStart="8dp" 35 android:layout_marginStart="8dp"
37 android:text="Laboratorio Foca 1" 36 android:text="Laboratorio Foca 1"
38 android:textAppearance="@style/TextAppearance.AppCompat.Large" 37 android:textAppearance="@style/TextAppearance.AppCompat.Large"
39 android:textColorHint="@android:color/black" 38 android:textColorHint="@android:color/black"
40 android:textSize="14sp" 39 android:textSize="14sp"
41 android:textStyle="bold" 40 android:textStyle="bold"
42 app:layout_constraintBaseline_toBaselineOf="@+id/textView2" 41 app:layout_constraintBaseline_toBaselineOf="@+id/textView2"
43 app:layout_constraintEnd_toEndOf="parent" 42 app:layout_constraintEnd_toEndOf="parent"
44 app:layout_constraintStart_toEndOf="@+id/textView2" /> 43 app:layout_constraintStart_toEndOf="@+id/textView2" />
45 44
46 <TextView 45 <TextView
47 android:id="@+id/textView85" 46 android:id="@+id/textView85"
48 android:layout_width="wrap_content" 47 android:layout_width="wrap_content"
49 android:layout_height="wrap_content" 48 android:layout_height="wrap_content"
50 android:layout_marginStart="5dp" 49 android:layout_marginStart="5dp"
51 android:layout_marginTop="8dp" 50 android:layout_marginTop="8dp"
52 android:text="Dirección:" 51 android:text="Dirección:"
53 android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Large" 52 android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Large"
54 android:textSize="14sp" 53 android:textSize="14sp"
55 app:layout_constraintHorizontal_chainStyle="packed"
56 app:layout_constraintStart_toStartOf="parent" 54 app:layout_constraintStart_toStartOf="parent"
57 app:layout_constraintEnd_toStartOf="@id/tvDireccionServidor"
58 app:layout_constraintTop_toBottomOf="@id/tvDescServidor" /> 55 app:layout_constraintTop_toBottomOf="@id/tvDescServidor" />
59 56
60 <TextView 57 <TextView
61 android:id="@+id/tvDireccionServidor" 58 android:id="@+id/tvDireccionServidor"
62 android:layout_width="0dp" 59 android:layout_width="wrap_content"
63 android:layout_height="match_parent" 60 android:layout_height="wrap_content"
64 android:layout_marginStart="8dp" 61 android:layout_marginStart="5dp"
65 android:text="http://192.168.0.205:3008" 62 android:text="http://192.168.0.205"
66 android:textAppearance="@style/TextAppearance.AppCompat.Large" 63 android:textAppearance="@style/TextAppearance.AppCompat.Large"
67 android:textColorHint="@android:color/black" 64 android:textColorHint="@android:color/black"
68 android:textSize="14sp" 65 android:textSize="14sp"
69 android:textStyle="bold" 66 android:textStyle="bold"
70 app:layout_constraintBaseline_toBaselineOf="@+id/textView85" 67 app:layout_constraintBaseline_toBaselineOf="@+id/textView85"
71 app:layout_constraintEnd_toEndOf="parent"
72 app:layout_constraintStart_toEndOf="@+id/textView85" /> 68 app:layout_constraintStart_toEndOf="@+id/textView85" />
73 69
70 <TextView
71 android:id="@+id/textView86"
72 android:layout_width="wrap_content"
73 android:layout_height="wrap_content"
74 android:layout_marginTop="8dp"
75 android:layout_marginStart="10dp"
76 android:text="Puerto:"
77 android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Large"
78 android:textSize="14sp"
79 app:layout_constraintHorizontal_chainStyle="packed"
80 app:layout_constraintStart_toEndOf="@+id/tvDireccionServidor"
81 app:layout_constraintTop_toBottomOf="@id/tvDescServidor" />
82
83 <TextView
84 android:id="@+id/tvPuertoServidor"
85 android:layout_width="wrap_content"
86 android:layout_height="wrap_content"
87 android:layout_marginTop="8dp"
88 android:layout_marginStart="5dp"
89 android:text=""
90 android:textAppearance="@style/TextAppearance.AppCompat.Large"
91 android:textColorHint="@android:color/black"
92 android:textSize="14sp"
93 android:textStyle="bold"
94 app:layout_constraintStart_toEndOf="@+id/textView86"
app/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 2
3 <string name="action_settings">Ayuda</string> 3 <string name="action_settings">Ayuda</string>
4 <string name="app_name">DEBO Inventarios</string> 4 <string name="app_name">DEBO Inventarios</string>
5 5
6 <!-- menu--> 6 <!-- menu-->
7 <string name="menuInicio">Principal</string> 7 <string name="menuInicio">Principal</string>
8 <string name="menuNueInv">Nuevo Inventario</string> 8 <string name="menuNueInv">Nuevo Inventario</string>
9 <string name="menuActMae">Importaciones</string> 9 <string name="menuActMae">Importaciones</string>
10 <string name="menuConf">Configuraciones</string> 10 <string name="menuConf">Configuraciones</string>
11 <string name="menuSal">Salir</string> 11 <string name="menuSal">Salir</string>
12 12
13 <!-- Menu header--> 13 <!-- Menu header-->
14 <string name="menuLeyenda">Debo Inventario</string> 14 <string name="menuLeyenda">Debo Inventario</string>
15 15
16 <string name="navigation_drawer_open">Open navigation drawer</string> 16 <string name="navigation_drawer_open">Open navigation drawer</string>
17 <string name="navigation_drawer_close">Close navigation drawer</string> 17 <string name="navigation_drawer_close">Close navigation drawer</string>
18 18
19 <!-- Pantalla de inicio--> 19 <!-- Pantalla de inicio-->
20 <string name="bien">Bienvenido</string> 20 <string name="bien">Bienvenido</string>
21 <string name="debo">DEBO®</string> 21 <string name="debo">DEBO®</string>
22 <string name="inventario">Inventario</string> 22 <string name="inventario">Inventario</string>
23 <string name="todo">TODO</string> 23 <string name="todo">TODO</string>
24 <string name="hello_blank_fragment">Hello blank fragment</string> 24 <string name="hello_blank_fragment">Hello blank fragment</string>
25 25
26 <!-- inventarios dinamicos--> 26 <!-- inventarios dinamicos-->
27 <string name="invDinamicoVenta">Inventarios Dinamicos</string> 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 <!-- ventana emergente--> 30 <!-- ventana emergente-->
31 <string name="adv">Ingrese la cantidad contada</string> 31 <string name="adv">Ingrese la cantidad contada</string>
32 <string name="invVentas">Inventarios Dinamicos de Ventas</string> 32 <string name="invVentas">Inventarios Dinamicos de Ventas</string>
33 <string name="btnCancela">Cancelar</string> 33 <string name="btnCancela">Cancelar</string>
34 34
35 35
36 <!-- Fragment Inventario--> 36 <!-- Fragment Inventario-->
37 <string name="invTitulo">Inventarios Dinámicos</string> 37 <string name="invTitulo">Inventarios Dinámicos</string>
38 <string name="invTituloV">Inventarios de Ventas</string> 38 <string name="invTituloV">Inventarios de Ventas</string>
39 <string name="invTituloD">Inventarios de Depositos</string> 39 <string name="invTituloD">Inventarios de Depositos</string>
40 <string name="invCodigoBarras">Código Barras:</string> 40 <string name="invCodigoBarras">Código Barras:</string>
41 <string name="btnExportarInv">Exportar Inventario</string> 41 <string name="btnExportarInv">Exportar Inventario</string>
42 <string name="btnBorrarInv">Borrar Inventario</string> 42 <string name="btnBorrarInv">Borrar Inventario</string>
43 <string name="ibBusDesc">Busqueda por Descripción</string> 43 <string name="ibBusDesc">Busqueda por Descripción</string>
44 <string name="ibBusCB">Busqueda por C. Barras</string> 44 <string name="ibBusCB">Busqueda por C. Barras</string>
45 <string name="ibBusCO">Busqueda por Código de Origen</string> 45 <string name="ibBusCO">Busqueda por Código de Origen</string>
46 <string name="switch_1">+ 1</string> 46 <string name="switch_1">+ 1</string>
47 47
48 <!-- Fragmento Configuraciones--> 48 <!-- Fragmento Configuraciones-->
49 <string name="tvTituloConf">Configuraciones</string> 49 <string name="tvTituloConf">Configuraciones</string>
50 <string name="tvSeleccioneServidor">Seleccione un Servidor</string> 50 <string name="tvSeleccioneServidor">Seleccione un Servidor</string>
51 <string name="btnValidarServidor">Validar</string> 51 <string name="btnValidarServidor">Validar</string>
52 <string name="btnAgregarServidor">Agregar un nuevo servidor</string> 52 <string name="btnAgregarServidor">Agregar un nuevo servidor</string>
53 <string name="tvUbicacionCarpetas">Ubicación de las carpetas de uso interno</string> 53 <string name="tvUbicacionCarpetas">Ubicación de las carpetas de uso interno</string>
54 <string name="tvTituloArea">Area de Invetnario</string> 54 <string name="tvTituloArea">Area de Invetnario</string>
55 <string name="rbVentas">Inventarios de Ventas</string> 55 <string name="rbVentas">Inventarios de Ventas</string>
56 <string name="rbDeposito">Inventarios de Depositos</string> 56 <string name="rbDeposito">Inventarios de Depositos</string>
57 <string name="tvLosProductos">Los productos no contabilizados en Inventarios</string> 57 <string name="tvLosProductos">Los productos no contabilizados en Inventarios</string>
58 <string name="tvColumnas">Columnas a Visualizar</string> 58 <string name="tvColumnas">Columnas a Visualizar</string>
59 59
60 <string name="rbProInclu">Solo se ajustan los productos incluidos en el conteo.</string> 60 <string name="rbProInclu">Solo se ajustan los productos incluidos en el conteo.</string>
61 <string name="rbProNoInclu">Ajusta productos no incluidos en el conteo con stock en cero.</string> 61 <string name="rbProNoInclu">Ajusta productos no incluidos en el conteo con stock en cero.</string>
62 62
63 <string name="cbMostrarStock">Mostror stock en el sistema al momento de la descarga del maestro.</string> 63 <string name="cbMostrarStock">Mostror stock en el sistema al momento de la descarga del maestro.</string>
64 <string name="cbHabiLectura">Habilitar Lectura de codigo de barras en balanza.</string> 64 <string name="cbHabiLectura">Habilitar Lectura de codigo de barras en balanza.</string>
65 65
66 <string name="tvColumMostrar">Columnas a mostrar en inventario</string> 66 <string name="tvColumMostrar">Columnas a mostrar en inventario</string>
67 67
68 <string name="rbCodigoDebo">Código DEBO</string> 68 <string name="rbCodigoDebo">Código DEBO</string>
69 <string name="rbCodigoOrigen">Código Origen</string> 69 <string name="rbCodigoOrigen">Código Origen</string>
70 <string name="rbCodigoBarras">Código de Barras</string> 70 <string name="rbCodigoBarras">Código de Barras</string>
71 71
72 72
73 <!-- Spinner servidor--> 73 <!-- Spinner servidor-->
74 <string-array name="spinnerServidor"> 74 <string-array name="spinnerServidor">
75 <item>Servidor Laboratorio 1</item> 75 <item>Servidor Laboratorio 1</item>
76 <item>Servidor Laboratorio 2</item> 76 <item>Servidor Laboratorio 2</item>
77 <item>Servidor Laboratorio 3</item> 77 <item>Servidor Laboratorio 3</item>
78 </string-array> 78 </string-array>
79 <string name="leyendaSpinner">Seleccione Servidor Predeterminado</string> 79 <string name="leyendaSpinner">Seleccione Servidor Predeterminado</string>
80 80
81 <string name="cbMostrarExistencia">Existencia</string> 81 <string name="cbMostrarExistencia">Existencia</string>
82 <string name="cbMostrarPrecio">Precio</string> 82 <string name="cbMostrarPrecio">Precio</string>
83 83
84 <string name="btnGuardar">Guardar Cambios</string> 84 <string name="btnGuardar">Guardar Cambios</string>
85 85
86 <!-- fragment Actualizacion de Maestros--> 86 <!-- fragment Actualizacion de Maestros-->
87 <string name="tvActMaestros">Importaciones</string> 87 <string name="tvActMaestros">Importaciones</string>
88 <string name="tvMedio">Seleccione que tipo de importación desea realizar</string> 88 <string name="tvMedio">Seleccione que tipo de importación desea realizar</string>
89 <string name="obPorWifi">Importación de artículos</string> 89 <string name="obPorWifi">Importación de artículos</string>
90 <string name="obViaArchivo">Importación de inventarios</string> 90 <string name="obViaArchivo">Importación de inventarios</string>
91 91
92 <string name="btnConfirmarAct">Confirmar Importación</string> 92 <string name="btnConfirmarAct">Confirmar Importación</string>
93 93
94 <!-- Fragment Save--> 94 <!-- Fragment Save-->
95 <string name="tvConfServi">Configuración de Servidores</string> 95 <string name="tvConfServi">Configuración de Servidores</string>
96 <string name="server">Ingrese la direccion del servidor</string> 96 <string name="server">Ingrese la direccion del servidor</string>
97 <string name="etNomServer">Ingrese una descripción para la conexión</string> 97 <string name="etNomServer">Ingrese una descripción para la conexión</string>
98 <string name="btnGuardarConfServ">Guardar Conexión</string> 98 <string name="btnGuardarConfServ">Guardar Conexión</string>
99 99
100 <!-- Dialog--> 100 <!-- Dialog-->
101 <string name="sTitulo">Producto Buscado</string> 101 <string name="sTitulo">Producto Buscado</string>
102 <string name="btnOk">Aceptar</string> 102 <string name="btnOk">Aceptar</string>
103 <string name="btnCancelar">Cancelar</string> 103 <string name="btnCancelar">Cancelar</string>
104 <string name="sMensaje">¡No se encontro el producto ingresado!</string> 104 <string name="sMensaje">¡No se encontro el producto ingresado!</string>
105 <string name="sMensajeEncontrado">¡Ingrese nueva cantidad!</string> 105 <string name="sMensajeEncontrado">¡Ingrese nueva cantidad!</string>
106 <string name="sTituloNueva">Producto ingresado esta cargado</string> 106 <string name="sTituloNueva">Producto ingresado esta cargado</string>
107 <string name="sCantidadNueva">¡Por favor ingrese la nueva Cantidad!</string> 107 <string name="sCantidadNueva">¡Por favor ingrese la nueva Cantidad!</string>
108 108
109 <string name="sMensajeExportar">¡Confirma que exporta el Inventario!</string> 109 <string name="sMensajeExportar">¡Confirma que exporta el Inventario!</string>
110 <string name="sTituloExportar">Exportación de Inventarios</string> 110 <string name="sTituloExportar">Exportación de Inventarios</string>
111 111
112 <!-- FRAGMENT SERVIDOR--> 112 <!-- FRAGMENT SERVIDOR-->
113 <string name="tvTitutloServer">Alta de Servidores</string> 113 <string name="tvTitutloServer">Alta de Servidores</string>
114 <string name="tvNomServer">Ingrese un nombre para identificar al servidor</string> 114 <string name="tvNomServer">Descripción para identificar al servidor</string>
115 <string name="tvDirServer">Ingrese la dirección del servidor</string> 115 <string name="tvDirServer">Dirección del servidor</string>
116 <string name="btnGuardarServidores">Guardar Servidor</string> 116 <string name="btnGuardarServidores">Guardar Servidor</string>
117 117
118 <string name="tvSeleccion">Toque sobre la operación que desea realizar</string> 118 <string name="tvSeleccion">Toque sobre la operación que desea realizar</string>
119 <string name="rbSumar">Sumar</string> 119 <string name="rbSumar">Sumar</string>
120 <string name="rbRestar">Restar</string> 120 <string name="rbRestar">Restar</string>
121 <string name="rbModificar">Reemplazar</string> 121 <string name="rbModificar">Reemplazar</string>
122 <string name="tvTotal">Cantidad Final</string>tvTotal 122 <string name="tvTotal">Cantidad Final</string>tvTotal
123 <string name="tvResultado">Resultado:</string>tvTotal 123 <string name="tvResultado">Resultado:</string>tvTotal
124 124
125 <string name="large_text"> 125 <string name="large_text">
126 "Material is the metaphor.\n\n" 126 "Material is the metaphor.\n\n"
127 127
128 "A material metaphor is the unifying theory of a rationalized space and a system of motion." 128 "A material metaphor is the unifying theory of a rationalized space and a system of motion."
129 "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " 129 "The material is grounded in tactile reality, inspired by the study of paper and ink, yet "
130 "technologically advanced and open to imagination and magic.\n" 130 "technologically advanced and open to imagination and magic.\n"
131 "Surfaces and edges of the material provide visual cues that are grounded in reality. The " 131 "Surfaces and edges of the material provide visual cues that are grounded in reality. The "
132 "use of familiar tactile attributes helps users quickly understand affordances. Yet the " 132 "use of familiar tactile attributes helps users quickly understand affordances. Yet the "
133 "flexibility of the material creates new affordances that supercede those in the physical " 133 "flexibility of the material creates new affordances that supercede those in the physical "
134 "world, without breaking the rules of physics.\n" 134 "world, without breaking the rules of physics.\n"
135 "The fundamentals of light, surface, and movement are key to conveying how objects move, " 135 "The fundamentals of light, surface, and movement are key to conveying how objects move, "
136 "interact, and exist in space and in relation to each other. Realistic lighting shows " 136 "interact, and exist in space and in relation to each other. Realistic lighting shows "
137 "seams, divides space, and indicates moving parts.\n\n" 137 "seams, divides space, and indicates moving parts.\n\n"
138 138
139 "Bold, graphic, intentional.\n\n" 139 "Bold, graphic, intentional.\n\n"
140 140
141 "The foundational elements of print based design typography, grids, space, scale, color, " 141 "The foundational elements of print based design typography, grids, space, scale, color, "
142 "and use of imagery guide visual treatments. These elements do far more than please the " 142 "and use of imagery guide visual treatments. These elements do far more than please the "
143 "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " 143 "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge "
144 "imagery, large scale typography, and intentional white space create a bold and graphic " 144 "imagery, large scale typography, and intentional white space create a bold and graphic "
145 "interface that immerse the user in the experience.\n" 145 "interface that immerse the user in the experience.\n"
146 "An emphasis on user actions makes core functionality immediately apparent and provides " 146 "An emphasis on user actions makes core functionality immediately apparent and provides "
147 "waypoints for the user.\n\n" 147 "waypoints for the user.\n\n"
148 148
149 "Motion provides meaning.\n\n" 149 "Motion provides meaning.\n\n"
150 150
151 "Motion respects and reinforces the user as the prime mover. Primary user actions are " 151 "Motion respects and reinforces the user as the prime mover. Primary user actions are "
152 "inflection points that initiate motion, transforming the whole design.\n" 152 "inflection points that initiate motion, transforming the whole design.\n"
153 "All action takes place in a single environment. Objects are presented to the user without " 153 "All action takes place in a single environment. Objects are presented to the user without "
154 "breaking the continuity of experience even as they transform and reorganize.\n" 154 "breaking the continuity of experience even as they transform and reorganize.\n"
155 "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " 155 "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. "
156 "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" 156 "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n"
157 157
158 "3D world.\n\n" 158 "3D world.\n\n"
159 159
160 "The material environment is a 3D space, which means all objects have x, y, and z " 160 "The material environment is a 3D space, which means all objects have x, y, and z "
161 "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " 161 "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the "
162 "positive z-axis extending towards the viewer. Every sheet of material occupies a single " 162 "positive z-axis extending towards the viewer. Every sheet of material occupies a single "
163 "position along the z-axis and has a standard 1dp thickness.\n" 163 "position along the z-axis and has a standard 1dp thickness.\n"
164 "On the web, the z-axis is used for layering and not for perspective. The 3D world is " 164 "On the web, the z-axis is used for layering and not for perspective. The 3D world is "
165 "emulated by manipulating the y-axis.\n\n" 165 "emulated by manipulating the y-axis.\n\n"
166 166
167 "Light and shadow.\n\n" 167 "Light and shadow.\n\n"
168 168
169 "Within the material environment, virtual lights illuminate the scene. Key lights create " 169 "Within the material environment, virtual lights illuminate the scene. Key lights create "
170 "directional shadows, while ambient light creates soft shadows from all angles.\n" 170 "directional shadows, while ambient light creates soft shadows from all angles.\n"
171 "Shadows in the material environment are cast by these two light sources. In Android " 171 "Shadows in the material environment are cast by these two light sources. In Android "
172 "development, shadows occur when light sources are blocked by sheets of material at " 172 "development, shadows occur when light sources are blocked by sheets of material at "
173 "various positions along the z-axis. On the web, shadows are depicted by manipulating the " 173 "various positions along the z-axis. On the web, shadows are depicted by manipulating the "
174 "y-axis only. The following example shows the card with a height of 6dp.\n\n" 174 "y-axis only. The following example shows the card with a height of 6dp.\n\n"
175 175
176 "Resting elevation.\n\n" 176 "Resting elevation.\n\n"
177 177
178 "All material objects, regardless of size, have a resting elevation, or default elevation " 178 "All material objects, regardless of size, have a resting elevation, or default elevation "
179 "that does not change. If an object changes elevation, it should return to its resting " 179 "that does not change. If an object changes elevation, it should return to its resting "
180 "elevation as soon as possible.\n\n" 180 "elevation as soon as possible.\n\n"
181 181
182 "Component elevations.\n\n" 182 "Component elevations.\n\n"
183 183
184 "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " 184 "The resting elevation for a component type is consistent across apps (e.g., FAB elevation "
185 "does not vary from 6dp in one app to 16dp in another app).\n" 185 "does not vary from 6dp in one app to 16dp in another app).\n"
186 "Components may have different resting elevations across platforms, depending on the depth " 186 "Components may have different resting elevations across platforms, depending on the depth "
187 "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" 187 "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n"
188 188
189 "Responsive elevation and dynamic elevation offsets.\n\n" 189 "Responsive elevation and dynamic elevation offsets.\n\n"
190 190
191 "Some component types have responsive elevation, meaning they change elevation in response " 191 "Some component types have responsive elevation, meaning they change elevation in response "
192 "to user input (e.g., normal, focused, and pressed) or system events. These elevation " 192 "to user input (e.g., normal, focused, and pressed) or system events. These elevation "
193 "changes are consistently implemented using dynamic elevation offsets.\n" 193 "changes are consistently implemented using dynamic elevation offsets.\n"
194 "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " 194 "Dynamic elevation offsets are the goal elevation that a component moves towards, relative "
195 "to the component’s resting state. They ensure that elevation changes are consistent " 195 "to the component’s resting state. They ensure that elevation changes are consistent "
196 "across actions and component types. For example, all components that lift on press have " 196 "across actions and component types. For example, all components that lift on press have "
197 "the same elevation change relative to their resting elevation.\n" 197 "the same elevation change relative to their resting elevation.\n"
198 "Once the input event is completed or cancelled, the component will return to its resting " 198 "Once the input event is completed or cancelled, the component will return to its resting "
199 "elevation.\n\n" 199 "elevation.\n\n"
200 200
201 "Avoiding elevation interference.\n\n" 201 "Avoiding elevation interference.\n\n"
202 202
203 "Components with responsive elevations may encounter other components as they move between " 203 "Components with responsive elevations may encounter other components as they move between "
204 "their resting elevations and dynamic elevation offsets. Because material cannot pass " 204 "their resting elevations and dynamic elevation offsets. Because material cannot pass "
205 "through other material, components avoid interfering with one another any number of ways, " 205 "through other material, components avoid interfering with one another any number of ways, "
206 "whether on a per component basis or using the entire app layout.\n" 206 "whether on a per component basis or using the entire app layout.\n"
207 "On a component level, components can move or be removed before they cause interference. " 207 "On a component level, components can move or be removed before they cause interference. "
208 "For example, a floating action button (FAB) can disappear or move off screen before a " 208 "For example, a floating action button (FAB) can disappear or move off screen before a "
209 "user picks up a card, or it can move if a snackbar appears.\n" 209 "user picks up a card, or it can move if a snackbar appears.\n"
210 "On the layout level, design your app layout to minimize opportunities for interference. " 210 "On the layout level, design your app layout to minimize opportunities for interference. "
211 "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " 211 "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
212 "when a user tries to pick up one of cards.\n\n" 212 "when a user tries to pick up one of cards.\n\n"
213 </string> 213 </string>
214 </resources> 214 </resources>