Commit c1c9b23894b1638b33e222f229a8e2d5f8366689
1 parent
ea6d4ed726
Exists in
master
06092020 2207
Showing
24 changed files
with
534 additions
and
457 deletions
Show diff stats
app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | apply plugin: 'kotlin-android' | 2 | apply plugin: 'kotlin-android' |
3 | apply plugin: 'kotlin-android-extensions' | 3 | apply plugin: 'kotlin-android-extensions' |
4 | apply plugin: 'kotlin-kapt' | 4 | |
5 | 5 | ||
6 | android { | 6 | android { |
7 | compileSdkVersion 30 | 7 | compileSdkVersion 30 |
8 | buildToolsVersion "29.0.3" | 8 | buildToolsVersion "29.0.3" |
9 | 9 | ||
10 | defaultConfig { | 10 | defaultConfig { |
11 | applicationId "com.focasoftware.deboinventariov20" | 11 | applicationId "com.focasoftware.deboinventariov20" |
12 | minSdkVersion 26 | 12 | minSdkVersion 26 |
13 | targetSdkVersion 30 | 13 | targetSdkVersion 30 |
14 | versionCode 1 | 14 | versionCode 1 |
15 | versionName "1.0" | 15 | versionName "1.0" |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
17 | javaCompileOptions { | 17 | javaCompileOptions { |
18 | annotationProcessorOptions { | 18 | annotationProcessorOptions { |
19 | arguments = ["room.incremental":"true"] | 19 | arguments = ["room.incremental":"true"] |
20 | } | 20 | } |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | buildTypes { | 24 | buildTypes { |
25 | release { | 25 | release { |
26 | minifyEnabled false | 26 | minifyEnabled false |
27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
28 | } | 28 | } |
29 | } | 29 | } |
30 | compileOptions { | 30 | compileOptions { |
31 | sourceCompatibility JavaVersion.VERSION_1_8 | 31 | sourceCompatibility JavaVersion.VERSION_1_8 |
32 | targetCompatibility JavaVersion.VERSION_1_8 | 32 | targetCompatibility JavaVersion.VERSION_1_8 |
33 | 33 | ||
34 | } | 34 | } |
35 | kotlinOptions { | 35 | kotlinOptions { |
36 | jvmTarget = '1.8' | 36 | jvmTarget = '1.8' |
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | dependencies { | 40 | dependencies { |
41 | implementation fileTree(dir: "libs", include: ["*.jar"]) | 41 | implementation fileTree(dir: "libs", include: ["*.jar"]) |
42 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
43 | implementation 'androidx.core:core-ktx:1.3.1' | 43 | implementation 'androidx.core:core-ktx:1.3.1' |
44 | implementation 'androidx.appcompat:appcompat:1.2.0' | 44 | implementation 'androidx.appcompat:appcompat:1.2.0' |
45 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' | 45 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
46 | implementation 'com.google.android.material:material:1.2.0' | 46 | implementation 'com.google.android.material:material:1.2.0' |
47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0' | 47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' |
48 | implementation 'androidx.navigation:navigation-fragment:2.3.0' | 48 | implementation 'androidx.navigation:navigation-fragment:2.3.0' |
49 | implementation 'androidx.navigation:navigation-ui:2.3.0' | 49 | implementation 'androidx.navigation:navigation-ui:2.3.0' |
50 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | 50 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' |
51 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' | 51 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' |
52 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' | 52 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' |
53 | implementation 'androidx.recyclerview:recyclerview:1.1.0' | 53 | implementation 'androidx.recyclerview:recyclerview:1.1.0' |
54 | testImplementation 'junit:junit:4.13' | 54 | testImplementation 'junit:junit:4.13' |
55 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' | 55 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' |
56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' |
57 | 57 | ||
58 | 58 | ||
59 | //Room | 59 | //Room |
60 | implementation 'androidx.room:room-ktx:2.2.5' | 60 | implementation 'androidx.room:room-ktx:2.2.5' |
61 | implementation "androidx.room:room-runtime:2.2.5" | 61 | implementation "androidx.room:room-runtime:2.2.5" |
62 | kapt "androidx.room:room-compiler:2.2.5" | 62 | annotationProcessor 'androidx.room:room-compiler:2.2.5' |
63 | 63 | ||
64 | //Retrofit | 64 | //Retrofit |
65 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' | 65 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' |
66 | implementation 'com.google.code.gson:gson:2.8.6' | 66 | implementation 'com.google.code.gson:gson:2.8.6' |
67 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | 67 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' |
68 | implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1' | 68 | implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1' |
69 | 69 | ||
70 | //Gson library | 70 | //Gson library |
71 | implementation "com.google.code.gson:gson:2.8.6" | 71 | implementation "com.google.code.gson:gson:2.8.6" |
72 | annotationProcessor 'androidx.room:room-compiler:2.2.5' | ||
73 | 72 | ||
73 | // ViewModel and LiveData | ||
74 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | ||
75 | annotationProcessor 'androidx.lifecycle:lifecycle-common-java8:2.2.0' |
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.* | 3 | import androidx.room.* |
4 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART | 4 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART |
5 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B | 5 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B |
6 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H | 6 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H |
7 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV | 7 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV |
8 | import com.focasoftware.deboinventariov20.Model.* | 8 | import com.focasoftware.deboinventariov20.Model.* |
9 | import java.util.ArrayList | 9 | import java.util.ArrayList |
10 | 10 | ||
11 | @Dao | 11 | @Dao |
12 | interface ArticulosDAO { | 12 | interface ArticulosDAO { |
13 | 13 | ||
14 | // TABLA ARTICULOS | 14 | // TABLA ARTICULOS |
15 | @Insert(onConflict = OnConflictStrategy.REPLACE) | 15 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
16 | suspend fun insertArticulos(articulos: Articles?) | 16 | suspend fun insertArticulos(articulos: Articles?) |
17 | 17 | ||
18 | @Query("SELECT * FROM $TABLA_ART ORDER BY DES DESC") | 18 | @Query("SELECT * FROM $TABLA_ART ORDER BY DES DESC") |
19 | suspend fun findAllArticulos(): List<Articles> | 19 | suspend fun findAllArticulos(): List<Articles> |
20 | 20 | ||
21 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%' GROUP BY DES ORDER BY DES") | 21 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%' GROUP BY DES ORDER BY DES") |
22 | suspend fun findArticuloByDesc(description: String?, dep: Int): List<Articles> | 22 | suspend fun findArticuloByDesc(description: String?, dep: Int): List<Articles> |
23 | 23 | ||
24 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CB LIKE :codBarra") | 24 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CB LIKE :codBarra") |
25 | suspend fun findArticuloByCodBar(codBarra: String?, dep: Int): Articles? | 25 | suspend fun findArticuloByCodBar(codBarra: String?, dep: Int): Articles? |
26 | 26 | ||
27 | @Query("DELETE FROM $TABLA_ART") | 27 | @Query("DELETE FROM $TABLA_ART") |
28 | suspend fun deleteAllArticulos() | 28 | suspend fun deleteAllArticulos() |
29 | 29 | ||
30 | @Query("SELECT * FROM $TABLA_ART WHERE SEC=:sector AND COD=:codigo") | 30 | @Query("SELECT * FROM $TABLA_ART WHERE SEC=:sector AND COD=:codigo") |
31 | suspend fun fetchArticuloByCodSec(sector: String?, codigo: String?): Articles? | 31 | suspend fun fetchArticuloByCodSec(sector: String?, codigo: String?): Articles? |
32 | } | 32 | } |
33 | 33 | ||
34 | @Dao | 34 | @Dao |
35 | interface InvHeadDAO { | 35 | interface InvHeadDAO { |
36 | @Insert() | 36 | @Insert() |
37 | suspend fun insertInvHead(invHead: InvHead?) | 37 | suspend fun insertInvHead(invHead: InvHead?) |
38 | 38 | ||
39 | @Query("SELECT INV_NUM FROM $TABLA_INV_H ORDER BY INV_NUM DESC") | 39 | @Query("SELECT INV_NUM FROM $TABLA_INV_H ORDER BY INV_NUM DESC") |
40 | suspend fun findLastInv(): Int | 40 | suspend fun findLastInv(): Int |
41 | 41 | ||
42 | @Query("DELETE FROM $TABLA_INV_H") | 42 | @Query("DELETE FROM $TABLA_INV_H") |
43 | suspend fun deleteAllArticulos() | 43 | suspend fun deleteAllArticulos() |
44 | 44 | ||
45 | @Query("DELETE FROM $TABLA_INV_H WHERE INV_NUM=:inven") | 45 | @Query("DELETE FROM $TABLA_INV_H WHERE INV_NUM=:inven") |
46 | suspend fun deleteinvHead(inven: Int) | 46 | suspend fun deleteinvHead(inven: Int) |
47 | 47 | ||
48 | @Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI") | 48 | @Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI") |
49 | suspend fun fetchAllInvHead(): List<InvHead> | 49 | suspend fun fetchAllInvHead(): List<InvHead> |
50 | |||
51 | @Query("UPDATE $TABLA_INV_H SET INV_PRODCONT=:cant WHERE INV_NUM=:inven") | ||
52 | suspend fun UpdateInvBody(cant: Float, inven: Int) | ||
50 | } | 53 | } |
51 | 54 | ||
52 | @Dao | 55 | @Dao |
53 | interface InvBodyDAO { | 56 | interface InvBodyDAO { |
54 | @Insert() | 57 | @Insert() |
55 | suspend fun insertInvBody(invBody: InvBody?) | 58 | suspend fun insertInvBody(invBody: InvBody?) |
56 | 59 | ||
57 | @Query("DELETE FROM $TABLA_INV_B") | 60 | @Query("DELETE FROM $TABLA_INV_B") |
58 | suspend fun deleteAllInvBody() | 61 | suspend fun deleteAllInvBody() |
59 | 62 | ||
60 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven") | 63 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven") |
61 | suspend fun deleteInvBody(inven: Int) | 64 | suspend fun deleteInvBody(inven: Int) |
62 | 65 | ||
63 | @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod") | 66 | @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod") |
64 | suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) | 67 | suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) |
65 | 68 | ||
66 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") | 69 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") |
67 | suspend fun fetchAllInvBody(inven:Int): List<InvBody> | 70 | suspend fun fetchAllInvBody(inven:Int): List<InvBody> |
68 | 71 | ||
69 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") | 72 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") |
70 | suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody | 73 | suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody |
71 | 74 | ||
72 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") | 75 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") |
73 | suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int | 76 | suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int |
74 | } | 77 | } |
75 | @Dao | 78 | @Dao |
76 | interface ServeInvDao { | 79 | interface ServeInvDao { |
77 | @Insert(onConflict = OnConflictStrategy.REPLACE) | 80 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
78 | fun insertServer(servidor: ServeInv) | 81 | fun insertServer(servidor: ServeInv) |
79 | 82 | ||
80 | @Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM") | 83 | @Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM") |
81 | suspend fun fetchAllServers(): List<ServeInv> | 84 | suspend fun fetchAllServers(): List<ServeInv> |
82 | 85 | ||
83 | @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") | 86 | @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") |
84 | suspend fun deleteServer(description: String, dir: String) | 87 | suspend fun deleteServer(description: String, dir: String) |
85 | 88 | ||
86 | @Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC") | 89 | @Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC") |
87 | suspend fun findLastServer(): Int | 90 | suspend fun findLastServer(): Int |
88 | 91 | ||
89 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0") | 92 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0") |
90 | suspend fun UpdateServerPreInZero() | 93 | suspend fun UpdateServerPreInZero() |
91 | 94 | ||
92 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir") | 95 | @Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_NUM = :numero") |
93 | suspend fun UpdateServerPre(description: String, dir: String) | 96 | suspend fun UpdateServerPre(numero: Int) |
94 | 97 | ||
95 | @Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE =:sOne") | 98 | @Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE= 1") |
96 | suspend fun fetchServerPreOne(sOne: String): ServeInv | 99 | suspend fun fetchServerPreOne(): ServeInv |
97 | } | 100 | } |
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.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART | 6 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_ART |
7 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B | 7 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_B |
8 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H | 8 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_INV_H |
9 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.Constans.Companion.TABLA_SERV_INV | 9 | import com.focasoftware.deboinventario.ui.actualizacionMaestros.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 | 26 | ||
27 | @Entity(tableName = TABLA_ART) | 27 | @Entity(tableName = TABLA_ART) |
28 | data class Articles(@ColumnInfo(name = "SEC") var sector: String?, | 28 | data class Articles(@ColumnInfo(name = "SEC") var sector: String?, |
29 | @ColumnInfo(name = "COD") var codigo: String?, | 29 | @ColumnInfo(name = "COD") var codigo: String?, |
30 | @ColumnInfo(name = "DES") var descripcion: String?, | 30 | @ColumnInfo(name = "DES") var descripcion: String?, |
31 | @ColumnInfo(name = "CB") var codBar: String?, | 31 | @ColumnInfo(name = "CB") var codBar: String?, |
32 | @ColumnInfo(name = "CBC") var codOrigen: String?, | 32 | @ColumnInfo(name = "CBC") var codOrigen: String?, |
33 | @ColumnInfo(name = "PRE_VTA") var precio: String?, | 33 | @ColumnInfo(name = "PRE_VTA") var precio: String?, |
34 | @ColumnInfo(name = "PRE_COS") var costo: String?, | 34 | @ColumnInfo(name = "PRE_COS") var costo: String?, |
35 | @ColumnInfo(name = "EV") var exiVenta: String?, | 35 | @ColumnInfo(name = "EV") var exiVenta: String?, |
36 | @ColumnInfo(name = "ED") var exiDeposito: String?, | 36 | @ColumnInfo(name = "ED") var exiDeposito: String?, |
37 | @ColumnInfo(name = "DE") var de: String?, | 37 | @ColumnInfo(name = "DE") var de: String?, |
38 | @ColumnInfo(name = "BAL") var balanza: Int?, | 38 | @ColumnInfo(name = "BAL") var balanza: Int?, |
39 | @ColumnInfo(name = "DEPSN") var depSn: Int?, | 39 | @ColumnInfo(name = "DEPSN") var depSn: Int?, |
40 | @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable { | 40 | @ColumnInfo(name = "FOTO") var imagen: String?) : Serializable { |
41 | @PrimaryKey(autoGenerate = true) | 41 | @PrimaryKey(autoGenerate = true) |
42 | @ColumnInfo(name = "id") | 42 | @ColumnInfo(name = "id") |
43 | var id: Long = 0 | 43 | var id: Long = 0 |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | @Entity(tableName = TABLA_INV_H) | 47 | @Entity(tableName = TABLA_INV_H) |
48 | data class InvHead(@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "INV_NUM") var invNum: Int, | 48 | data class InvHead(@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "INV_NUM") var invNum: Int, |
49 | @ColumnInfo(name = "INV_DESC") var descripcion: String?, | 49 | @ColumnInfo(name = "INV_DESC") var descripcion: String?, |
50 | @ColumnInfo(name = "ESTADO") var estado: Int?, | 50 | @ColumnInfo(name = "ESTADO") var estado: Int?, |
51 | @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, | 51 | @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, |
52 | @ColumnInfo(name = "INV_FEF") var fechaFinal: String?, | 52 | @ColumnInfo(name = "INV_FEF") var fechaFinal: String?, |
53 | // productos contados en el inventario | 53 | // productos contados en el inventario |
54 | @ColumnInfo(name = "INV_PRODCONT") var prodContados: Long?, | 54 | @ColumnInfo(name = "INV_PRODCONT") var prodContados: Long?, |
55 | @ColumnInfo(name = "INV_LUG") var lugar: Int?, | 55 | @ColumnInfo(name = "INV_LUG") var lugar: Int?, |
56 | // Solo se ajustan los productos incluidos en el conteo=0 | 56 | // Solo se ajustan los productos incluidos en el conteo=0 |
57 | // Ajusta productos no incluidos en el conteo con stock en cero=1 | 57 | // Ajusta productos no incluidos en el conteo con stock en cero=1 |
58 | @ColumnInfo(name = "PRO_NO_CONTA") var stDesc: Int?, | 58 | @ColumnInfo(name = "PRO_NO_CONTA") var stDesc: Int?, |
59 | // Mostror stock en el sistema al momento de la descarga del maestro. | 59 | // Mostror stock en el sistema al momento de la descarga del maestro. |
60 | @ColumnInfo(name = "MOSTRAR_STOCK") var proNoCont: Int?) | 60 | @ColumnInfo(name = "MOSTRAR_STOCK") var proNoCont: Int?) |
61 | 61 | ||
62 | 62 | ||
63 | @Entity(tableName = TABLA_INV_B) | 63 | @Entity(tableName = TABLA_INV_B) |
64 | data class InvBody(@ColumnInfo(name = "INV_NUM") var invNum: Int, | 64 | data class InvBody(@ColumnInfo(name = "INV_NUM") var invNum: Int, |
65 | @ColumnInfo(name = "SEC") var sector: String?, | 65 | @ColumnInfo(name = "SEC") var sector: String?, |
66 | @ColumnInfo(name = "COD") var codigo: String?, | 66 | @ColumnInfo(name = "COD") var codigo: String?, |
67 | @ColumnInfo(name = "DES") var descripcion: String?, | 67 | @ColumnInfo(name = "DES") var descripcion: String?, |
68 | @ColumnInfo(name = "CANT") var cantTomada: String?, | 68 | @ColumnInfo(name = "CANT") var cantTomada: String?, |
69 | @ColumnInfo(name = "CB") var codBar: String?, | 69 | @ColumnInfo(name = "CB") var codBar: String?, |
70 | @ColumnInfo(name = "CBC") var codOrigen: String?, | 70 | @ColumnInfo(name = "CBC") var codOrigen: String?, |
71 | @ColumnInfo(name = "PRE_VTA") var precio: String?, | 71 | @ColumnInfo(name = "PRE_VTA") var precio: String?, |
72 | @ColumnInfo(name = "PRE_COS") var costo: String?, | 72 | @ColumnInfo(name = "PRE_COS") var costo: String?, |
73 | @ColumnInfo(name = "BAL") var balanza: Int?, | 73 | @ColumnInfo(name = "BAL") var balanza: Int?, |
74 | @ColumnInfo(name = "DSN") var depSn: Int?, | 74 | @ColumnInfo(name = "DSN") var depSn: Int?, |
75 | @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, | 75 | @ColumnInfo(name = "INV_FEI") var fechaInicio: String?, |
76 | @ColumnInfo(name = "INV_FEF") var fechaFinal: String?) : Serializable { | 76 | @ColumnInfo(name = "INV_FEF") var fechaFinal: String?) : Serializable { |
77 | @PrimaryKey(autoGenerate = true) | 77 | @PrimaryKey(autoGenerate = true) |
78 | @ColumnInfo(name = "id") | 78 | @ColumnInfo(name = "id") |
79 | var id: Long = 0 | 79 | var id: Long = 0 |
80 | } | 80 | } |
81 | 81 | ||
82 | @Entity(tableName = TABLA_SERV_INV) | 82 | @Entity(tableName = TABLA_SERV_INV) |
83 | data class ServeInv( | 83 | data class ServeInv( |
84 | @ColumnInfo(name = "SER_DESC") var descripcion: String?, | 84 | @ColumnInfo(name = "SER_DESC") var descripcion: String?, |
85 | @ColumnInfo(name = "SER_DIR") var direccion: String?, | 85 | @ColumnInfo(name = "SER_DIR") var direccion: String?, |
86 | @ColumnInfo(name = "SER_PRE") var predeterminado: String?): | 86 | @ColumnInfo(name = "SER_PRE") var predeterminado: Int?): |
87 | Serializable { @PrimaryKey(autoGenerate = true) | 87 | Serializable { @PrimaryKey(autoGenerate = true) |
88 | @ColumnInfo(name = "SER_NUM") | 88 | @ColumnInfo(name = "SER_NUM") |
89 | var servNum: Int=0 | 89 | var servNum: Int=0 |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | 93 |
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 androidx.fragment.app.FragmentActivity | ||
10 | import androidx.lifecycle.lifecycleScope | ||
9 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 11 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
10 | import com.focasoftware.deboinventariov20.Model.Articles | 12 | import com.focasoftware.deboinventariov20.Model.* |
11 | import com.focasoftware.deboinventariov20.Model.Productos | ||
12 | import com.focasoftware.deboinventariov20.Model.ProductosService | ||
13 | import com.focasoftware.deboinventariov20.Model.ServeInv | ||
14 | import com.focasoftware.deboinventariov20.R | 13 | import com.focasoftware.deboinventariov20.R |
15 | import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment | 14 | import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment |
16 | import kotlinx.android.synthetic.main.fragment_actua_maestros.* | 15 | import kotlinx.android.synthetic.main.fragment_actua_maestros.* |
17 | import kotlinx.coroutines.* | 16 | import kotlinx.coroutines.* |
18 | 17 | ||
19 | var BASE_URL ="" | 18 | public var BASE_URL ="" |
20 | class ActuaMaestrosFragment : Fragment() { | 19 | class ActuaMaestrosFragment : Fragment() { |
21 | 20 | ||
22 | var job: Job? = null | 21 | var job: Job? = null |
23 | 22 | ||
24 | 23 | ||
25 | override fun onCreate(savedInstanceState: Bundle?) { | 24 | override fun onCreate(savedInstanceState: Bundle?) { |
26 | super.onCreate(savedInstanceState) | 25 | super.onCreate(savedInstanceState) |
27 | // GlobalScope.launch(Dispatchers.Main) { | 26 | // GlobalScope.launch(Dispatchers.Main) { |
28 | // | 27 | // val invbody = fetchServerPreOne() |
29 | // BASE_URL = fetchServerPre().direccion.toString() | 28 | //BASE_URL= invbody!!.direccion.toString() |
30 | // } | 29 | BASE_URL="http://10.0.2.2:3000/" |
31 | BASE_URL="http://10.0.2.2:3000/" | 30 | // } |
32 | // mostrarArticulos() | 31 | // mostrarArticulos() |
33 | } | 32 | } |
34 | 33 | ||
35 | suspend fun fetchServerPre(): ServeInv { | 34 | private suspend fun fetchServerPreOne(): ServeInv? { |
36 | var busqueda: ServeInv | ||
37 | return GlobalScope.async(Dispatchers.IO) { | 35 | return GlobalScope.async(Dispatchers.IO) { |
38 | busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchServerPreOne("1") | 36 | return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchServerPreOne() |
39 | return@async busqueda | ||
40 | }.await() | 37 | }.await() |
41 | } | 38 | } |
42 | 39 | ||
43 | // return "http://10.0.2.2:3000/" | 40 | // return "http://10.0.2.2:3000/" |
44 | // } | 41 | // } |
45 | 42 | ||
46 | 43 | ||
47 | override fun onCreateView( | 44 | override fun onCreateView( |
48 | inflater: LayoutInflater, container: ViewGroup?, | 45 | inflater: LayoutInflater, container: ViewGroup?, |
49 | savedInstanceState: Bundle? | 46 | savedInstanceState: Bundle? |
50 | ): View? { | 47 | ): View? { |
51 | // Inflate the layout for this fragment | 48 | // Inflate the layout for this fragment |
52 | val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false) | 49 | val v = inflater.inflate(R.layout.fragment_actua_maestros, container, false) |
53 | val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) | 50 | val bConfirmarAct = v.findViewById<Button>(R.id.btnConfirmarAct) |
54 | bConfirmarAct.setOnClickListener { | 51 | bConfirmarAct.setOnClickListener { |
55 | loading_view.visibility = View.VISIBLE | 52 | loading_view.visibility = View.VISIBLE |
56 | countriesList.text = "Obteniendo Maestros de artículos, aguarde por favor." | 53 | countriesList.text = "Obteniendo Maestros de artículos, aguarde por favor." |
57 | obtenerArticulos() | 54 | obtenerArticulos() |
58 | } | 55 | } |
59 | return v | 56 | return v |
60 | } | 57 | } |
61 | 58 | ||
62 | 59 | ||
63 | private fun obtenerArticulos() { | 60 | private fun obtenerArticulos() { |
64 | 61 | ||
65 | val productosService = ProductosService.getProductosService() | 62 | val productosService = ProductosService.getProductosService() |
66 | var index: Long = 1 | 63 | var index: Long = 1 |
67 | job = CoroutineScope(Dispatchers.IO).launch { | 64 | job = CoroutineScope(Dispatchers.IO).launch { |
68 | AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | 65 | AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! |
69 | .deleteAllArticulos() | 66 | .deleteAllArticulos() |
70 | val response = productosService.getProductos() | 67 | val response = productosService.getProductos() |
71 | if (response.isSuccessful) { | 68 | if (response.isSuccessful) { |
72 | for (pro in response.body()!!) { | 69 | for (pro in response.body()!!) { |
73 | val artiAcargar = Articles( | 70 | val artiAcargar = Articles( |
74 | pro.sector, | 71 | pro.sector, |
75 | pro.codigo, | 72 | pro.codigo, |
76 | pro.descripcion, | 73 | pro.descripcion, |
77 | pro.codBar, | 74 | pro.codBar, |
78 | pro.codOrigen, | 75 | pro.codOrigen, |
79 | pro.precio, | 76 | pro.precio, |
80 | pro.costo, | 77 | pro.costo, |
81 | pro.exiVenta, | 78 | pro.exiVenta, |
82 | pro.exiDeposito, | 79 | pro.exiDeposito, |
83 | pro.de, | 80 | pro.de, |
84 | pro.balanza, | 81 | pro.balanza, |
85 | pro.depSn, | 82 | pro.depSn, |
86 | pro.imagen | 83 | pro.imagen |
87 | ) | 84 | ) |
88 | index += index | 85 | index += index |
89 | 86 | ||
90 | AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | 87 | AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! |
91 | .insertArticulos(artiAcargar) | 88 | .insertArticulos(artiAcargar) |
92 | } | 89 | } |
93 | withContext(Dispatchers.Main) { | 90 | withContext(Dispatchers.Main) { |
94 | countriesList.visibility = View.VISIBLE | 91 | countriesList.visibility = View.VISIBLE |
95 | countriesList.text = "¡Datos Importados Correctamente!" | 92 | countriesList.text = "¡Datos Importados Correctamente!" |
96 | loading_view.visibility = View.GONE | 93 | loading_view.visibility = View.GONE |
97 | } | 94 | } |
98 | // | 95 | // |
99 | } else { | 96 | } else { |
100 | countriesList.text = "Error: ${response.message()}" | 97 | countriesList.text = "Error: ${response.message()}" |
101 | } | 98 | } |
102 | } | 99 | } |
103 | 100 | ||
104 | // withContext(Dispatchers.Main) { | 101 | // withContext(Dispatchers.Main) { |
105 | // if (response.isSuccessful) { | 102 | // if (response.isSuccessful) { |
106 | // val call = WebService | 103 | // val call = WebService |
107 | // .instance | 104 | // .instance |
108 | // ?.createService(WebServiceApi::class.java) | 105 | // ?.createService(WebServiceApi::class.java) |
109 | // ?.articulos | 106 | // ?.articulos |
110 | // call?.enqueue(object : Callback<List<productos?>?> { | 107 | // call?.enqueue(object : Callback<List<productos?>?> { |
111 | // override fun onResponse( | 108 | // override fun onResponse( |
112 | // call: Call<List<productos?>?>, | 109 | // call: Call<List<productos?>?>, |
113 | // response: Response<List<productos?>?> | 110 | // response: Response<List<productos?>?> |
114 | // ) { | 111 | // ) { |
115 | // if (response.code() == 200) { | 112 | // if (response.code() == 200) { |
116 | // for (i in response.body()!!.indices) { | 113 | // for (i in response.body()!!.indices) { |
117 | // //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i]) | 114 | // //AppDb.getAppDb(requireActivity())!!.ArticulosDAO()?.insertArticulos(response.body()!![i]) |
118 | // cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "") | 115 | // cargarArticulos(2, 500, "sfas", "66666","2,2", "2,2", false, false, "") |
119 | //// Log.d( | 116 | //// Log.d( |
120 | //// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector | 117 | //// "TAG1", "Nombre Curso: " + response.body()!![i]?.sector |
121 | //// + "Codigo Profesor: " + response.body()!![i]?.descripcion | 118 | //// + "Codigo Profesor: " + response.body()!![i]?.descripcion |
122 | //// ) | 119 | //// ) |
123 | // mostrarArticulos() | 120 | // mostrarArticulos() |
124 | // } | 121 | // } |
125 | // } else if (response.code() == 404) { | 122 | // } else if (response.code() == 404) { |
126 | // Log.d("TAG1", "No hay cursos") | 123 | // Log.d("TAG1", "No hay cursos") |
127 | // } | 124 | // } |
128 | // | 125 | // |
129 | // } | 126 | // } |
130 | // | 127 | // |
131 | // override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {} | 128 | // override fun onFailure(call: Call<List<productos?>?>, t: Throwable) {} |
132 | // }) | 129 | // }) |
133 | } | 130 | } |
134 | 131 | ||
135 | fun mostrarArticulos() { | 132 | fun mostrarArticulos() { |
136 | val Job = GlobalScope.launch { | 133 | val Job = GlobalScope.launch { |
137 | var listArticulos: List<Articles>? = null | 134 | var listArticulos: List<Articles>? = null |
138 | var temp: String = "" | 135 | var temp: String = "" |
139 | listArticulos = | 136 | listArticulos = |
140 | AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos() | 137 | AppDb.getAppDb(requireActivity())?.ArticulosDAO()?.findAllArticulos() |
141 | if (listArticulos != null) { | 138 | if (listArticulos != null) { |
142 | 139 | ||
143 | for (i in listArticulos.indices) | 140 | for (i in listArticulos.indices) |
144 | temp += listArticulos[i].codigo.toString() | 141 | temp += listArticulos[i].codigo.toString() |
145 | } | 142 | } |
146 | withContext(Dispatchers.Main) { | 143 | withContext(Dispatchers.Main) { |
147 | countriesList.visibility = View.VISIBLE | 144 | countriesList.visibility = View.VISIBLE |
148 | loading_view.visibility = View.GONE | 145 | loading_view.visibility = View.GONE |
149 | countriesList?.text = temp | 146 | countriesList?.text = temp |
150 | } | 147 | } |
151 | } | 148 | } |
152 | // for (professor in listArticulos!!) { | 149 | // for (professor in listArticulos!!) { |
153 | // editT.text= professor.id.toString() | 150 | // editT.text= professor.id.toString() |
154 | // } | 151 | // } |
155 | } | 152 | } |
156 | 153 | ||
157 | 154 | ||
158 | // fun observeViewModel() { | 155 | // fun observeViewModel() { |
159 | // | 156 | // |
160 | // val productosService = ProductosService.getProductosService() | 157 | // val productosService = ProductosService.getProductosService() |
161 | // var job: Job? = null | 158 | // var job: Job? = null |
162 | // | 159 | // |
163 | // | 160 | // |
164 | // //countriesList.text="Procesando..." | 161 | // //countriesList.text="Procesando..." |
165 | // //countriesList.visibility = View.VISIBLE | 162 | // //countriesList.visibility = View.VISIBLE |
166 | // // GlobalScope1.launch(Dispatchers.IO) { | 163 | // // GlobalScope1.launch(Dispatchers.IO) { |
167 | // val response = productosService.getProductos() | 164 | // val response = productosService.getProductos() |
168 | // if (response.isSuccessful) { | 165 | // if (response.isSuccessful) { |
169 | //// countriesList.layoutManager = LinearLayoutManager(context) | 166 | //// countriesList.layoutManager = LinearLayoutManager(context) |
170 | //// countriesList.itemAnimator = DefaultItemAnimator() | 167 | //// countriesList.itemAnimator = DefaultItemAnimator() |
171 | // | 168 | // |
172 | //// ProductAdapter.updateCountries(it) | 169 | //// ProductAdapter.updateCountries(it) |
173 | // // cargarArticulos(response.body()) | 170 | // // cargarArticulos(response.body()) |
174 | // | 171 | // |
175 | // | 172 | // |
176 | // val artiAcargar: Articulos? = null | 173 | // val artiAcargar: Articulos? = null |
177 | // var index: Long = 1 | 174 | // var index: Long = 1 |
178 | // | 175 | // |
179 | // for (pro in response.body()!!) { | 176 | // for (pro in response.body()!!) { |
180 | // //artiAcargar.id =index+1 | 177 | // //artiAcargar.id =index+1 |
181 | // artiAcargar!!.sector = pro.sector | 178 | // artiAcargar!!.sector = pro.sector |
182 | // artiAcargar.codigo = pro.codigo | 179 | // artiAcargar.codigo = pro.codigo |
183 | // artiAcargar.descripcion = pro.descripcion | 180 | // artiAcargar.descripcion = pro.descripcion |
184 | // artiAcargar.codBar = pro.codBar | 181 | // artiAcargar.codBar = pro.codBar |
185 | // artiAcargar.precio = pro.precio | 182 | // artiAcargar.precio = pro.precio |
186 | // artiAcargar.costo = pro.costo | 183 | // artiAcargar.costo = pro.costo |
187 | // artiAcargar.balanza = pro.balanza | 184 | // artiAcargar.balanza = pro.balanza |
188 | // artiAcargar.depSn = pro.depSn | 185 | // artiAcargar.depSn = pro.depSn |
189 | // artiAcargar.imagen = pro.imagen | 186 | // artiAcargar.imagen = pro.imagen |
190 | // index += index | 187 | // index += index |
191 | // | 188 | // |
192 | // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | 189 | // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! |
193 | // .insertArticulos(artiAcargar) | 190 | // .insertArticulos(artiAcargar) |
194 | // } | 191 | // } |
195 | // } | 192 | // } |
196 | // // } | 193 | // // } |
197 | // | 194 | // |
198 | // //job.cancel() | 195 | // //job.cancel() |
199 | // | 196 | // |
200 | // | 197 | // |
201 | // } | 198 | // } |
202 | 199 | ||
203 | // fun cargarArticulos(Productos: List<Productos>?) { | 200 | // fun cargarArticulos(Productos: List<Productos>?) { |
204 | // val artiAcargar: Articulos? = null | 201 | // val artiAcargar: Articulos? = null |
205 | // var index: Long = 1 | 202 | // var index: Long = 1 |
206 | // //val job4 = CoroutineScope(Dispatchers.Default).launch { | 203 | // //val job4 = CoroutineScope(Dispatchers.Default).launch { |
207 | // for (pro in Productos!!) { | 204 | // for (pro in Productos!!) { |
208 | // //artiAcargar.id =index+1 | 205 | // //artiAcargar.id =index+1 |
209 | // artiAcargar!!.sector = pro.sector | 206 | // artiAcargar!!.sector = pro.sector |
210 | // artiAcargar.codigo = pro.codigo | 207 | // artiAcargar.codigo = pro.codigo |
211 | // artiAcargar.descripcion = pro.descripcion | 208 | // artiAcargar.descripcion = pro.descripcion |
212 | // artiAcargar.codBar = pro.codBar | 209 | // artiAcargar.codBar = pro.codBar |
213 | // artiAcargar.precio = pro.precio | 210 | // artiAcargar.precio = pro.precio |
214 | // artiAcargar.costo = pro.costo | 211 | // artiAcargar.costo = pro.costo |
215 | // artiAcargar.balanza = pro.balanza | 212 | // artiAcargar.balanza = pro.balanza |
216 | // artiAcargar.depSn = pro.depSn | 213 | // artiAcargar.depSn = pro.depSn |
217 | // artiAcargar.imagen = pro.imagen | 214 | // artiAcargar.imagen = pro.imagen |
218 | // index += index | 215 | // index += index |
219 | // | 216 | // |
220 | // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! | 217 | // AppDb.getAppDb(requireActivity())!!.ArticulosDAO()!! |
221 | // .insertArticulos(artiAcargar) | 218 | // .insertArticulos(artiAcargar) |
222 | // } | 219 | // } |
223 | // } | 220 | // } |
224 | } | 221 | } |
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 | ||
12 | import androidx.lifecycle.lifecycleScope | ||
11 | import androidx.navigation.NavController | 13 | import androidx.navigation.NavController |
12 | import androidx.navigation.Navigation | 14 | import androidx.navigation.Navigation |
13 | import androidx.navigation.fragment.findNavController | 15 | import androidx.navigation.fragment.findNavController |
14 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 16 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
15 | import com.focasoftware.deboinventariov20.Model.ServeInv | 17 | import com.focasoftware.deboinventariov20.Model.ServeInv |
16 | import com.focasoftware.deboinventariov20.R | 18 | import com.focasoftware.deboinventariov20.R |
17 | import com.focasoftware.deboinventariov20.ui.servidores.SpinnerAdapterServidor | 19 | import com.focasoftware.deboinventariov20.ui.servidores.SpinnerAdapterServidor |
18 | import kotlinx.android.synthetic.main.fragment_configuracion.* | 20 | import kotlinx.android.synthetic.main.fragment_configuracion.* |
19 | import kotlinx.coroutines.Dispatchers | 21 | import kotlinx.coroutines.* |
20 | import kotlinx.coroutines.GlobalScope | ||
21 | import kotlinx.coroutines.async | ||
22 | import kotlinx.coroutines.launch | ||
23 | 22 | ||
24 | class ConfiguracionFragment : Fragment() { | 23 | class ConfiguracionFragment : Fragment() { |
25 | 24 | ||
26 | lateinit var sharedPreferences: SharedPreferences | 25 | lateinit var sharedPreferences: SharedPreferences |
27 | private lateinit var navController: NavController | 26 | private lateinit var navController: NavController |
28 | lateinit var adapterSpinnerServidor: SpinnerAdapterServidor | 27 | lateinit var adapterSpinnerServidor: SpinnerAdapterServidor |
29 | var itemSelect: Int = 0 | 28 | var itemSelect: Int = 0 |
30 | 29 | ||
31 | override fun onCreate(savedInstanceState: Bundle?) { | 30 | override fun onCreate(savedInstanceState: Bundle?) { |
32 | super.onCreate(savedInstanceState) | 31 | super.onCreate(savedInstanceState) |
33 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 32 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
34 | } | 33 | } |
35 | 34 | ||
36 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 35 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
37 | super.onViewCreated(view, savedInstanceState) | 36 | super.onViewCreated(view, savedInstanceState) |
38 | navController = Navigation.findNavController(view) | 37 | navController = Navigation.findNavController(view) |
39 | 38 | ||
40 | } | 39 | } |
41 | 40 | ||
42 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 41 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
43 | 42 | ||
44 | val v = inflater.inflate(R.layout.fragment_configuracion, container, false) | 43 | val v = inflater.inflate(R.layout.fragment_configuracion, container, false) |
45 | val etRuta = v.findViewById<EditText>(R.id.etRuta) | 44 | val etRuta = v.findViewById<EditText>(R.id.etRuta) |
46 | val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) | 45 | val btnGuardar = v.findViewById<Button>(R.id.btnGuardar) |
47 | val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) | 46 | val rbProInclu = v.findViewById<RadioButton>(R.id.rbProInclu) |
48 | val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu) | 47 | val rbProNoInclu = v.findViewById<RadioButton>(R.id.rbProNoInclu) |
49 | val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura) | 48 | val cbHabiLectura = v.findViewById<CheckBox>(R.id.cbHabiLectura) |
50 | val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock) | 49 | val cbMostrarStock = v.findViewById<CheckBox>(R.id.cbMostrarStock) |
51 | val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras) | 50 | val rbCodigoBarras = v.findViewById<RadioButton>(R.id.rbCodigoBarras) |
52 | val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo) | 51 | val rbCodigoDebo = v.findViewById<RadioButton>(R.id.rbCodigoDebo) |
53 | val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen) | 52 | val rbCodigoOrigen = v.findViewById<RadioButton>(R.id.rbCodigoOrigen) |
54 | val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito) | 53 | val rbDeposito = v.findViewById<RadioButton>(R.id.rbDeposito) |
55 | val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas) | 54 | val rbVentas = v.findViewById<RadioButton>(R.id.rbVentas) |
56 | val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) | 55 | val cbMostrarExistencia = v.findViewById<CheckBox>(R.id.cbMostrarExistencia) |
57 | val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) | 56 | val cbMostrarPrecio = v.findViewById<CheckBox>(R.id.cbMostrarPrecio) |
58 | val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) | 57 | val btnAgregarServidor = v.findViewById<Button>(R.id.btnAgregarServidor) |
59 | val spServidor = v.findViewById<Spinner>(R.id.spServidor) | 58 | val spServidor = v.findViewById<Spinner>(R.id.spServidor) |
60 | val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) | 59 | val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor) |
61 | 60 | ||
62 | if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) { | 61 | if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) { |
63 | if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { | 62 | if (sharedPreferences.getString("rbProInclu", "").toString() == "0") { |
64 | rbProInclu.isChecked = false | 63 | rbProInclu.isChecked = false |
65 | rbProNoInclu.isChecked = true | 64 | rbProNoInclu.isChecked = true |
66 | } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { | 65 | } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") { |
67 | rbProInclu.isChecked = true | 66 | rbProInclu.isChecked = true |
68 | rbProNoInclu.isChecked = false | 67 | rbProNoInclu.isChecked = false |
69 | } | 68 | } |
70 | } else (sharedPreferences.getString("rbProInclu", "").toString() == "") | 69 | } else (sharedPreferences.getString("rbProInclu", "").toString() == "") |
71 | 70 | ||
72 | if (sharedPreferences.contains("rbProNoInclu")) { | 71 | if (sharedPreferences.contains("rbProNoInclu")) { |
73 | if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { | 72 | if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") { |
74 | rbProNoInclu.isChecked = false | 73 | rbProNoInclu.isChecked = false |
75 | rbProInclu.isChecked = true | 74 | rbProInclu.isChecked = true |
76 | } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { | 75 | } else if (sharedPreferences.getString("rbProNoInclu", "").toString() == "1") { |
77 | rbProNoInclu.isChecked = true | 76 | rbProNoInclu.isChecked = true |
78 | rbProInclu.isChecked = false | 77 | rbProInclu.isChecked = false |
79 | } | 78 | } |
80 | } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") | 79 | } else (sharedPreferences.getString("rbProNoInclu", "").toString() == "") |
81 | 80 | ||
82 | if (sharedPreferences.contains("cbHabiLectura")) { | 81 | if (sharedPreferences.contains("cbHabiLectura")) { |
83 | if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { | 82 | if (sharedPreferences.getString("cbHabiLectura", "").toString() == "0") { |
84 | cbHabiLectura.isChecked = false | 83 | cbHabiLectura.isChecked = false |
85 | } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { | 84 | } else if (sharedPreferences.getString("cbHabiLectura", "").toString() == "1") { |
86 | cbHabiLectura.isChecked = true | 85 | cbHabiLectura.isChecked = true |
87 | } | 86 | } |
88 | } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") | 87 | } else (sharedPreferences.getString("cbHabiLectura", "").toString() == "") |
89 | 88 | ||
90 | if (sharedPreferences.contains("cbMostrarStock")) { | 89 | if (sharedPreferences.contains("cbMostrarStock")) { |
91 | if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { | 90 | if (sharedPreferences.getString("cbMostrarStock", "").toString() == "0") { |
92 | cbMostrarStock.isChecked = false | 91 | cbMostrarStock.isChecked = false |
93 | } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") { | 92 | } else if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") { |
94 | cbMostrarStock.isChecked = true | 93 | cbMostrarStock.isChecked = true |
95 | } | 94 | } |
96 | } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") | 95 | } else (sharedPreferences.getString("cbMostrarStock", "").toString() == "") |
97 | 96 | ||
98 | if (sharedPreferences.contains("rbVentas")) { | 97 | if (sharedPreferences.contains("rbVentas")) { |
99 | if (sharedPreferences.getString("rbVentas", "").toString() == "0") { | 98 | if (sharedPreferences.getString("rbVentas", "").toString() == "0") { |
100 | rbVentas.isChecked = false | 99 | rbVentas.isChecked = false |
101 | rbDeposito.isChecked = true | 100 | rbDeposito.isChecked = true |
102 | } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { | 101 | } else if (sharedPreferences.getString("rbVentas", "").toString() == "1") { |
103 | rbVentas.isChecked = true | 102 | rbVentas.isChecked = true |
104 | rbDeposito.isChecked = false | 103 | rbDeposito.isChecked = false |
105 | } | 104 | } |
106 | } else (sharedPreferences.getString("rbVentas", "").toString() == "") | 105 | } else (sharedPreferences.getString("rbVentas", "").toString() == "") |
107 | 106 | ||
108 | if (sharedPreferences.contains("rbDeposito")) { | 107 | if (sharedPreferences.contains("rbDeposito")) { |
109 | if (sharedPreferences.getString("rbDeposito", "").toString() == "0") { | 108 | if (sharedPreferences.getString("rbDeposito", "").toString() == "0") { |
110 | rbDeposito.isChecked = false | 109 | rbDeposito.isChecked = false |
111 | rbVentas.isChecked = true | 110 | rbVentas.isChecked = true |
112 | } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { | 111 | } else if (sharedPreferences.getString("rbDeposito", "").toString() == "1") { |
113 | rbDeposito.isChecked = true | 112 | rbDeposito.isChecked = true |
114 | rbVentas.isChecked = false | 113 | rbVentas.isChecked = false |
115 | } | 114 | } |
116 | } else (sharedPreferences.getString("rbDeposito", "").toString() == "") | 115 | } else (sharedPreferences.getString("rbDeposito", "").toString() == "") |
117 | 116 | ||
118 | if (sharedPreferences.contains("rbCodigoDebo")) { | 117 | if (sharedPreferences.contains("rbCodigoDebo")) { |
119 | if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { | 118 | if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "0") { |
120 | rbCodigoDebo.isChecked = false | 119 | rbCodigoDebo.isChecked = false |
121 | rbCodigoOrigen.isChecked = false | 120 | rbCodigoOrigen.isChecked = false |
122 | rbCodigoBarras.isChecked = false | 121 | rbCodigoBarras.isChecked = false |
123 | } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { | 122 | } else if (sharedPreferences.getString("rbCodigoDebo", "").toString() == "1") { |
124 | rbCodigoDebo.isChecked = true | 123 | rbCodigoDebo.isChecked = true |
125 | rbCodigoOrigen.isChecked = false | 124 | rbCodigoOrigen.isChecked = false |
126 | rbCodigoBarras.isChecked = false | 125 | rbCodigoBarras.isChecked = false |
127 | } | 126 | } |
128 | } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "") | 127 | } else (sharedPreferences.getString("rbCodigoDebo", "").toString() == "") |
129 | 128 | ||
130 | if (sharedPreferences.contains("rbCodigoOrigen")) { | 129 | if (sharedPreferences.contains("rbCodigoOrigen")) { |
131 | if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") { | 130 | if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "0") { |
132 | rbCodigoOrigen.isChecked = false | 131 | rbCodigoOrigen.isChecked = false |
133 | } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") { | 132 | } else if (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "1") { |
134 | rbCodigoOrigen.isChecked = true | 133 | rbCodigoOrigen.isChecked = true |
135 | } | 134 | } |
136 | } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") | 135 | } else (sharedPreferences.getString("rbCodigoOrigen", "").toString() == "") |
137 | 136 | ||
138 | if (sharedPreferences.contains("rbCodigoBarras")) { | 137 | if (sharedPreferences.contains("rbCodigoBarras")) { |
139 | if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { | 138 | if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "0") { |
140 | rbCodigoBarras.isChecked = false | 139 | rbCodigoBarras.isChecked = false |
141 | } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") { | 140 | } else if (sharedPreferences.getString("rbCodigoBarras", "").toString() == "1") { |
142 | rbCodigoBarras.isChecked = true | 141 | rbCodigoBarras.isChecked = true |
143 | } | 142 | } |
144 | } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") | 143 | } else (sharedPreferences.getString("rbCodigoBarras", "").toString() == "") |
145 | 144 | ||
146 | if (sharedPreferences.contains("cbMostrarExistencia")) { | 145 | if (sharedPreferences.contains("cbMostrarExistencia")) { |
147 | if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { | 146 | if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "0") { |
148 | cbMostrarExistencia.isChecked = false | 147 | cbMostrarExistencia.isChecked = false |
149 | } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { | 148 | } else if (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "1") { |
150 | cbMostrarExistencia.isChecked = true | 149 | cbMostrarExistencia.isChecked = true |
151 | } | 150 | } |
152 | } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") | 151 | } else (sharedPreferences.getString("cbMostrarExistencia", "").toString() == "") |
153 | 152 | ||
154 | if (sharedPreferences.contains("cbMostrarPrecio")) { | 153 | if (sharedPreferences.contains("cbMostrarPrecio")) { |
155 | if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { | 154 | if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "0") { |
156 | cbMostrarPrecio.isChecked = false | 155 | cbMostrarPrecio.isChecked = false |
157 | } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") { | 156 | } else if (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "1") { |
158 | cbMostrarPrecio.isChecked = true | 157 | cbMostrarPrecio.isChecked = true |
159 | } | 158 | } |
160 | } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "") | 159 | } else (sharedPreferences.getString("cbMostrarPrecio", "").toString() == "") |
161 | 160 | ||
162 | btnGuardar.setOnClickListener { | 161 | btnGuardar.setOnClickListener { |
163 | guardarPreferencias() | 162 | guardarPreferencias() |
164 | Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() | 163 | Toast.makeText(v.context, "Los Datos se guardaron correctamente", Toast.LENGTH_LONG).show() |
165 | navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) | 164 | navController.navigate(R.id.action_configuracionFragment_to_mainFragment2) |
166 | } | 165 | } |
167 | btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } | 166 | btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) } |
168 | btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Dirección correcta", Toast.LENGTH_LONG).show() } | 167 | btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Dirección correcta", Toast.LENGTH_LONG).show() } |
169 | spServidor?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | ||
170 | override fun onNothingSelected(parent: AdapterView<*>?) {} | ||
171 | override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { itemSelect = position } | ||
172 | } | ||
173 | GlobalScope.launch(Dispatchers.Main) { | 168 | GlobalScope.launch(Dispatchers.Main) { |
174 | adapterSpinnerServidor = SpinnerAdapterServidor(requireContext(), getDescServers()) | 169 | adapterSpinnerServidor = SpinnerAdapterServidor(requireContext(), getDescServers()) |
175 | spServidor.adapter = adapterSpinnerServidor | 170 | spServidor.adapter = adapterSpinnerServidor |
176 | |||
177 | if (sharedPreferences.contains("ServerPredeterminado")) { | 171 | if (sharedPreferences.contains("ServerPredeterminado")) { |
178 | spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) | 172 | spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt()) |
179 | } else (spServidor.setSelection(0)) | 173 | } else (spServidor.setSelection(0)) |
180 | } | 174 | } |
181 | 175 | spServidor?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | |
176 | override fun onNothingSelected(parent: AdapterView<*>?) {} | ||
177 | override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | ||
178 | itemSelect = position | ||
179 | } | ||
180 | } | ||
182 | return v | 181 | return v |
183 | } | 182 | } |
184 | 183 | ||
185 | suspend fun getDescServers(): List<ServeInv> { | 184 | suspend fun getDescServers(): List<ServeInv> { |
186 | return GlobalScope.async(Dispatchers.IO) { | 185 | return GlobalScope.async(Dispatchers.IO) { |
187 | return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() | 186 | return@async AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.fetchAllServers() |
188 | }.await() | 187 | }.await() |
189 | } | 188 | } |
190 | 189 | ||
191 | fun guardarPreferencias() { | 190 | fun guardarPreferencias() { |
192 | try { | 191 | // try { |
193 | val editor = sharedPreferences.edit() | 192 | val editor = sharedPreferences.edit() |
194 | 193 | ||
195 | if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString()) | 194 | if (etRuta.text.isNotEmpty()) editor?.putString("etRuta", etRuta.text.toString()) |
196 | 195 | ||
197 | if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") | 196 | if (rbProInclu.isChecked) editor?.putString("rbProInclu", "1") else editor?.putString("rbProInclu", "0") |
198 | if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") | 197 | if (rbProNoInclu.isChecked) editor?.putString("rbProNoInclu", "1") else editor?.putString("rbProNoInclu", "0") |
199 | 198 | ||
200 | if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") | 199 | if (cbHabiLectura.isChecked) editor?.putString("cbHabiLectura", "1") else editor?.putString("cbHabiLectura", "0") |
201 | if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") | 200 | if (cbMostrarStock.isChecked) editor?.putString("cbMostrarStock", "1") else editor?.putString("cbMostrarStock", "0") |
202 | if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") | 201 | if (rbVentas.isChecked) editor?.putString("rbVentas", "1") else editor?.putString("rbVentas", "0") |
203 | if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") | 202 | if (rbDeposito.isChecked) editor?.putString("rbDeposito", "1") else editor?.putString("rbDeposito", "0") |
204 | if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") | 203 | if (rbCodigoDebo.isChecked) editor?.putString("rbCodigoDebo", "1") else editor?.putString("rbCodigoDebo", "0") |
205 | if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") | 204 | if (rbCodigoOrigen.isChecked) editor?.putString("rbCodigoOrigen", "1") else editor?.putString("rbCodigoOrigen", "0") |
206 | if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") | 205 | if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0") |
207 | if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") | 206 | if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0") |
208 | if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") | 207 | if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0") |
209 | editor?.putString("ServerPredeterminado", itemSelect.toString()) | 208 | editor?.putString("ServerPredeterminado", itemSelect.toString()) |
210 | 209 | updateServerPreInZero() | |
211 | editor?.apply() | 210 | updateServerPre(itemSelect+1) |
212 | editor.commit() | 211 | |
213 | 212 | editor?.apply() | |
214 | } catch (e: Exception) { | 213 | editor.commit() |
215 | e.printStackTrace() | 214 | |
216 | } | 215 | // } catch (e: Exception) { |
216 | // Toast.makeText(requireContext(), "Error ", Toast.LENGTH_LONG).show() | ||
217 | // e.printStackTrace() | ||
218 | // } | ||
217 | } | 219 | } |
218 | 220 | ||
221 | private fun updateServerPreInZero() { | ||
222 | lifecycleScope.launch { | ||
223 | withContext(Dispatchers.IO) { | ||
224 | val activity: FragmentActivity? = activity | ||
225 | if (activity != null && isAdded) { | ||
226 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.UpdateServerPreInZero() | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | private fun updateServerPre(server:Int) { | ||
232 | lifecycleScope.launch { | ||
233 | withContext(Dispatchers.IO) { |
app/src/main/java/com/focasoftware/deboinventariov20/ui/descripcionFragment/DescripcionFragment.kt
1 | package com.focasoftware.deboinventariov20.ui.descripcionFragment | 1 | package com.focasoftware.deboinventariov20.ui.descripcionFragment |
2 | 2 | ||
3 | import android.app.AlertDialog | 3 | import android.app.AlertDialog |
4 | import android.content.Context | 4 | import android.content.Context |
5 | import android.content.SharedPreferences | 5 | import android.content.SharedPreferences |
6 | import android.graphics.Canvas | 6 | import android.graphics.Canvas |
7 | import android.graphics.Color | 7 | import android.graphics.Color |
8 | import android.graphics.drawable.ColorDrawable | 8 | import android.graphics.drawable.ColorDrawable |
9 | import android.os.Bundle | 9 | import android.os.Bundle |
10 | import android.text.InputType | 10 | import android.text.InputType |
11 | import android.view.LayoutInflater | 11 | import android.view.LayoutInflater |
12 | import android.view.View | 12 | import android.view.View |
13 | import android.view.ViewGroup | 13 | import android.view.ViewGroup |
14 | import android.widget.Button | 14 | import android.widget.Button |
15 | import androidx.fragment.app.Fragment | 15 | import androidx.fragment.app.Fragment |
16 | import androidx.fragment.app.FragmentActivity | 16 | import androidx.fragment.app.FragmentActivity |
17 | import androidx.lifecycle.lifecycleScope | 17 | import androidx.lifecycle.lifecycleScope |
18 | import androidx.navigation.NavController | 18 | import androidx.navigation.NavController |
19 | import androidx.navigation.Navigation | 19 | import androidx.navigation.Navigation |
20 | import androidx.recyclerview.widget.ItemTouchHelper | 20 | import androidx.recyclerview.widget.ItemTouchHelper |
21 | import androidx.recyclerview.widget.LinearLayoutManager | 21 | import androidx.recyclerview.widget.LinearLayoutManager |
22 | import androidx.recyclerview.widget.RecyclerView | 22 | import androidx.recyclerview.widget.RecyclerView |
23 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 23 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
24 | import com.focasoftware.deboinventariov20.Model.Articles | 24 | import com.focasoftware.deboinventariov20.Model.Articles |
25 | import com.focasoftware.deboinventariov20.Model.InvBody | 25 | import com.focasoftware.deboinventariov20.Model.InvBody |
26 | import com.focasoftware.deboinventariov20.R | 26 | import com.focasoftware.deboinventariov20.R |
27 | import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment | 27 | import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment |
28 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | 28 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* |
29 | import kotlinx.android.synthetic.main.login_dialog.view.* | 29 | import kotlinx.android.synthetic.main.login_dialog.view.* |
30 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | 30 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar |
31 | import kotlinx.coroutines.* | 31 | import kotlinx.coroutines.* |
32 | 32 | ||
33 | class DescripcionFragment : Fragment() { | 33 | class DescripcionFragment : Fragment() { |
34 | private var artAcargar2: List<Articles>? = null | 34 | private var artAcargar2: List<Articles>? = null |
35 | private var listArticulos2: List<Articles>? = null | 35 | private var listArticulos2: List<Articles>? = null |
36 | lateinit var viewAdapter2: RecyclerView.Adapter<*> | 36 | lateinit var viewAdapter2: RecyclerView.Adapter<*> |
37 | private lateinit var viewManager2: RecyclerView.LayoutManager | 37 | private lateinit var viewManager2: RecyclerView.LayoutManager |
38 | private lateinit var rcDescripcion: RecyclerView | 38 | private lateinit var rcDescripcion: RecyclerView |
39 | private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | 39 | private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) |
40 | private var cantidad = 0F | 40 | private var cantidad = 0F |
41 | private var numeroInventario = 0 | 41 | private var numeroInventario = 0 |
42 | lateinit var navController: NavController | 42 | lateinit var navController: NavController |
43 | lateinit var sharedPreferences: SharedPreferences | 43 | lateinit var sharedPreferences: SharedPreferences |
44 | private var indice = 0 | 44 | private var indice = 0 |
45 | private var artCargadoEnBD: InvBody? = null | 45 | private var artCargadoEnBD: InvBody? = null |
46 | 46 | ||
47 | override fun onCreate(savedInstanceState: Bundle?) { | 47 | override fun onCreate(savedInstanceState: Bundle?) { |
48 | super.onCreate(savedInstanceState) | 48 | super.onCreate(savedInstanceState) |
49 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 49 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
50 | arguments.apply { | 50 | arguments.apply { |
51 | artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | 51 | artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> |
52 | numeroInventario = requireArguments().getInt("numeroInv") | 52 | numeroInventario = requireArguments().getInt("numeroInv") |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 56 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
57 | super.onViewCreated(view, savedInstanceState) | 57 | super.onViewCreated(view, savedInstanceState) |
58 | navController = Navigation.findNavController(view) | 58 | navController = Navigation.findNavController(view) |
59 | } | 59 | } |
60 | 60 | ||
61 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 61 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
62 | val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | 62 | val v = inflater.inflate(R.layout.fragment_descripcion, container, false) |
63 | rcDescripcion = v.findViewById(R.id.rcDescripcion) | 63 | rcDescripcion = v.findViewById(R.id.rcDescripcion) |
64 | val btnSalir = v.findViewById<Button>(R.id.btnSalir) | 64 | // val btnSalir = v.findViewById<Button>(R.id.btnSalir) |
65 | 65 | ||
66 | IngresarRecicler(artAcargar2) | 66 | IngresarRecicler(artAcargar2) |
67 | 67 | ||
68 | btnSalir.setOnClickListener { | 68 | // btnSalir.setOnClickListener { |
69 | VolverAinventario() | 69 | // activity?.onBackPressed(); |
70 | } | 70 | //// VolverAinventario() |
71 | // } | ||
71 | return v | 72 | return v |
72 | } | 73 | } |
73 | 74 | ||
74 | fun IngresarRecicler(articulos: List<Articles>?) { | 75 | fun IngresarRecicler(articulos: List<Articles>?) { |
75 | 76 | ||
76 | viewAdapter2 = DescripcionListAdapter(articulos) | 77 | viewAdapter2 = DescripcionListAdapter(articulos) |
77 | viewManager2 = LinearLayoutManager(requireContext()) | 78 | viewManager2 = LinearLayoutManager(requireContext()) |
78 | 79 | ||
79 | rcDescripcion.apply { | 80 | rcDescripcion.apply { |
80 | adapter = viewAdapter2 | 81 | adapter = viewAdapter2 |
81 | layoutManager = viewManager2 | 82 | layoutManager = viewManager2 |
82 | } | 83 | } |
83 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { | 84 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { |
84 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | 85 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { |
85 | return false | 86 | return false |
86 | } | 87 | } |
87 | 88 | ||
88 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | 89 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { |
89 | 90 | ||
90 | var indice = 0 | 91 | var indice = 0 |
91 | indice = viewHolder.layoutPosition | 92 | indice = viewHolder.layoutPosition |
92 | GlobalScope.launch(Dispatchers.Main) { | 93 | GlobalScope.launch(Dispatchers.Main) { |
93 | //TODO BUSCO EN BASE DE DATOS | 94 | //TODO BUSCO EN BASE DE DATOS |
94 | artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), | 95 | artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), |
95 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), | 96 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), |
96 | numeroInventario.toString()) | 97 | numeroInventario.toString()) |
97 | if (artCargadoEnBD == null) { | 98 | if (artCargadoEnBD == null) { |
98 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | 99 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) |
99 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView) | 100 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView) |
100 | .setCancelable(false) | 101 | .setCancelable(false) |
101 | if ((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==1 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==3 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==7) | 102 | if ((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==1 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==3 || (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza==7) |
102 | mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER | 103 | mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER |
103 | mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" | 104 | mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" |
104 | val mAlertDialog = mBuilder.show() | 105 | val mAlertDialog = mBuilder.show() |
105 | mDialogView.btnAceptar.setOnClickListener { | 106 | mDialogView.btnAceptar.setOnClickListener { |
106 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { | 107 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { |
107 | mDialogView.etCantidad.error = "No vacio" | 108 | mDialogView.etCantidad.error = "No vacio" |
108 | mDialogView.etCantidad.requestFocus() | 109 | mDialogView.etCantidad.requestFocus() |
109 | mDialogView.etCantidad.hint = "Ingrese un valor" | 110 | mDialogView.etCantidad.hint = "Ingrese un valor" |
110 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | 111 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { |
111 | cantidad = mDialogView.etCantidad.text.toString().toFloat() | 112 | cantidad = mDialogView.etCantidad.text.toString().toFloat() |
112 | val body = InvBody(numeroInventario, | 113 | val body = InvBody(numeroInventario, |
113 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | 114 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, |
114 | // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD | 115 | // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD |
115 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | 116 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, |
116 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | 117 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, |
117 | cantidad.toString(), | 118 | cantidad.toString(), |
118 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | 119 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, |
119 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | 120 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, |
120 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | 121 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, |
121 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | 122 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, |
122 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | 123 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, |
123 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | 124 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, |
124 | InventarioFragment().ObtenerFechaActual(), | 125 | InventarioFragment().ObtenerFechaActual(), |
125 | InventarioFragment().ObtenerFechaActual()) | 126 | InventarioFragment().ObtenerFechaActual()) |
126 | InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | 127 | InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS |
127 | VolverAinventario() | 128 | // VolverAinventario() |
129 | activity?.onBackPressed() | ||
128 | mAlertDialog.dismiss() | 130 | mAlertDialog.dismiss() |
129 | } | 131 | } |
130 | } | 132 | } |
131 | } else if (artCargadoEnBD != null) { | 133 | } else if (artCargadoEnBD != null) { |
132 | 134 | ||
133 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 135 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
134 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) | 136 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) |
135 | if (artCargadoEnBD!!.balanza.toString().contains("1" ) || artCargadoEnBD!!.balanza.toString().contains("3") || artCargadoEnBD!!.balanza.toString().contains("7")) mDialogView.tvNuevaCantidad.inputType= InputType.TYPE_CLASS_NUMBER | 137 | if (artCargadoEnBD!!.balanza.toString().contains("1" ) || artCargadoEnBD!!.balanza.toString().contains("3") || artCargadoEnBD!!.balanza.toString().contains("7")) mDialogView.tvNuevaCantidad.inputType= InputType.TYPE_CLASS_NUMBER |
136 | mDialogView.tvCantInicial.text = artCargadoEnBD!!.cantTomada | 138 | mDialogView.tvCantInicial.text =String.format("%.2f", artCargadoEnBD!!.cantTomada.toString().toFloat()) |
137 | 139 | ||
138 | val mAlertDialog = mBuilder.show() | 140 | val mAlertDialog = mBuilder.show() |
139 | mDialogView.rbSumar.setOnClickListener { | 141 | mDialogView.rbSumar.setOnClickListener { |
140 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 142 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
141 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 143 | mDialogView.tvResultado.text = String.format("%.2f",(mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat())) |
142 | mDialogView.tvNuevaCantidad.isEnabled=false | 144 | mDialogView.tvNuevaCantidad.isEnabled=false |
143 | } | 145 | } |
144 | } | 146 | } |
145 | mDialogView.rbRestar.setOnClickListener { | 147 | mDialogView.rbRestar.setOnClickListener { |
146 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 148 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
147 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 149 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
148 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 150 | mDialogView.tvResultado.text = String.format("%.2f",mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) |
149 | mDialogView.tvNuevaCantidad.isEnabled=false | 151 | mDialogView.tvNuevaCantidad.isEnabled = false |
152 | }else{ | ||
153 | mDialogView.tvResultado.text="" | ||
154 | mDialogView.tvResultado.error = "Operación No Valida" | ||
155 | mDialogView.tvResultado.requestFocus() | ||
156 | mDialogView.tvResultado.hint = "Error" | ||
150 | } | 157 | } |
151 | } | 158 | } |
152 | } | 159 | } |
153 | mDialogView.rbMdodificar.setOnClickListener { | 160 | mDialogView.rbMdodificar.setOnClickListener { |
154 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 161 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
155 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 162 | mDialogView.tvResultado.text = String.format("%.2f", (mDialogView.tvNuevaCantidad.text.toString().toFloat())) |
156 | mDialogView.tvNuevaCantidad.isEnabled=false | 163 | mDialogView.tvNuevaCantidad.isEnabled = false |
157 | } | 164 | } |
158 | } | 165 | } |
159 | mDialogView.btnAceptar.setOnClickListener { | 166 | mDialogView.btnAceptar.setOnClickListener { |
160 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 167 | if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { |
161 | val name = mDialogView.tvgenerico4.text.toString().toFloat() | 168 | if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { |
169 | |||
162 | updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), | 170 | updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), |
163 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), | 171 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), |
164 | name) | 172 | mDialogView.tvResultado.text.toString().toFloat()) |
165 | VolverAinventario() | 173 | // VolverAinventario() |
174 | activity?.onBackPressed(); | ||
166 | mAlertDialog.dismiss() | 175 | mAlertDialog.dismiss() |
167 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 176 | } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { |
168 | mDialogView.tvNuevaCantidad.error = "No vacio" | 177 | mDialogView.tvResultado.error = "Operación Requerida" |
169 | mDialogView.tvNuevaCantidad.requestFocus() | 178 | mDialogView.tvResultado.requestFocus() |
170 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | 179 | mDialogView.tvResultado.hint = "Seleccione Operación" |
171 | } | 180 | } |
181 | } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | ||
182 | mDialogView.tvNuevaCantidad.error = "Completar" | ||
183 | mDialogView.tvNuevaCantidad.requestFocus() | ||
184 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | ||
185 | } | ||
172 | } | 186 | } |
173 | mDialogView.dialogCancelBtn.setOnClickListener { | 187 | mDialogView.dialogCancelBtn.setOnClickListener { |
188 | activity?.onBackPressed(); | ||
174 | mAlertDialog.dismiss() | 189 | mAlertDialog.dismiss() |
175 | } | 190 | } |
176 | } | 191 | } |
177 | } | 192 | } |
178 | } | 193 | } |
179 | 194 | ||
180 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | 195 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
181 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 196 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
182 | val itemView = viewHolder.itemView | 197 | val itemView = viewHolder.itemView |
183 | 198 | ||
184 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | 199 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) |
185 | 200 | ||
186 | if (dX > 0) { | 201 | if (dX > 0) { |
187 | 202 | ||
188 | c.drawColor(Color.RED) | 203 | c.drawColor(Color.RED) |
189 | } else if (dX < 0) { | 204 | } else if (dX < 0) { |
190 | // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | 205 | // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) |
191 | c.drawColor(Color.YELLOW) | 206 | c.drawColor(Color.YELLOW) |
192 | } | 207 | } |
193 | swipeBackground.draw(c) | 208 | swipeBackground.draw(c) |
194 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 209 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
195 | } | 210 | } |
196 | } | 211 | } |
197 | val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | 212 | val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) |
198 | itemTouchHelper2.attachToRecyclerView(rcDescripcion) | 213 | itemTouchHelper2.attachToRecyclerView(rcDescripcion) |
199 | 214 | ||
200 | } | 215 | } |
201 | 216 | ||
202 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { | 217 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { |
203 | lifecycleScope.launch { | 218 | lifecycleScope.launch { |
204 | withContext(Dispatchers.IO) { | 219 | withContext(Dispatchers.IO) { |
205 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | 220 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) |
206 | } | 221 | } |
207 | } | 222 | } |
208 | } | 223 | } |
209 | 224 | ||
210 | fun VolverAinventario() { | 225 | // fun VolverAinventario() { |
211 | 226 | // | |
212 | val editor = sharedPreferences.edit() | 227 | // val editor = sharedPreferences.edit() |
213 | editor?.putString("Inventario", numeroInventario.toString()) | 228 | // editor?.putString("Inventario", numeroInventario.toString()) |
214 | editor?.apply() | 229 | // editor?.apply() |
215 | editor.commit() | 230 | // editor.commit() |
216 | navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | 231 | // navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) |
217 | } | 232 | // } |
218 | 233 | ||
219 | suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { | 234 | suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { |
220 | //TODO BUSQUEDA POR CODIGO DE BARRAS | 235 | //TODO BUSQUEDA POR CODIGO DE BARRAS |
221 | var busqueda: InvBody? = null | 236 | var busqueda: InvBody? = null |
222 | return GlobalScope.async(Dispatchers.IO) { | 237 | return GlobalScope.async(Dispatchers.IO) { |
223 | busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) | 238 | busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) |
224 | return@async busqueda | 239 | return@async busqueda |
225 | }.await() | 240 | }.await() |
226 | } | 241 | } |
227 | 242 | ||
228 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | 243 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { |
229 | lifecycleScope.launch { | 244 | lifecycleScope.launch { |
230 | withContext(Dispatchers.IO) { | 245 | withContext(Dispatchers.IO) { |
231 | val activity: FragmentActivity? = activity | 246 | val activity: FragmentActivity? = activity |
232 | if (activity != null && isAdded) { | 247 | if (activity != null && isAdded) { |
233 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | 248 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) |
234 | } | 249 | } |
235 | |||
236 | } | 250 | } |
237 | } | 251 | } |
238 | } | 252 | } |
239 | } | 253 | } |
240 | 254 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/DialogNoEncontrado.kt
1 | package com.focasoftware.deboinventariov20.ui.dialogos | File was deleted | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.os.Bundle | ||
6 | import androidx.fragment.app.DialogFragment | ||
7 | |||
8 | class DialogNoEncontrado : DialogFragment() { | ||
9 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
10 | return activity?.let { | ||
11 | val title = "Busqueda de Productos" | ||
12 | val content = "Producto no encotrado." | ||
13 | val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | ||
14 | builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ -> | ||
15 | //Todo OK click | ||
16 | } | ||
17 | return builder.create() | ||
18 | } ?: throw IllegalStateException("Activity cannot be null") | ||
19 | } | ||
20 | } | ||
21 | 1 | package com.focasoftware.deboinventariov20.ui.dialogos |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/DialogoLogin.kt
1 | package com.focasoftware.deboinventariov20.ui.dialogos | File was deleted | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.content.SharedPreferences | ||
6 | import android.os.Bundle | ||
7 | import androidx.fragment.app.DialogFragment | ||
8 | import com.focasoftware.deboinventariov20.R | ||
9 | |||
10 | class DialogoLogin() : DialogFragment() { | ||
11 | private lateinit var sharedPreferences: SharedPreferences | ||
12 | |||
13 | interface OnContinueCancelClickListener { | ||
14 | fun onPositiveClick() | ||
15 | fun onCancelClick() | ||
16 | } | ||
17 | |||
18 | fun newInstance(s: String): DialogoLogin? { | ||
19 | val dialog = DialogoLogin() | ||
20 | |||
21 | val args = Bundle() | ||
22 | args.putString("title", s) | ||
23 | dialog.arguments = args | ||
24 | |||
25 | return dialog | ||
26 | } | ||
27 | |||
28 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
29 | return activity?.let { | ||
30 | val builder = AlertDialog.Builder(it) | ||
31 | |||
32 | val inflater = requireActivity().layoutInflater; | ||
33 | |||
34 | builder.setView(inflater.inflate(R.layout.login_dialog, null)).setTitle("El producto ya fue escaneado").setPositiveButton(android.R.string.ok) { _, _ -> | ||
35 | val listener = activity as OnContinueCancelClickListener? | ||
36 | listener!!.onPositiveClick() | ||
37 | }.setNegativeButton(android.R.string.cancel) { _, _ -> | ||
38 | val listener = activity as OnContinueCancelClickListener? | ||
39 | listener!!.onCancelClick() | ||
40 | } | ||
41 | builder.create() | ||
42 | } ?: throw IllegalStateException("Activity cannot be null") | ||
43 | } | ||
44 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/InsertCant.kt
1 | package com.focasoftware.deboinventariov20.ui.dialogos | File was deleted | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.content.Context | ||
6 | import android.content.SharedPreferences | ||
7 | import android.os.Bundle | ||
8 | import android.view.View | ||
9 | import android.widget.EditText | ||
10 | import androidx.fragment.app.DialogFragment | ||
11 | import com.focasoftware.deboinventariov20.R | ||
12 | |||
13 | class InsertCant() : DialogFragment() { | ||
14 | |||
15 | private lateinit var sharedPreferences: SharedPreferences | ||
16 | |||
17 | interface OnContinueCancelClickListener { | ||
18 | fun onPositiveClick() | ||
19 | fun onCancelClick() | ||
20 | } | ||
21 | |||
22 | fun newInstance(s: String): InsertCant? { | ||
23 | val dialog = InsertCant() | ||
24 | |||
25 | val args = Bundle() | ||
26 | args.putString("title", s) | ||
27 | dialog.arguments = args | ||
28 | |||
29 | return dialog | ||
30 | } | ||
31 | |||
32 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
33 | return activity?.let { | ||
34 | val builder = AlertDialog.Builder(it) | ||
35 | |||
36 | val inflater = requireActivity().layoutInflater; | ||
37 | |||
38 | builder.setView(inflater.inflate(R.layout.ingresar_cantidad, null)).setTitle("").setPositiveButton(android.R.string.ok) { _, _ -> | ||
39 | val listener = activity as OnContinueCancelClickListener? | ||
40 | listener!!.onPositiveClick() | ||
41 | }.setNegativeButton(android.R.string.cancel) { _, _ -> | ||
42 | val listener = activity as OnContinueCancelClickListener? | ||
43 | listener!!.onCancelClick() | ||
44 | } | ||
45 | builder.create() | ||
46 | } ?: throw IllegalStateException("Activity cannot be null") | ||
47 | } | ||
48 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/dialogos/SingleChoiceAlertDialog.kt
1 | package com.focasoftware.deboinventariov20.ui.dialogos | File was deleted | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.os.Bundle | ||
6 | import androidx.fragment.app.DialogFragment | ||
7 | |||
8 | class SingleChoiceAlertDialog : DialogFragment() { | ||
9 | |||
10 | interface OnDialogSelectorListener { | ||
11 | fun onSelectedOption(dialogId: Int) | ||
12 | } | ||
13 | |||
14 | |||
15 | var mDialogSelectorCallback: OnDialogSelectorListener? = null | ||
16 | |||
17 | fun newInstance(title: String, values: Array<String>, selected: Int = -1): SingleChoiceAlertDialog? { | ||
18 | val dialog = SingleChoiceAlertDialog() | ||
19 | |||
20 | val args = Bundle() | ||
21 | args.putString("title", title) | ||
22 | args.putStringArray("values", values) | ||
23 | args.putInt("selected", selected) | ||
24 | dialog.arguments = args | ||
25 | |||
26 | return dialog | ||
27 | |||
28 | } | ||
29 | |||
30 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
31 | |||
32 | return activity?.let { | ||
33 | |||
34 | val args = requireArguments() | ||
35 | val title = args.getString("title") | ||
36 | val values = args.getStringArray("values") | ||
37 | val selectedIndex = args.getInt("selected") | ||
38 | |||
39 | val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | ||
40 | |||
41 | builder.setSingleChoiceItems(values, selectedIndex) { _, which -> | ||
42 | //val item = values?.get(which) | ||
43 | mDialogSelectorCallback?.onSelectedOption(which) | ||
44 | dialog?.dismiss() | ||
45 | } | ||
46 | builder.setTitle(title) | ||
47 | |||
48 | return builder.create() | ||
49 | } ?: throw IllegalStateException("Activity cannot be null") | ||
50 | } | ||
51 | |||
52 | |||
53 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
1 | package com.focasoftware.deboinventariov20.ui.inventario | 1 | package com.focasoftware.deboinventariov20.ui.inventario |
2 | 2 | ||
3 | import android.annotation.SuppressLint | 3 | import android.annotation.SuppressLint |
4 | import android.app.AlertDialog | 4 | import android.app.AlertDialog |
5 | import android.content.Context | 5 | import android.content.Context |
6 | import android.content.DialogInterface | 6 | import android.content.DialogInterface |
7 | import android.content.SharedPreferences | 7 | import android.content.SharedPreferences |
8 | import android.graphics.Canvas | 8 | import android.graphics.Canvas |
9 | import android.graphics.Color | 9 | import android.graphics.Color |
10 | import android.graphics.drawable.Drawable | 10 | import android.graphics.drawable.Drawable |
11 | import android.os.Bundle | 11 | import android.os.Bundle |
12 | import android.text.InputType | ||
13 | import android.text.InputType.TYPE_CLASS_NUMBER | 12 | import android.text.InputType.TYPE_CLASS_NUMBER |
14 | import android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL | ||
15 | import android.view.KeyEvent | 13 | import android.view.KeyEvent |
16 | import android.view.LayoutInflater | 14 | import android.view.LayoutInflater |
17 | import android.view.View | 15 | import android.view.View |
18 | import android.view.ViewGroup | 16 | import android.view.ViewGroup |
19 | import android.widget.EditText | 17 | import android.widget.EditText |
20 | import android.widget.TextView | 18 | import android.widget.TextView |
21 | import android.widget.Toast | 19 | import android.widget.Toast |
22 | import androidx.core.content.ContextCompat | 20 | import androidx.core.content.ContextCompat |
23 | import androidx.core.os.bundleOf | 21 | import androidx.core.os.bundleOf |
24 | import androidx.fragment.app.Fragment | 22 | import androidx.fragment.app.Fragment |
25 | import androidx.lifecycle.lifecycleScope | 23 | import androidx.lifecycle.lifecycleScope |
26 | import androidx.navigation.NavController | 24 | import androidx.navigation.NavController |
27 | import androidx.navigation.Navigation | 25 | import androidx.navigation.Navigation |
28 | import androidx.recyclerview.widget.ItemTouchHelper | 26 | import androidx.recyclerview.widget.ItemTouchHelper |
29 | import androidx.recyclerview.widget.LinearLayoutManager | 27 | import androidx.recyclerview.widget.LinearLayoutManager |
30 | import androidx.recyclerview.widget.RecyclerView | 28 | import androidx.recyclerview.widget.RecyclerView |
31 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 29 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
32 | import com.focasoftware.deboinventariov20.Model.Articles | 30 | import com.focasoftware.deboinventariov20.Model.Articles |
33 | import com.focasoftware.deboinventariov20.Model.InvBody | 31 | import com.focasoftware.deboinventariov20.Model.InvBody |
34 | import com.focasoftware.deboinventariov20.Model.InvHead | 32 | import com.focasoftware.deboinventariov20.Model.InvHead |
35 | import com.focasoftware.deboinventariov20.R | 33 | import com.focasoftware.deboinventariov20.R |
36 | import com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado | 34 | import com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogNoEncontrado |
37 | import kotlinx.android.synthetic.main.fragment_inventario.* | 35 | import kotlinx.android.synthetic.main.fragment_inventario.* |
38 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | 36 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* |
39 | import kotlinx.android.synthetic.main.login_dialog.view.* | 37 | import kotlinx.android.synthetic.main.login_dialog.view.* |
40 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | 38 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar |
41 | import kotlinx.coroutines.* | 39 | import kotlinx.coroutines.* |
42 | import java.lang.Integer.TYPE | ||
43 | import java.time.LocalDateTime | 40 | import java.time.LocalDateTime |
44 | import java.time.format.DateTimeFormatter | 41 | import java.time.format.DateTimeFormatter |
45 | import java.util.* | 42 | import java.util.* |
46 | 43 | ||
47 | 44 | ||
48 | class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener{ | 45 | class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener { |
49 | 46 | ||
50 | private lateinit var sharedPreferences: SharedPreferences | 47 | private lateinit var sharedPreferences: SharedPreferences |
51 | private var iArea: Int = 0 | 48 | private var iArea: Int = 0 |
52 | private lateinit var invHead: InvHead | 49 | private lateinit var invHead: InvHead |
53 | private lateinit var rcInventarios: RecyclerView | 50 | private lateinit var rcInventarios: RecyclerView |
54 | private lateinit var viewAdapter: RecyclerView.Adapter<*> | 51 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
55 | private lateinit var viewManager: RecyclerView.LayoutManager | 52 | private lateinit var viewManager: RecyclerView.LayoutManager |
56 | private lateinit var sChangeUpper: String | 53 | private lateinit var sChangeUpper: String |
57 | private var listArticulos = ArrayList<ItemsRecycler>() | 54 | private var listArticulos = ArrayList<ItemsRecycler>() |
58 | private lateinit var navController: NavController | 55 | private lateinit var navController: NavController |
59 | private var InventarioNuevo: Int = 0 | 56 | private var InventarioNuevo: Int = 0 |
60 | private var iEstado = 0 | 57 | private var iEstado = 0 |
61 | private var iBusquedaPor = 0 | 58 | private var iBusquedaPor = 0 |
62 | private var fCant = 0F | 59 | private var fCant = 0F |
63 | private var bFirst = false | 60 | private var bFirst = false |
64 | private lateinit var deleteIcon: Drawable | 61 | private lateinit var deleteIcon: Drawable |
65 | 62 | ||
66 | override fun onCreate(savedInstanceState: Bundle?) { | 63 | override fun onCreate(savedInstanceState: Bundle?) { |
67 | super.onCreate(savedInstanceState) | 64 | super.onCreate(savedInstanceState) |
68 | 65 | ||
69 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 66 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
70 | if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { | 67 | if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { |
71 | InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() | 68 | InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() |
72 | val editor = sharedPreferences.edit() | 69 | val editor = sharedPreferences.edit() |
73 | editor?.putString("Inventario", "-1") | 70 | editor?.putString("Inventario", "-1") |
74 | editor?.apply() | 71 | editor?.apply() |
75 | editor.commit() | 72 | editor.commit() |
76 | } | 73 | } |
77 | } | 74 | } |
78 | 75 | ||
79 | 76 | ||
80 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 77 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
81 | val v = inflater.inflate(R.layout.fragment_inventario, container, false) | 78 | val v = inflater.inflate(R.layout.fragment_inventario, container, false) |
82 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 79 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
83 | val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) | 80 | val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) |
84 | rcInventarios = v.findViewById(R.id.rcInventarios) | 81 | rcInventarios = v.findViewById(R.id.rcInventarios) |
85 | val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) | 82 | val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) |
86 | 83 | ||
87 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO | 84 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO |
88 | GlobalScope.launch(Dispatchers.Main) { | 85 | GlobalScope.launch(Dispatchers.Main) { |
89 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO | 86 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO |
90 | InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 | 87 | InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 |
91 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO | 88 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO |
92 | invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) | 89 | invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) |
93 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) | 90 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) |
94 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" | 91 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" |
95 | } | 92 | } |
96 | } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) | 93 | } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) |
97 | listArticulos.clear() | 94 | listArticulos.clear() |
98 | CargarDeBdInventario(InventarioNuevo) | 95 | CargarDeBdInventario(InventarioNuevo) |
99 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" | 96 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" |
100 | } | 97 | } |
101 | 98 | ||
102 | tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> | 99 | tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> |
103 | if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { | 100 | if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { |
104 | sChangeUpper = tCodigoBarras.text.toString() | 101 | sChangeUpper = tCodigoBarras.text.toString() |
105 | var indiceDelArtEncontrado = 0 | 102 | var indiceDelArtEncontrado = 0 |
106 | 103 | ||
107 | if (tCodigoBarras.text.isNullOrBlank()) { | 104 | if (tCodigoBarras.text.isNullOrBlank()) { |
108 | tCodigoBarras.error = "No puede estar vacio" | 105 | tCodigoBarras.error = "No puede estar vacio" |
109 | tCodigoBarras.requestFocus() | 106 | tCodigoBarras.requestFocus() |
110 | tCodigoBarras.hint = "No puede estar vacio" | 107 | tCodigoBarras.hint = "No puede estar vacio" |
111 | } else { | 108 | } else { |
112 | 109 | ||
113 | //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS | 110 | //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS |
114 | when (iBusquedaPor) { | 111 | when (iBusquedaPor) { |
115 | 0 -> { | 112 | 0 -> { |
116 | GlobalScope.launch(Dispatchers.Main) { | 113 | GlobalScope.launch(Dispatchers.Main) { |
117 | indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | 114 | indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice |
118 | //TODO (Si no lo encuentra devuelve -1) | 115 | //TODO (Si no lo encuentra devuelve -1) |
119 | if (indiceDelArtEncontrado != -1) { | 116 | if (indiceDelArtEncontrado != -1) { |
120 | if (swSumaUno!!.isChecked) { | 117 | if (swSumaUno!!.isChecked) { |
121 | // fCant = 0F | 118 | // fCant = 0F |
122 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 119 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
123 | // fCant += 1F | 120 | // fCant += 1F |
124 | //TODO ACTUALIZO LA CANTIDAD EN LA BD | 121 | //TODO ACTUALIZO LA CANTIDAD EN LA BD |
125 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), listArticulos[indiceDelArtEncontrado].cantTomada+1) | 122 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), |
123 | listArticulos[indiceDelArtEncontrado].codigo.toString(), | ||
124 | listArticulos[indiceDelArtEncontrado].cantTomada + 1) | ||
126 | //TODO ACTUALIZO LA CANTIDAD EN EL RV | 125 | //TODO ACTUALIZO LA CANTIDAD EN EL RV |
127 | listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada+1 | 126 | listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada + 1 |
128 | viewAdapter.notifyDataSetChanged() | 127 | viewAdapter.notifyDataSetChanged() |
129 | } else { | 128 | } else { |
130 | dialogoSumaResta(requireContext(),indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta) | 129 | dialogoSumaResta(requireContext(), indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta, false) |
131 | } | 130 | } |
132 | 131 | ||
133 | } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | 132 | } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD |
134 | 133 | ||
135 | 134 | ||
136 | //TODO BUSCO EN BASE DE DATOS | 135 | //TODO BUSCO EN BASE DE DATOS |
137 | val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 136 | val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
138 | ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE | 137 | ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE |
139 | } | 138 | } |
140 | 139 | ||
141 | 140 | ||
142 | tCodigoBarras.focusable = View.FOCUSABLE | 141 | tCodigoBarras.focusable = View.FOCUSABLE |
143 | tCodigoBarras.setText("") | 142 | tCodigoBarras.setText("") |
144 | tCodigoBarras.selectAll() | 143 | tCodigoBarras.selectAll() |
145 | } | 144 | } |
146 | return@setOnKeyListener true | 145 | return@setOnKeyListener true |
147 | 146 | ||
148 | 147 | ||
149 | } | 148 | } |
150 | 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | 149 | 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** |
151 | // | 150 | // |
152 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | 151 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice |
153 | // //TODO Si no lo encuentra devuelve -1 | 152 | // //TODO Si no lo encuentra devuelve -1 |
154 | // if (indiceDelArtEncontrado != -1) { | 153 | // if (indiceDelArtEncontrado != -1) { |
155 | //// if (swSumaUno!!.isChecked) { | 154 | //// if (swSumaUno!!.isChecked) { |
156 | //// fCant = 0F | 155 | //// fCant = 0F |
157 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 156 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
158 | //// fCant += 1F | 157 | //// fCant += 1F |
159 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 158 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
160 | //// viewAdapter.notifyDataSetChanged() | 159 | //// viewAdapter.notifyDataSetChanged() |
161 | //// } else { | 160 | //// } else { |
162 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 161 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
163 | // MaterialDialog(requireContext()).show { | 162 | // MaterialDialog(requireContext()).show { |
164 | // title(R.string.sTituloNueva) | 163 | // title(R.string.sTituloNueva) |
165 | // message(R.string.sCantidadNueva) | 164 | // message(R.string.sCantidadNueva) |
166 | // input { materialDialog, charSequence -> | 165 | // input { materialDialog, charSequence -> |
167 | // fCant = 0F | 166 | // fCant = 0F |
168 | // fCant = charSequence.toString().toFloat() | 167 | // fCant = charSequence.toString().toFloat() |
169 | // } | 168 | // } |
170 | // positiveButton(R.string.btnOk) { | 169 | // positiveButton(R.string.btnOk) { |
171 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 170 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
172 | // viewAdapter.notifyDataSetChanged() | 171 | // viewAdapter.notifyDataSetChanged() |
173 | // dismiss() | 172 | // dismiss() |
174 | // } | 173 | // } |
175 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 174 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
176 | //// } | 175 | //// } |
177 | // | 176 | // |
178 | // } else if | 177 | // } else if |
179 | // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | 178 | // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD |
180 | GlobalScope.launch(Dispatchers.Main) { | 179 | GlobalScope.launch(Dispatchers.Main) { |
181 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 180 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
182 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) | 181 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) |
183 | } | 182 | } |
184 | // } | 183 | // } |
185 | 184 | ||
186 | return@setOnKeyListener true | 185 | return@setOnKeyListener true |
187 | } | 186 | } |
188 | // 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** | 187 | // 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** |
189 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice | 188 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice |
190 | // //TODO Si no lo encuentra devuelve -1 | 189 | // //TODO Si no lo encuentra devuelve -1 |
191 | // if (indiceDelArtEncontrado != -1) { | 190 | // if (indiceDelArtEncontrado != -1) { |
192 | // if (swSumaUno!!.isChecked) { | 191 | // if (swSumaUno!!.isChecked) { |
193 | // fCant = 0F | 192 | // fCant = 0F |
194 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 193 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
195 | // fCant += 1F | 194 | // fCant += 1F |
196 | // //TODO ACTUALIZO LA CANTIDAD EN LA BD | 195 | // //TODO ACTUALIZO LA CANTIDAD EN LA BD |
197 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 196 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
198 | // //TODO ACTUALIZO LA CANTIDAD EN EL RV | 197 | // //TODO ACTUALIZO LA CANTIDAD EN EL RV |
199 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 198 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
200 | // viewAdapter.notifyDataSetChanged() | 199 | // viewAdapter.notifyDataSetChanged() |
201 | // } else { | 200 | // } else { |
202 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 201 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
203 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | 202 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") |
204 | // .setCancelable(false) | 203 | // .setCancelable(false) |
205 | // mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | 204 | // mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() |
206 | // val mAlertDialog = mBuilder.show() | 205 | // val mAlertDialog = mBuilder.show() |
207 | // mDialogView.rbSumar.setOnClickListener { | 206 | // mDialogView.rbSumar.setOnClickListener { |
208 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 207 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
209 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 208 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
210 | // } | 209 | // } |
211 | // } | 210 | // } |
212 | // mDialogView.rbRestar.setOnClickListener { | 211 | // mDialogView.rbRestar.setOnClickListener { |
213 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 212 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
214 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 213 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
215 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 214 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
216 | // } | 215 | // } |
217 | // } | 216 | // } |
218 | // } | 217 | // } |
219 | // mDialogView.rbMdodificar.setOnClickListener { | 218 | // mDialogView.rbMdodificar.setOnClickListener { |
220 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 219 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
221 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 220 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
222 | // } | 221 | // } |
223 | // } | 222 | // } |
224 | // mDialogView.btnAceptar.setOnClickListener { | 223 | // mDialogView.btnAceptar.setOnClickListener { |
225 | // mAlertDialog.dismiss() | 224 | // mAlertDialog.dismiss() |
226 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | 225 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() |
227 | // fCant = 0F | 226 | // fCant = 0F |
228 | // fCant = name | 227 | // fCant = name |
229 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 228 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
230 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 229 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
231 | // viewAdapter.notifyDataSetChanged() | 230 | // viewAdapter.notifyDataSetChanged() |
232 | // } | 231 | // } |
233 | // mDialogView.dialogCancelBtn.setOnClickListener { | 232 | // mDialogView.dialogCancelBtn.setOnClickListener { |
234 | // mAlertDialog.dismiss() | 233 | // mAlertDialog.dismiss() |
235 | // } | 234 | // } |
236 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 235 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
237 | //// val type = InputType.TYPE_CLASS_NUMBER | 236 | //// val type = InputType.TYPE_CLASS_NUMBER |
238 | //// MaterialDialog(requireContext()).show { | 237 | //// MaterialDialog(requireContext()).show { |
239 | //// | 238 | //// |
240 | //// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | 239 | //// title(text = "Producto '$sChangeUpper', se encuentra cargado.") |
241 | //// message(R.string.sCantidadNueva) | 240 | //// message(R.string.sCantidadNueva) |
242 | //// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | 241 | //// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> |
243 | //// fCant = 0F | 242 | //// fCant = 0F |
244 | //// fCant = charSequence.toString().toFloat() | 243 | //// fCant = charSequence.toString().toFloat() |
245 | //// } | 244 | //// } |
246 | //// positiveButton(R.string.btnOk) { | 245 | //// positiveButton(R.string.btnOk) { |
247 | //// //TODO ACTUALIZO CANTIADAD EN BD | 246 | //// //TODO ACTUALIZO CANTIADAD EN BD |
248 | //// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 247 | //// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
249 | //// //TODO ACTUALIZO CANTIDAD EN RV | 248 | //// //TODO ACTUALIZO CANTIDAD EN RV |
250 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 249 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
251 | //// viewAdapter.notifyDataSetChanged() | 250 | //// viewAdapter.notifyDataSetChanged() |
252 | //// dismiss() | 251 | //// dismiss() |
253 | //// } | 252 | //// } |
254 | //// }.cancelOnTouchOutside(false).cornerRadius(10F) | 253 | //// }.cancelOnTouchOutside(false).cornerRadius(10F) |
255 | // } | 254 | // } |
256 | // } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | 255 | // } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD |
257 | // | 256 | // |
258 | // GlobalScope.launch(Dispatchers.Main) { | 257 | // GlobalScope.launch(Dispatchers.Main) { |
259 | // //TODO BUSCO EN BASE DE DATOS | 258 | // //TODO BUSCO EN BASE DE DATOS |
260 | // listArticulos[indiceDelArtEncontrado].cantTomada | 259 | // listArticulos[indiceDelArtEncontrado].cantTomada |
261 | // val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 260 | // val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
262 | // ContinuarCargaCB(artEncontrado) | 261 | // ContinuarCargaCB(artEncontrado) |
263 | // } | 262 | // } |
264 | // } | 263 | // } |
265 | // return@setOnKeyListener true | 264 | // return@setOnKeyListener true |
266 | // } | 265 | // } |
267 | } | 266 | } |
268 | } | 267 | } |
269 | } | 268 | } |
270 | return@setOnKeyListener false | 269 | return@setOnKeyListener false |
271 | } | 270 | } |
272 | return v | 271 | return v |
273 | } | 272 | } |
274 | 273 | ||
275 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 274 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
276 | super.onViewCreated(view, savedInstanceState) | 275 | super.onViewCreated(view, savedInstanceState) |
277 | navController = Navigation.findNavController(view) | 276 | navController = Navigation.findNavController(view) |
278 | etCodigoBarras.requestFocus() | 277 | etCodigoBarras.requestFocus() |
279 | // val modalDialog = NoEncontradoSimple() | 278 | // val modalDialog = NoEncontradoSimple() |
280 | // modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 279 | // modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
281 | 280 | ||
282 | btnBorrarInv.setOnClickListener { | 281 | btnBorrarInv.setOnClickListener { |
283 | AlertDialog.Builder(requireContext()) | 282 | AlertDialog.Builder(requireContext()).setTitle("Eliminación de Inventarios").setMessage("¿Confirma que desea eliminar el inventario?") |
284 | .setTitle("Eliminación de Inventarios") | 283 | .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> |
285 | .setMessage("¿Confirma que desea eliminar el inventario?") | ||
286 | .setPositiveButton(R.string.btnOk, | ||
287 | DialogInterface.OnClickListener { dialog, which -> | ||
288 | BorrarInvActual() | 284 | BorrarInvActual() |
289 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | 285 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() |
290 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 286 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
291 | InventarioNuevo = 0 | 287 | InventarioNuevo = 0 |
292 | 288 | ||
293 | }) | 289 | }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> |
294 | .setNegativeButton(R.string.btnCancelar, | 290 | //botón cancel pulsado |
295 | DialogInterface.OnClickListener { dialog, which -> | 291 | }).show() |
296 | //botón cancel pulsado | ||
297 | }) | ||
298 | .show() | ||
299 | } | 292 | } |
300 | 293 | ||
301 | btnExportarInv.setOnClickListener { | 294 | btnExportarInv.setOnClickListener { |
302 | AlertDialog.Builder(requireContext()) | 295 | AlertDialog.Builder(requireContext()).setTitle(R.string.sTituloExportar).setMessage(R.string.sMensajeExportar) |
303 | .setTitle(R.string.sTituloExportar) | 296 | .setPositiveButton(R.string.btnOk, DialogInterface.OnClickListener { dialog, which -> |
304 | .setMessage(R.string.sMensajeExportar) | 297 | BorrarInvActual() |
305 | .setPositiveButton(R.string.btnOk, | 298 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() |
306 | DialogInterface.OnClickListener { dialog, which -> | 299 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
307 | BorrarInvActual() | 300 | InventarioNuevo = 0 |
308 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | 301 | |
309 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 302 | }).setNegativeButton(R.string.btnCancelar, DialogInterface.OnClickListener { dialog, which -> |
310 | InventarioNuevo = 0 | 303 | //botón cancel pulsado |
311 | 304 | }).show() | |
312 | }) | ||
313 | .setNegativeButton(R.string.btnCancelar, | ||
314 | DialogInterface.OnClickListener { dialog, which -> | ||
315 | //botón cancel pulsado | ||
316 | }) | ||
317 | .show() | ||
318 | 305 | ||
319 | // MaterialDialog(requireContext()).show { | 306 | // MaterialDialog(requireContext()).show { |
320 | // title(R.string.sTituloExportar) | 307 | // title(R.string.sTituloExportar) |
321 | // message(R.string.sMensajeExportar) | 308 | // message(R.string.sMensajeExportar) |
322 | // positiveButton(R.string.btnOk) { | 309 | // positiveButton(R.string.btnOk) { |
323 | // BorrarInvActual() | 310 | // BorrarInvActual() |
324 | // Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | 311 | // Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() |
325 | // navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 312 | // navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
326 | // InventarioNuevo = 0 | 313 | // InventarioNuevo = 0 |
327 | // dismiss() | 314 | // dismiss() |
328 | // } | 315 | // } |
329 | // negativeButton { | 316 | // negativeButton { |
330 | // dismiss() | 317 | // dismiss() |
331 | // } | 318 | // } |
332 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 319 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
333 | } | 320 | } |
334 | ivCamara.setOnClickListener { | 321 | ivCamara.setOnClickListener { |
335 | if (!bFirst) { | 322 | if (!bFirst) { |
336 | iEstado = 1 | 323 | iEstado = 1 |
337 | bFirst = true | 324 | bFirst = true |
338 | } | 325 | } |
339 | 326 | ||
340 | when (iEstado) { | 327 | when (iEstado) { |
341 | 0 -> { | 328 | 0 -> { |
342 | ivCamara.setImageResource(R.drawable.codbar) | 329 | ivCamara.setImageResource(R.drawable.codbar) |
343 | etCodigoBarras.hint = "Busqueda por C. Barras" | 330 | etCodigoBarras.hint = "Busqueda por C. Barras" |
344 | swSumaUno.visibility = View.VISIBLE | 331 | swSumaUno.visibility = View.VISIBLE |
345 | iBusquedaPor = 0 | 332 | iBusquedaPor = 0 |
346 | iEstado = 1 | 333 | iEstado = 1 |
347 | } | 334 | } |
348 | 1 -> { | 335 | 1 -> { |
349 | ivCamara.setImageResource(R.drawable.desc) | 336 | ivCamara.setImageResource(R.drawable.desc) |
350 | etCodigoBarras.hint = "Busqueda por Descripción" | 337 | etCodigoBarras.hint = "Busqueda por Descripción" |
351 | swSumaUno.visibility = View.GONE | 338 | swSumaUno.visibility = View.GONE |
352 | iBusquedaPor = 1 | 339 | iBusquedaPor = 1 |
353 | iEstado = 2 | 340 | iEstado = 2 |
354 | } | 341 | } |
355 | 2 -> { | 342 | 2 -> { |
356 | ivCamara.setImageResource(R.drawable.cod_origen) | 343 | ivCamara.setImageResource(R.drawable.cod_origen) |
357 | etCodigoBarras.hint = "Busqueda por C. Origen" | 344 | etCodigoBarras.hint = "Busqueda por C. Origen" |
358 | swSumaUno.visibility = View.GONE | 345 | swSumaUno.visibility = View.GONE |
359 | iBusquedaPor = 2 | 346 | iBusquedaPor = 2 |
360 | iEstado = 0 | 347 | iEstado = 0 |
361 | } | 348 | } |
362 | } | 349 | } |
363 | } | 350 | } |
364 | } | 351 | } |
365 | 352 | ||
366 | private fun BorrarInvActual() { | 353 | private fun BorrarInvActual() { |
367 | lifecycleScope.launch { | 354 | lifecycleScope.launch { |
368 | withContext(Dispatchers.IO) { | 355 | withContext(Dispatchers.IO) { |
369 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) | 356 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) |
370 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) | 357 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) |
371 | } | 358 | } |
372 | } | 359 | } |
373 | } | 360 | } |
374 | 361 | ||
375 | private fun CargarDeBdInventario(ultimoInv: Int) { | 362 | private fun CargarDeBdInventario(ultimoInv: Int) { |
376 | GlobalScope.launch(Dispatchers.Main) { | 363 | GlobalScope.launch(Dispatchers.Main) { |
377 | val invbody = cargarInventario(ultimoInv) | 364 | val invbody = cargarInventario(ultimoInv) |
378 | for ((i, item) in invbody!!.withIndex()) { | 365 | for ((i, item) in invbody!!.withIndex()) { |
379 | val art = Articles(invbody[i].sector, | 366 | val art = Articles(invbody[i].sector, |
380 | invbody[i].codigo, | 367 | invbody[i].codigo, |
381 | invbody[i].descripcion, | 368 | invbody[i].descripcion, |
382 | invbody[i].codBar, | 369 | invbody[i].codBar, |
383 | invbody[i].codOrigen, | 370 | invbody[i].codOrigen, |
384 | invbody[i].precio, | 371 | invbody[i].precio, |
385 | invbody[i].costo, | 372 | invbody[i].costo, |
386 | "", | 373 | "", |
387 | "", | 374 | "", |
388 | "", | 375 | "", |
389 | invbody[i].balanza, | 376 | invbody[i].balanza, |
390 | invbody[i].depSn, | 377 | invbody[i].depSn, |
391 | invbody[i].costo) | 378 | invbody[i].costo) |
392 | cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) | 379 | cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) |
393 | } | 380 | } |
394 | } | 381 | } |
395 | 382 | ||
396 | } | 383 | } |
397 | 384 | ||
398 | @SuppressLint("RestrictedApi") | 385 | @SuppressLint("RestrictedApi") |
399 | private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { | 386 | private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { |
400 | //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS | 387 | //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS |
401 | //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV | 388 | //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV |
402 | 389 | ||
403 | if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD | 390 | if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD |
404 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | 391 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV |
405 | // fCant = 0F | 392 | // fCant = 0F |
406 | // fCant += 1F | 393 | // fCant += 1F |
407 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | 394 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV |
408 | // val acargarPorDesc = Articles(artAcargar[0].sector, | 395 | // val acargarPorDesc = Articles(artAcargar[0].sector, |
409 | // artAcargar[0].codigo, | 396 | // artAcargar[0].codigo, |
410 | // artAcargar[0].descripcion, | 397 | // artAcargar[0].descripcion, |
411 | // artAcargar[0].codBar, | 398 | // artAcargar[0].codBar, |
412 | // artAcargar[0].codOrigen, | 399 | // artAcargar[0].codOrigen, |
413 | // artAcargar[0].precio, | 400 | // artAcargar[0].precio, |
414 | // artAcargar[0].costo, | 401 | // artAcargar[0].costo, |
415 | // "", | 402 | // "", |
416 | // "", | 403 | // "", |
417 | // "", | 404 | // "", |
418 | // artAcargar[0].balanza, | 405 | // artAcargar[0].balanza, |
419 | // artAcargar[0].depSn, | 406 | // artAcargar[0].depSn, |
420 | // "") | 407 | // "") |
421 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | 408 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD |
422 | // cargarArtEnBd(acargarPorDesc, fCant) | 409 | // cargarArtEnBd(acargarPorDesc, fCant) |
423 | // cargarRecicler(acargarPorDesc, fCant) | 410 | // cargarRecicler(acargarPorDesc, fCant) |
424 | // } else { | 411 | // } else { |
425 | var bundle = Bundle() | 412 | var bundle = Bundle() |
426 | bundle = bundleOf("ArrayDesc" to artAcargar) | 413 | bundle = bundleOf("ArrayDesc" to artAcargar) |
427 | bundle.putInt("numeroInv", InventarioNuevo) | 414 | bundle.putInt("numeroInv", InventarioNuevo) |
428 | navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | 415 | navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) |
429 | //navController.backStack.removeLast() | 416 | //navController.backStack.removeLast() |
430 | // } | 417 | // } |
431 | // } else {//SI NO ESTA +1 | 418 | // } else {//SI NO ESTA +1 |
432 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | 419 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV |
433 | // fCant = listArticulos[0].cantTomada | 420 | // fCant = listArticulos[0].cantTomada |
434 | // MaterialDialog(requireContext()).show { | 421 | // MaterialDialog(requireContext()).show { |
435 | // title(R.string.sTituloNueva) | 422 | // title(R.string.sTituloNueva) |
436 | // message(R.string.sCantidadNueva) | 423 | // message(R.string.sCantidadNueva) |
437 | // input { materialDialog, charSequence -> | 424 | // input { materialDialog, charSequence -> |
438 | // fCant = 0F | 425 | // fCant = 0F |
439 | // fCant = charSequence.toString().toFloat() | 426 | // fCant = charSequence.toString().toFloat() |
440 | // } | 427 | // } |
441 | // positiveButton(R.string.btnOk) { | 428 | // positiveButton(R.string.btnOk) { |
442 | // listArticulos[0].cantTomada = fCant | 429 | // listArticulos[0].cantTomada = fCant |
443 | // viewAdapter.notifyDataSetChanged() | 430 | // viewAdapter.notifyDataSetChanged() |
444 | // dismiss() | 431 | // dismiss() |
445 | // } | 432 | // } |
446 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 433 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
447 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | 434 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV |
448 | // val acargarPorDesc = Articles(artAcargar[0].sector, | 435 | // val acargarPorDesc = Articles(artAcargar[0].sector, |
449 | // artAcargar[0].codigo, | 436 | // artAcargar[0].codigo, |
450 | // artAcargar[0].descripcion, | 437 | // artAcargar[0].descripcion, |
451 | // artAcargar[0].codBar, | 438 | // artAcargar[0].codBar, |
452 | // artAcargar[0].cod_origen, | 439 | // artAcargar[0].cod_origen, |
453 | // artAcargar[0].precio, | 440 | // artAcargar[0].precio, |
454 | // artAcargar[0].costo, | 441 | // artAcargar[0].costo, |
455 | // artAcargar[0].balanza, | 442 | // artAcargar[0].balanza, |
456 | // artAcargar[0].depSn, | 443 | // artAcargar[0].depSn, |
457 | // "") | 444 | // "") |
458 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | 445 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD |
459 | // cargarArtEnBd(acargarPorDesc, fCant) | 446 | // cargarArtEnBd(acargarPorDesc, fCant) |
460 | // cargarRecicler(acargarPorDesc, fCant) | 447 | // cargarRecicler(acargarPorDesc, fCant) |
461 | // } else { | 448 | // } else { |
462 | // var bundle = Bundle() | 449 | // var bundle = Bundle() |
463 | // bundle = bundleOf("ArrayDesc" to artAcargar) | 450 | // bundle = bundleOf("ArrayDesc" to artAcargar) |
464 | // bundle.putInt("numeroInv", InventarioNuevo) | 451 | // bundle.putInt("numeroInv", InventarioNuevo) |
465 | // navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | 452 | // navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) |
466 | // } | 453 | // } |
467 | // } | 454 | // } |
468 | } else {//TODO si no lo encuentra en la BD | 455 | } else {//TODO si no lo encuentra en la BD |
469 | val modalDialog = DialogNoEncontrado() | 456 | val modalDialog = DialogNoEncontrado() |
470 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 457 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
471 | } | 458 | } |
472 | etCodigoBarras.focusable = View.FOCUSABLE | 459 | etCodigoBarras.focusable = View.FOCUSABLE |
473 | etCodigoBarras.setText("") | 460 | etCodigoBarras.setText("") |
474 | etCodigoBarras.selectAll() | 461 | etCodigoBarras.selectAll() |
475 | } | 462 | } |
476 | 463 | ||
477 | private fun ContinuarCargaCB(artAcargar: Articles?) { | 464 | private fun ContinuarCargaCB(artAcargar: Articles?) { |
478 | 465 | ||
479 | if (artAcargar != null) {// TODO: Si lo encuentra en la BD | 466 | if (artAcargar != null) {// TODO: Si lo encuentra en la BD |
480 | if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 | 467 | if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 |
481 | fCant = 0F | 468 | fCant = 0F |
482 | fCant += 1F | 469 | fCant += 1F |
483 | cargarArtEnBd(artAcargar, fCant) | 470 | cargarArtEnBd(artAcargar, String.format("%.3f", fCant)) |
484 | cargarRecicler(artAcargar, fCant) | 471 | cargarRecicler(artAcargar, fCant) |
485 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD | 472 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD |
486 | 473 | ||
487 | DialogingresarCantidad(requireContext(),artAcargar) | 474 | DialogingresarCantidad(requireContext(), artAcargar) |
488 | } | 475 | } |
489 | } else {// TODO si no lo encuentra en la BD | 476 | } else {// TODO si no lo encuentra en la BD |
490 | val modalDialog = DialogNoEncontrado() | 477 | val modalDialog = DialogNoEncontrado() |
491 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 478 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
492 | } | 479 | } |
493 | etCodigoBarras.focusable = View.FOCUSABLE | 480 | etCodigoBarras.focusable = View.FOCUSABLE |
494 | etCodigoBarras.setText("") | 481 | etCodigoBarras.setText("") |
495 | etCodigoBarras.selectAll() | 482 | etCodigoBarras.selectAll() |
496 | } | 483 | } |
497 | 484 | ||
498 | fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?) { | 485 | fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?) { |
499 | val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) | 486 | val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) |
500 | val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView) | 487 | val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView).setCancelable(false) |
501 | .setCancelable(false) | 488 | if (artAcargar!!.balanza!!.toInt() == 1 || artAcargar.balanza!!.toInt() == 3 || artAcargar.balanza!!.toInt() == 7) mDialogView.etCantidad.inputType = TYPE_CLASS_NUMBER |
502 | if (artAcargar!!.balanza!!.toInt()==1 || artAcargar.balanza!!.toInt()==3 || artAcargar.balanza!!.toInt()==7) mDialogView.etCantidad.inputType=TYPE_CLASS_NUMBER | ||
503 | mDialogView.tvTitulo.text = artAcargar.descripcion.toString() | 489 | mDialogView.tvTitulo.text = artAcargar.descripcion.toString() |
504 | val mAlertDialog = mBuilder.show() | 490 | val mAlertDialog = mBuilder.show() |
505 | mDialogView.btnAceptar.setOnClickListener { | 491 | mDialogView.btnAceptar.setOnClickListener { |
506 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { | 492 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { |
507 | mDialogView.etCantidad.error = "No vacio" | 493 | mDialogView.etCantidad.error = "No vacio" |
508 | mDialogView.etCantidad.requestFocus() | 494 | mDialogView.etCantidad.requestFocus() |
509 | mDialogView.etCantidad.hint = "Ingrese un valor" | 495 | mDialogView.etCantidad.hint = "Ingrese un valor" |
510 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | 496 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { |
511 | mAlertDialog.dismiss() | 497 | mAlertDialog.dismiss() |
512 | cargarArtEnBd(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | 498 | cargarArtEnBd(artAcargar, String.format("%.2f", mDialogView.etCantidad.text.toString().toFloat())) |
513 | cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | 499 | cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) |
514 | } | 500 | } |
515 | } | 501 | } |
516 | } | 502 | } |
517 | 503 | ||
518 | fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String) { | 504 | fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String, cancelable: Boolean) { |
519 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 505 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
520 | val mBuilder = | 506 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.").setCancelable(cancelable) |
521 | AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.") | 507 | // TODO: SI PERMITE QUE INGRESE DECIMALES |
522 | // .setCancelable(false) | 508 | if (univta.contains("1") || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType = TYPE_CLASS_NUMBER |
523 | if (univta.contains("1" ) || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType=TYPE_CLASS_NUMBER | ||
524 | 509 | ||
525 | mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | 510 | mDialogView.tvCantInicial.text = String.format("%.2f", listArticulos[indiceDelArtEncontrado].cantTomada) |
526 | val mAlertDialog = mBuilder.show() | 511 | val mAlertDialog = mBuilder.show() |
527 | mDialogView.rbSumar.setOnClickListener { | 512 | mDialogView.rbSumar.setOnClickListener { |
528 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 513 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
529 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 514 | mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()) |
530 | mDialogView.tvNuevaCantidad.isEnabled=false | 515 | mDialogView.tvNuevaCantidad.isEnabled = false |
531 | } | 516 | } |
532 | } | 517 | } |
533 | mDialogView.rbRestar.setOnClickListener { | 518 | mDialogView.rbRestar.setOnClickListener { |
534 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 519 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
535 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 520 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
536 | mDialogView.tvgenerico4.text = | 521 | mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()) |
537 | (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 522 | mDialogView.tvNuevaCantidad.isEnabled = false |
538 | mDialogView.tvNuevaCantidad.isEnabled=false | 523 | } else { |
524 | mDialogView.tvResultado.text = "" | ||
525 | mDialogView.tvResultado.error = "Operación No Valida" | ||
526 | mDialogView.tvResultado.requestFocus() | ||
527 | mDialogView.tvResultado.hint = "Error" | ||
539 | } | 528 | } |
540 | } | 529 | } |
541 | } | 530 | } |
542 | mDialogView.rbMdodificar.setOnClickListener { | 531 | mDialogView.rbMdodificar.setOnClickListener { |
543 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 532 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
544 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 533 | mDialogView.tvResultado.text = String.format("%.2f", mDialogView.tvNuevaCantidad.text.toString().toFloat()) |
545 | mDialogView.tvNuevaCantidad.isEnabled=false | 534 | mDialogView.tvNuevaCantidad.isEnabled = false |
546 | } | 535 | } |
547 | } | 536 | } |
548 | mDialogView.btnAceptar.setOnClickListener { | 537 | mDialogView.btnAceptar.setOnClickListener { |
549 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 538 | if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || !mDialogView.tvNuevaCantidad.text.isBlank()) { |
550 | mAlertDialog.dismiss() | 539 | if (mDialogView.tvResultado.text.isNotEmpty() || !mDialogView.tvResultado.text.isBlank()) { |
551 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | 540 | mAlertDialog.dismiss() |
552 | // fCant = 0F | 541 | listArticulos[indiceDelArtEncontrado].cantTomada = String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat() |
553 | // fCant = name | 542 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), |
554 | listArticulos[indiceDelArtEncontrado].cantTomada = mDialogView.tvgenerico4.text.toString().toFloat() | 543 | String.format("%.2f", mDialogView.tvResultado.text.toString().toFloat()).toFloat()) |
555 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), mDialogView.tvgenerico4.text.toString().toFloat()) | 544 | |
556 | viewAdapter.notifyDataSetChanged() | 545 | viewAdapter.notifyDataSetChanged() |
557 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 546 | } else if (mDialogView.tvNuevaCantidad.text.isNotEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { |
558 | mDialogView.tvNuevaCantidad.error = "No vacio" | 547 | mDialogView.tvResultado.error = "Operación Requerida" |
548 | mDialogView.tvResultado.requestFocus() | ||
549 | mDialogView.tvResultado.hint = "Seleccione Operación" | ||
550 | } | ||
551 | } else if (mDialogView.tvNuevaCantidad.text.isEmpty() || mDialogView.tvNuevaCantidad.text.isBlank()) { | ||
552 | mDialogView.tvNuevaCantidad.error = "Completar" | ||
559 | mDialogView.tvNuevaCantidad.requestFocus() | 553 | mDialogView.tvNuevaCantidad.requestFocus() |
560 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | 554 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" |
561 | } | 555 | } |
562 | } | 556 | } |
563 | mDialogView.dialogCancelBtn.setOnClickListener { | 557 | mDialogView.dialogCancelBtn.setOnClickListener { |
564 | mAlertDialog.dismiss() | 558 | mAlertDialog.dismiss() |
565 | } | 559 | } |
566 | } | 560 | } |
567 | 561 | ||
568 | suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { | 562 | suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { |
569 | //TODO BUSQUEDA POR CODIGO DE BARRAS | 563 | //TODO BUSQUEDA POR CODIGO DE BARRAS |
570 | var busqueda: Articles? = null | 564 | var busqueda: Articles? = null |
571 | return GlobalScope.async(Dispatchers.IO) { | 565 | return GlobalScope.async(Dispatchers.IO) { |
572 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) | 566 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) |
573 | return@async busqueda | 567 | return@async busqueda |
574 | }.await() | 568 | }.await() |
575 | } | 569 | } |
576 | 570 | ||
577 | suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { | 571 | suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { |
578 | //TODO BUSQUEDA POR DESCRIPCION | 572 | //TODO BUSQUEDA POR DESCRIPCION |
579 | var busqueda: List<Articles>? = null | 573 | var busqueda: List<Articles>? = null |
580 | return GlobalScope.async(Dispatchers.IO) { | 574 | return GlobalScope.async(Dispatchers.IO) { |
581 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) | 575 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) |
582 | return@async busqueda | 576 | return@async busqueda |
583 | }.await() | 577 | }.await() |
584 | } | 578 | } |
585 | 579 | ||
586 | suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { | 580 | suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { |
587 | //TODO BUSQUEDA POR DESCRIPCION | 581 | //TODO BUSQUEDA POR DESCRIPCION |
588 | var result: Int | 582 | var result: Int |
589 | return GlobalScope.async(Dispatchers.IO) { | 583 | return GlobalScope.async(Dispatchers.IO) { |
590 | result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) | 584 | result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) |
591 | return@async result | 585 | return@async result |
592 | }.await() | 586 | }.await() |
593 | } | 587 | } |
594 | 588 | ||
595 | private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { | 589 | private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { |
596 | 590 | ||
597 | return GlobalScope.async(Dispatchers.IO) { | 591 | return GlobalScope.async(Dispatchers.IO) { |
598 | var indice = 0 | 592 | var indice = 0 |
599 | var bEncontrado = false | 593 | var bEncontrado = false |
600 | if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS | 594 | if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS |
601 | // TODO CAMBIO DE CB A CODIGO DEBO | 595 | // TODO CAMBIO DE CB A CODIGO DEBO |
602 | val any = cambioCBporCodigoDebo(codigoBarras) | 596 | val any = cambioCBporCodigoDebo(codigoBarras) |
603 | if (any != null) { | 597 | if (any != null) { |
604 | for (item in listArticulos) { | 598 | for (item in listArticulos) { |
605 | if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { | 599 | if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { |
606 | bEncontrado = true | 600 | bEncontrado = true |
607 | break | 601 | break |
608 | } | 602 | } |
609 | indice += 1 | 603 | indice += 1 |
610 | } | 604 | } |
611 | } | 605 | } |
612 | 606 | ||
613 | } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION | 607 | } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION |
614 | for (item in listArticulos) { | 608 | for (item in listArticulos) { |
615 | if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | 609 | if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
616 | bEncontrado = true | 610 | bEncontrado = true |
617 | break | 611 | break |
618 | } | 612 | } |
619 | indice += 1 | 613 | indice += 1 |
620 | } | 614 | } |
621 | } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | 615 | } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN |
622 | for (item in listArticulos) { | 616 | for (item in listArticulos) { |
623 | if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | 617 | if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
624 | bEncontrado = true | 618 | bEncontrado = true |
625 | break | 619 | break |
626 | } | 620 | } |
627 | indice += 1 | 621 | indice += 1 |
628 | } | 622 | } |
629 | } | 623 | } |
630 | return@async if (bEncontrado) indice else -1 | 624 | return@async if (bEncontrado) indice else -1 |
631 | }.await() | 625 | }.await() |
632 | } | 626 | } |
633 | 627 | ||
634 | suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { | 628 | suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { |
635 | //TODO BUSQUEDA POR DESCRIPCION | 629 | //TODO BUSQUEDA POR DESCRIPCION |
636 | var busqueda: Articles? = null | 630 | var busqueda: Articles? = null |
637 | return GlobalScope.async(Dispatchers.IO) { | 631 | return GlobalScope.async(Dispatchers.IO) { |
638 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) | 632 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) |
639 | return@async busqueda | 633 | return@async busqueda |
640 | }.await() | 634 | }.await() |
641 | } | 635 | } |
642 | 636 | ||
643 | private fun cargarArtEnBd(articulos: Articles, cant: Float) { | 637 | private fun cargarArtEnBd(articulos: Articles, cant: String) { |
644 | val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD | 638 | val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD |
645 | articulos.sector, | 639 | articulos.sector, |
646 | articulos.codigo, | 640 | articulos.codigo, |
647 | articulos.descripcion, | 641 | articulos.descripcion, |
648 | cant.toString(), | 642 | cant, |
649 | articulos.codBar, | 643 | articulos.codBar, |
650 | articulos.codOrigen, | 644 | articulos.codOrigen, |
651 | articulos.precio, | 645 | articulos.precio, |
652 | articulos.precio, | 646 | articulos.precio, |
653 | articulos.balanza, | 647 | articulos.balanza, |
654 | articulos.depSn, | 648 | articulos.depSn, |
655 | ObtenerFechaActual(), | 649 | ObtenerFechaActual(), |
656 | ObtenerFechaActual()) | 650 | ObtenerFechaActual()) |
657 | InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS | 651 | InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS |
658 | } | 652 | } |
659 | 653 | ||
660 | fun cargarRecicler(articulos: Articles, cant: Float) { | 654 | fun cargarRecicler(articulos: Articles, cant: Float) { |
661 | //TODO CARGO EN LE RV | 655 | //TODO CARGO EN LE RV |
662 | val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(),articulos.de.toString()) | 656 | val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(), articulos.de.toString()) |
663 | listArticulos.add(item) | 657 | listArticulos.add(item) |
664 | 658 | ||
665 | viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) | 659 | viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) |
666 | viewManager = LinearLayoutManager(requireContext()) | 660 | viewManager = LinearLayoutManager(requireContext()) |
667 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | 661 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! |
668 | rcInventarios.apply { | 662 | rcInventarios.apply { |
669 | adapter = viewAdapter | 663 | adapter = viewAdapter |
670 | layoutManager = viewManager | 664 | layoutManager = viewManager |
671 | } | 665 | } |
672 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | 666 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { |
673 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | 667 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { |
674 | return false | 668 | return false |
675 | } | 669 | } |
676 | 670 | ||
677 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | 671 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { |
678 | 672 | ||
679 | GlobalScope.launch(Dispatchers.Main) { | 673 | GlobalScope.launch(Dispatchers.Main) { |
680 | borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) | 674 | borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) |
681 | (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | 675 | (viewAdapter as ProductosListAdapter).removeItem(viewHolder) |
682 | viewAdapter.notifyDataSetChanged() | 676 | viewAdapter.notifyDataSetChanged() |
683 | } | 677 | } |
684 | } | 678 | } |
685 | 679 | ||
686 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | 680 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
687 | val itemView = viewHolder.itemView | 681 | val itemView = viewHolder.itemView |
688 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | 682 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 |
689 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | 683 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) |
690 | 684 | ||
691 | if (dX > 0) { | 685 | if (dX > 0) { |
692 | 686 | ||
693 | if (dX < c.width / 2) c.drawColor(Color.GREEN) | 687 | if (dX < c.width / 2) c.drawColor(Color.GREEN) |
694 | else c.drawColor(Color.RED) | 688 | else c.drawColor(Color.RED) |
695 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | 689 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) |
696 | } else { | 690 | } else { |
697 | } | 691 | } |
698 | 692 | ||
699 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 693 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
700 | deleteIcon.draw(c) | 694 | deleteIcon.draw(c) |
701 | } | 695 | } |
702 | } | 696 | } |
703 | 697 | ||
704 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | 698 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) |
705 | itemTouchHelper.attachToRecyclerView(rcInventarios) | 699 | itemTouchHelper.attachToRecyclerView(rcInventarios) |
706 | } | 700 | } |
707 | 701 | ||
708 | private fun ProdNoCont(): Int? { | 702 | private fun ProdNoCont(): Int? { |
709 | var mostrarStock = 0 | 703 | var mostrarStock = 0 |
710 | if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 | 704 | if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 |
711 | return mostrarStock | 705 | return mostrarStock |
712 | } | 706 | } |
713 | 707 | ||
714 | private fun AjusteProductos(): Int? { | 708 | private fun AjusteProductos(): Int? { |
715 | var prodInclu = 0 | 709 | var prodInclu = 0 |
716 | if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 | 710 | if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 |
717 | 711 | ||
718 | if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 | 712 | if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 |
719 | return prodInclu | 713 | return prodInclu |
720 | } | 714 | } |
721 | 715 | ||
722 | private fun SerchArea(): Int { | 716 | private fun SerchArea(): Int { |
723 | if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 | 717 | if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 |
724 | if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 | 718 | if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 |
725 | return iArea | 719 | return iArea |
726 | } | 720 | } |
727 | 721 | ||
728 | fun ObtenerFechaActual(): String? { | 722 | fun ObtenerFechaActual(): String? { |
729 | //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD | 723 | //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD |
730 | val current = LocalDateTime.now() | 724 | val current = LocalDateTime.now() |
731 | val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") | 725 | val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") |
732 | val dFechaHora = current.format(formatter) | 726 | val dFechaHora = current.format(formatter) |
733 | return dFechaHora.toString() | 727 | return dFechaHora.toString() |
734 | } | 728 | } |
735 | 729 | ||
736 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { | 730 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { |
737 | lifecycleScope.launch { | 731 | lifecycleScope.launch { |
738 | withContext(Dispatchers.IO) { | 732 | withContext(Dispatchers.IO) { |
739 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | 733 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) |
740 | } | 734 | } |
741 | } | 735 | } |
742 | } | 736 | } |
743 | 737 | ||
744 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | 738 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { |
745 | lifecycleScope.launch { | 739 | lifecycleScope.launch { |
746 | withContext(Dispatchers.IO) { | 740 | withContext(Dispatchers.IO) { |
747 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | 741 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) |
748 | } | 742 | } |
749 | } | 743 | } |
750 | } | 744 | } |
751 | 745 | ||
752 | suspend fun cargarInventario(inventario: Int): List<InvBody>? { | 746 | suspend fun cargarInventario(inventario: Int): List<InvBody>? { |
753 | return GlobalScope.async(Dispatchers.IO) { | 747 | return GlobalScope.async(Dispatchers.IO) { |
754 | return@async AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.fetchAllInvBody(inventario) | 748 | return@async AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.fetchAllInvBody(inventario) |
755 | }.await() | 749 | }.await() |
756 | } | 750 | } |
757 | 751 | ||
758 | override fun onImageDotsClick(sector: String?, codigo: String?) { | 752 | override fun onImageDotsClick(sector: String?, codigo: String?) { |
759 | val bundle = Bundle() | 753 | val bundle = Bundle() |
760 | bundle.putString("sector", sector) | 754 | bundle.putString("sector", sector) |
761 | bundle.putString("codigo", codigo) | 755 | bundle.putString("codigo", codigo) |
762 | bundle.putInt("numeroInv", InventarioNuevo) | 756 | bundle.putInt("numeroInv", InventarioNuevo) |
763 | navController.navigate(R.id.action_inventarioFragment_to_detalleArtFragment, bundle) | 757 | navController.navigate(R.id.action_inventarioFragment_to_detalleArtFragment, bundle) |
764 | } | 758 | } |
765 | 759 | ||
766 | override fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) { | 760 | override fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) { |
767 | dialogoSumaResta(requireContext(), position.toInt(), listArticulos[position.toInt()].univta) | 761 | dialogoSumaResta(requireContext(), position.toInt(), listArticulos[position.toInt()].univta, true) |
768 | 762 | ||
769 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 763 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
770 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[position.toInt()].descripcion}") | 764 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[position.toInt()].descripcion}") |
771 | //// .setCancelable(false) | 765 | //// .setCancelable(false) |
772 | // mDialogView.tvCantInicial.text = cantidad | 766 | // mDialogView.tvCantInicial.text = cantidad |
773 | // val mAlertDialog = mBuilder.show() | 767 | // val mAlertDialog = mBuilder.show() |
774 | // mDialogView.rbSumar.setOnClickListener { | 768 | // mDialogView.rbSumar.setOnClickListener { |
775 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 769 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
776 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 770 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
777 | // mDialogView.tvNuevaCantidad.isEnabled=false | 771 | // mDialogView.tvNuevaCantidad.isEnabled=false |
778 | // } | 772 | // } |
779 | // } | 773 | // } |
780 | // mDialogView.rbRestar.setOnClickListener { | 774 | // mDialogView.rbRestar.setOnClickListener { |
781 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 775 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
782 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 776 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
783 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 777 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
784 | // mDialogView.tvNuevaCantidad.isEnabled=false | 778 | // mDialogView.tvNuevaCantidad.isEnabled=false |
785 | // } | 779 | // } |
786 | // } | 780 | // } |
787 | // } | 781 | // } |
788 | // mDialogView.rbMdodificar.setOnClickListener { | 782 | // mDialogView.rbMdodificar.setOnClickListener { |
789 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 783 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
790 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 784 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
791 | // mDialogView.tvNuevaCantidad.isEnabled=false | 785 | // mDialogView.tvNuevaCantidad.isEnabled=false |
792 | // } | 786 | // } |
793 | // } | 787 | // } |
794 | // mDialogView.btnAceptar.setOnClickListener { | 788 | // mDialogView.btnAceptar.setOnClickListener { |
795 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 789 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
796 | // mAlertDialog.dismiss() | 790 | // mAlertDialog.dismiss() |
797 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | 791 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() |
798 | // fCant = 0F | 792 | // fCant = 0F |
799 | // fCant = name | 793 | // fCant = name |
800 | // listArticulos[position.toInt()].cantTomada = fCant | 794 | // listArticulos[position.toInt()].cantTomada = fCant |
801 | // updateCantidad(listArticulos[position.toInt()].sector.toString(), listArticulos[position.toInt()].codigo.toString(), fCant) | 795 | // updateCantidad(listArticulos[position.toInt()].sector.toString(), listArticulos[position.toInt()].codigo.toString(), fCant) |
802 | // viewAdapter.notifyDataSetChanged() | 796 | // viewAdapter.notifyDataSetChanged() |
803 | // } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 797 | // } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
804 | // mDialogView.tvNuevaCantidad.error = "No vacio" | 798 | // mDialogView.tvNuevaCantidad.error = "No vacio" |
805 | // mDialogView.tvNuevaCantidad.requestFocus() | 799 | // mDialogView.tvNuevaCantidad.requestFocus() |
806 | // mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | 800 | // mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" |
807 | // } | 801 | // } |
808 | // } | 802 | // } |
809 | // mDialogView.dialogCancelBtn.setOnClickListener { | 803 | // mDialogView.dialogCancelBtn.setOnClickListener { |
810 | // mAlertDialog.dismiss() | 804 | // mAlertDialog.dismiss() |
811 | // } | 805 | // } |
812 | } | 806 | } |
813 | } | 807 | } |
814 | 808 | ||
815 | 809 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/InventarioListAdapter.kt
1 | package com.focasoftware.deboinventariov20.ui.main | 1 | package com.focasoftware.deboinventariov20.ui.main |
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.Model.InvHead | 8 | import com.focasoftware.deboinventariov20.Model.InvHead |
9 | import com.focasoftware.deboinventariov20.R | 9 | import com.focasoftware.deboinventariov20.R |
10 | import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder | 10 | import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder |
11 | import kotlinx.android.synthetic.main.item_principal.view.* | 11 | import kotlinx.android.synthetic.main.item_principal.view.* |
12 | 12 | ||
13 | class InventarioListAdapter(private val context: Context, private val inv: List<InvHead>, private val itemClickListener: OnInventarioClickListener) : | 13 | class InventarioListAdapter(private val context: Context, private val inv: List<InvHead>, private val itemClickListener: OnInventarioClickListener) : |
14 | RecyclerView.Adapter<BaseViewHolder<*>>() { | 14 | RecyclerView.Adapter<BaseViewHolder<*>>() { |
15 | 15 | ||
16 | interface OnInventarioClickListener { | 16 | interface OnInventarioClickListener { |
17 | fun onItemClick(inventario: String?) | 17 | fun onItemClick(inventario: String?) |
18 | } | 18 | } |
19 | 19 | ||
20 | override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item_principal, parent, false)) | 20 | override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item_principal, parent, false)) |
21 | 21 | ||
22 | override fun getItemCount() = inv.size | 22 | override fun getItemCount() = inv.size |
23 | 23 | ||
24 | 24 | ||
25 | inner class ItemsViewHolder(itemView: View) : BaseViewHolder<InvHead>(itemView) { | 25 | inner class ItemsViewHolder(itemView: View) : BaseViewHolder<InvHead>(itemView) { |
26 | override fun bind(item: InvHead, position: Int) { | 26 | override fun bind(item: InvHead, position: Int) { |
27 | itemView.setOnClickListener {itemClickListener.onItemClick(item.invNum.toString())} | 27 | itemView.setOnClickListener {itemClickListener.onItemClick(item.invNum.toString())} |
28 | itemView.tvPrincipalinventario.text = item.invNum.toString() | 28 | itemView.tvPrincipalinventario.text = if ( item.invNum < 10) "0${ item.invNum.toString()}" else item.invNum.toString() |
29 | |||
29 | itemView.tvDescription.text=item.descripcion.toString() | 30 | itemView.tvDescription.text=item.descripcion.toString() |
31 | itemView.tvFecha.text=item.fechaInicio.toString() | ||
32 | itemView.tvCantContada.text=item.prodContados.toString() | ||
30 | } | 33 | } |
31 | } | 34 | } |
32 | 35 | ||
33 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | 36 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { |
34 | when (holder) { | 37 | when (holder) { |
35 | is ItemsViewHolder -> holder.bind(inv[position], position) | 38 | is ItemsViewHolder -> holder.bind(inv[position], position) |
36 | else -> IllegalArgumentException("No se pudo pasar el ViewHolder") | 39 | else -> IllegalArgumentException("No se pudo pasar el ViewHolder") |
37 | } | 40 | } |
38 | } | 41 | } |
39 | 42 | ||
40 | 43 | ||
41 | } | 44 | } |
42 | 45 | ||
43 | 46 | ||
44 | 47 | ||
45 | 48 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
1 | package com.focasoftware.deboinventariov20.ui.main | 1 | package com.focasoftware.deboinventariov20.ui.main |
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.navigation.NavController | 11 | import androidx.navigation.NavController |
12 | import androidx.navigation.Navigation | 12 | import androidx.navigation.Navigation |
13 | import androidx.recyclerview.widget.LinearLayoutManager | 13 | import androidx.recyclerview.widget.LinearLayoutManager |
14 | import androidx.recyclerview.widget.RecyclerView | 14 | import androidx.recyclerview.widget.RecyclerView |
15 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 15 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
16 | import com.focasoftware.deboinventariov20.Model.InvHead | 16 | import com.focasoftware.deboinventariov20.Model.InvHead |
17 | import com.focasoftware.deboinventariov20.R | 17 | import com.focasoftware.deboinventariov20.R |
18 | import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | 18 | import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler |
19 | import kotlinx.coroutines.Dispatchers | 19 | import kotlinx.coroutines.Dispatchers |
20 | import kotlinx.coroutines.GlobalScope | 20 | import kotlinx.coroutines.GlobalScope |
21 | import kotlinx.coroutines.async | 21 | import kotlinx.coroutines.async |
22 | import kotlinx.coroutines.launch | 22 | import kotlinx.coroutines.launch |
23 | import java.util.* | 23 | import java.util.* |
24 | 24 | ||
25 | class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { | 25 | class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { |
26 | private lateinit var inventarios: List<InvHead> | 26 | private lateinit var inventarios: List<InvHead> |
27 | private lateinit var ordenado: List<InvHead> | 27 | private lateinit var ordenado: List<InvHead> |
28 | private lateinit var rcInventario: RecyclerView | 28 | private lateinit var rcInventario: RecyclerView |
29 | private lateinit var viewAdapter: RecyclerView.Adapter<*> | 29 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
30 | private lateinit var viewManager: RecyclerView.LayoutManager | 30 | private lateinit var viewManager: RecyclerView.LayoutManager |
31 | // private var listIvn2 = List<InvHead>() | 31 | // private var listIvn2 = List<InvHead>() |
32 | private var listIvn2 = ArrayList<InvHead>() | 32 | private var listIvn2 = ArrayList<InvHead>() |
33 | private lateinit var navController: NavController | 33 | private lateinit var navController: NavController |
34 | private lateinit var sharedPreferences: SharedPreferences | 34 | private lateinit var sharedPreferences: SharedPreferences |
35 | private var cantidadInventarios: Int = 0 | 35 | private var cantidadInventarios: Int = 0 |
36 | 36 | ||
37 | override fun onCreate(savedInstanceState: Bundle?) { | 37 | override fun onCreate(savedInstanceState: Bundle?) { |
38 | super.onCreate(savedInstanceState) | 38 | super.onCreate(savedInstanceState) |
39 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 39 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
40 | } | 40 | } |
41 | 41 | ||
42 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 42 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
43 | var bAbiertoCerrado = false | 43 | var bAbiertoCerrado = false |
44 | val v = inflater.inflate(R.layout.fragment_main, container, false) | 44 | val v = inflater.inflate(R.layout.fragment_main, container, false) |
45 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) | 45 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) |
46 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) | 46 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) |
47 | val ivSort19= v.findViewById<ImageButton>(R.id.ivSort19) | 47 | val ivSort19= v.findViewById<ImageButton>(R.id.ivSort19) |
48 | val ivSort91= v.findViewById<ImageButton>(R.id.ivSort91) | 48 | val ivSort91= v.findViewById<ImageButton>(R.id.ivSort91) |
49 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) | 49 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) |
50 | val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) | 50 | val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) |
51 | 51 | val tvTipo = v.findViewById<TextView>(R.id.tvTipo) | |
52 | rcInventario = v.findViewById(R.id.rcInventario) | 52 | rcInventario = v.findViewById(R.id.rcInventario) |
53 | 53 | ||
54 | GlobalScope.launch(Dispatchers.Main) { | 54 | GlobalScope.launch(Dispatchers.Main) { |
55 | inventarios = buscarEnBDInvHead() | 55 | inventarios = buscarEnBDInvHead() |
56 | for ((i, item) in inventarios.withIndex()) { | 56 | for ((i, item) in inventarios.withIndex()) { |
57 | val inv = InvHead(inventarios[i].invNum, | 57 | val inv = InvHead(inventarios[i].invNum, |
58 | inventarios[i].descripcion, | 58 | inventarios[i].descripcion, |
59 | inventarios[i].estado, | 59 | inventarios[i].estado, |
60 | inventarios[i].fechaInicio, | 60 | inventarios[i].fechaInicio, |
61 | inventarios[i].fechaFinal, | 61 | inventarios[i].fechaFinal, |
62 | inventarios[i].prodContados, | 62 | inventarios[i].prodContados, |
63 | inventarios[i].lugar, | 63 | inventarios[i].lugar, |
64 | inventarios[i].stDesc, | 64 | inventarios[i].stDesc, |
65 | inventarios[i].proNoCont) | 65 | inventarios[i].proNoCont) |
66 | cargarRecicler(inv) | 66 | cargarRecicler(inv) |
67 | cantidadInventarios = i + 1 | 67 | cantidadInventarios = i + 1 |
68 | } | 68 | } |
69 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | 69 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" |
70 | tvInvDinamicos.setOnClickListener { | 70 | tvInvDinamicos.setOnClickListener { |
71 | if (!bAbiertoCerrado) { | 71 | if (!bAbiertoCerrado) { |
72 | bAbiertoCerrado = true | 72 | bAbiertoCerrado = true |
73 | txtDeposito.visibility = View.GONE | 73 | txtDeposito.visibility = View.GONE |
74 | rcInventario.visibility = View.VISIBLE | 74 | rcInventario.visibility = View.VISIBLE |
75 | ivSort91.visibility = View.INVISIBLE | 75 | ivSort91.visibility = View.INVISIBLE |
76 | ivSort19.visibility = View.VISIBLE | 76 | ivSort19.visibility = View.VISIBLE |
77 | cbVentas.visibility = View.VISIBLE | 77 | cbVentas.visibility = View.VISIBLE |
78 | cbDeposito.visibility = View.VISIBLE | 78 | cbDeposito.visibility = View.VISIBLE |
79 | tvTipo.visibility = View.VISIBLE | ||
79 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" | 80 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" |
80 | } else { | 81 | } else { |
81 | bAbiertoCerrado = false | 82 | bAbiertoCerrado = false |
82 | rcInventario.visibility = View.GONE | 83 | rcInventario.visibility = View.GONE |
83 | ivSort91.visibility = View.GONE | 84 | ivSort91.visibility = View.GONE |
84 | ivSort19.visibility = View.GONE | 85 | ivSort19.visibility = View.GONE |
85 | txtDeposito.visibility = View.VISIBLE | 86 | txtDeposito.visibility = View.VISIBLE |
86 | cbVentas.visibility = View.GONE | 87 | cbVentas.visibility = View.GONE |
87 | cbDeposito.visibility = View.GONE | 88 | cbDeposito.visibility = View.GONE |
89 | tvTipo.visibility = View.GONE | ||
88 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" | 90 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" |
89 | } | 91 | } |
90 | } | 92 | } |
91 | ivSort19.setOnClickListener { | 93 | ivSort19.setOnClickListener { |
92 | ordenado= inventarios.sortedByDescending { | 94 | ordenado= inventarios.sortedByDescending { |
93 | it.invNum | 95 | it.invNum |
94 | } | 96 | } |
95 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | 97 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) |
96 | viewManager = LinearLayoutManager(requireContext()) | 98 | viewManager = LinearLayoutManager(requireContext()) |
97 | 99 | ||
98 | rcInventario.apply { | 100 | rcInventario.apply { |
99 | adapter = viewAdapter | 101 | adapter = viewAdapter |
100 | layoutManager = viewManager | 102 | layoutManager = viewManager |
101 | } | 103 | } |
102 | viewAdapter.notifyDataSetChanged() | 104 | viewAdapter.notifyDataSetChanged() |
103 | ivSort19.visibility=View.INVISIBLE | 105 | ivSort19.visibility=View.INVISIBLE |
104 | ivSort91.visibility=View.VISIBLE | 106 | ivSort91.visibility=View.VISIBLE |
105 | } | 107 | } |
106 | ivSort91.setOnClickListener { | 108 | ivSort91.setOnClickListener { |
107 | ordenado= inventarios.sortedBy { | 109 | ordenado= inventarios.sortedBy { |
108 | it.invNum | 110 | it.invNum |
109 | } | 111 | } |
110 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | 112 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) |
111 | viewManager = LinearLayoutManager(requireContext()) | 113 | viewManager = LinearLayoutManager(requireContext()) |
112 | 114 | ||
113 | rcInventario.apply { | 115 | rcInventario.apply { |
114 | adapter = viewAdapter | 116 | adapter = viewAdapter |
115 | layoutManager = viewManager | 117 | layoutManager = viewManager |
116 | } | 118 | } |
117 | viewAdapter.notifyDataSetChanged() | 119 | viewAdapter.notifyDataSetChanged() |
118 | ivSort91.visibility=View.INVISIBLE | 120 | ivSort91.visibility=View.INVISIBLE |
119 | ivSort19.visibility=View.VISIBLE | 121 | ivSort19.visibility=View.VISIBLE |
120 | } | 122 | } |
121 | } | 123 | } |
122 | return v | 124 | return v |
123 | } | 125 | } |
124 | 126 | ||
125 | suspend fun buscarEnBDInvHead(): List<InvHead> { | 127 | suspend fun buscarEnBDInvHead(): List<InvHead> { |
126 | //TODO BUSQUEDA POR DESCRIPCION | 128 | //TODO BUSQUEDA POR DESCRIPCION |
127 | var busqueda: List<InvHead> | 129 | var busqueda: List<InvHead> |
128 | return GlobalScope.async(Dispatchers.IO) { | 130 | return GlobalScope.async(Dispatchers.IO) { |
129 | busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() | 131 | busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() |
130 | return@async busqueda | 132 | return@async busqueda |
131 | }.await() | 133 | }.await() |
132 | } | 134 | } |
133 | 135 | ||
134 | fun cargarRecicler(inv: InvHead) { | 136 | fun cargarRecicler(inv: InvHead) { |
135 | //TODO CARGO EN LE RV | 137 | //TODO CARGO EN LE RV |
136 | 138 | ||
137 | // val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() | 139 | // val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() |
138 | // val item = ItemInventario("N° $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") | 140 | // val item = ItemInventario("N° $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") |
139 | 141 | ||
140 | // listIvn.add(item) | 142 | // listIvn.add(item) |
141 | listIvn2.add(inv) | 143 | listIvn2.add(inv) |
142 | viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) | 144 | viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) |
143 | viewManager = LinearLayoutManager(requireContext()) | 145 | viewManager = LinearLayoutManager(requireContext()) |
144 | 146 | ||
145 | rcInventario.apply { | 147 | rcInventario.apply { |
146 | adapter = viewAdapter | 148 | adapter = viewAdapter |
147 | layoutManager = viewManager | 149 | layoutManager = viewManager |
148 | } | 150 | } |
149 | } | 151 | } |
150 | 152 | ||
151 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 153 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
152 | super.onViewCreated(view, savedInstanceState) | 154 | super.onViewCreated(view, savedInstanceState) |
153 | navController = Navigation.findNavController(view) | 155 | navController = Navigation.findNavController(view) |
154 | listIvn2.clear() | 156 | listIvn2.clear() |
155 | } | 157 | } |
156 | 158 | ||
157 | override fun onItemClick(inventario: String?) { | 159 | override fun onItemClick(inventario: String?) { |
158 | 160 | ||
159 | val editor = sharedPreferences.edit() | 161 | val editor = sharedPreferences.edit() |
160 | // var invSel: String = inventario.toString() | 162 | // var invSel: String = inventario.toString() |
161 | // invSel = invSel.substring(3, 5) | 163 | // invSel = invSel.substring(3, 5) |
162 | editor?.putString("Inventario", inventario) | 164 | editor?.putString("Inventario", inventario) |
163 | editor?.apply() | 165 | editor?.apply() |
164 | editor.commit() | 166 | editor.commit() |
165 | navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) | 167 | navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | } | 171 | } |
170 | 172 | ||
171 | 173 |
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}/", 0) |
55 | ingresarDatos(servidor) | 55 | ingresarDatos(servidor) |
56 | cargarRecicler(servidor) | 56 | cargarRecicler(servidor) |
57 | Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() | 57 | Toast.makeText(requireContext(), "Servidor ${etNombreServidor.text} Guardado", Toast.LENGTH_LONG).show() |
58 | etNombreServidor.text.clear() | 58 | etNombreServidor.text.clear() |
59 | etDireccionServidor.text.clear() | 59 | etDireccionServidor.text.clear() |
60 | // } | 60 | // } |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 65 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
66 | val v = inflater.inflate(R.layout.fragment_servidores, container, false) | 66 | val v = inflater.inflate(R.layout.fragment_servidores, container, false) |
67 | rvServidores = v.findViewById(R.id.rvServidores) | 67 | rvServidores = v.findViewById(R.id.rvServidores) |
68 | return v | 68 | return v |
69 | } | 69 | } |
70 | 70 | ||
71 | fun ingresarDatos(servidor: ServeInv) { | 71 | fun ingresarDatos(servidor: ServeInv) { |
72 | val Job = GlobalScope.launch { | 72 | val Job = GlobalScope.launch { |
73 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) | 73 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.insertServer(servidor) |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | suspend fun buscarEnBD(): List<ServeInv> { | 77 | suspend fun buscarEnBD(): List<ServeInv> { |
78 | var busqueda: List<ServeInv> | 78 | var busqueda: List<ServeInv> |
79 | return GlobalScope.async(Dispatchers.IO) { | 79 | return GlobalScope.async(Dispatchers.IO) { |
80 | busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() | 80 | busqueda = AppDb.getAppDb(requireContext())!!.ServeInvDao()!!.fetchAllServers() |
81 | return@async busqueda | 81 | return@async busqueda |
82 | }.await() | 82 | }.await() |
83 | } | 83 | } |
84 | 84 | ||
85 | fun CargarRV() { | 85 | fun CargarRV() { |
86 | GlobalScope.launch(Dispatchers.Main) { | 86 | GlobalScope.launch(Dispatchers.Main) { |
87 | servidores = buscarEnBD() | 87 | servidores = buscarEnBD() |
88 | for ((i, item) in servidores.withIndex()) { | 88 | for ((i, item) in servidores.withIndex()) { |
89 | val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) | 89 | val ser = ServeInv(servidores[i].descripcion, servidores[i].direccion, servidores[i].predeterminado) |
90 | cargarRecicler(ser) | 90 | cargarRecicler(ser) |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | fun cargarRecicler(ser: ServeInv) { | 95 | fun cargarRecicler(ser: ServeInv) { |
96 | //TODO CARGO EN LE RV | 96 | //TODO CARGO EN LE RV |
97 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | 97 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! |
98 | val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado) | 98 | val item = ItemsServidores(ser.descripcion, ser.direccion, ser.predeterminado.toString()) |
99 | 99 | ||
100 | listServ.add(item) | 100 | listServ.add(item) |
101 | 101 | ||
102 | viewAdapter = AdapterServidores(listServ, requireContext()) | 102 | viewAdapter = AdapterServidores(listServ, requireContext()) |
103 | viewManager = LinearLayoutManager(requireContext()) | 103 | viewManager = LinearLayoutManager(requireContext()) |
104 | 104 | ||
105 | rvServidores.apply { | 105 | rvServidores.apply { |
106 | adapter = viewAdapter | 106 | adapter = viewAdapter |
107 | layoutManager = viewManager | 107 | layoutManager = viewManager |
108 | } | 108 | } |
109 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | 109 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { |
110 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | 110 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { |
111 | return false | 111 | return false |
112 | } | 112 | } |
113 | 113 | ||
114 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | 114 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { |
115 | GlobalScope.launch(Dispatchers.Main) { | 115 | GlobalScope.launch(Dispatchers.Main) { |
116 | deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) | 116 | deleteServer(listServ[viewHolder.adapterPosition].descripcion.toString(), listServ[viewHolder.adapterPosition].direccion.toString()) |
117 | 117 | ||
118 | (viewAdapter as AdapterServidores).removeItem(viewHolder) | 118 | (viewAdapter as AdapterServidores).removeItem(viewHolder) |
119 | viewAdapter.notifyDataSetChanged() | 119 | viewAdapter.notifyDataSetChanged() |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | 123 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
124 | val itemView = viewHolder.itemView | 124 | val itemView = viewHolder.itemView |
125 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | 125 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 |
126 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | 126 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) |
127 | 127 | ||
128 | if (dX > 0) { | 128 | if (dX > 0) { |
129 | 129 | ||
130 | if (dX < c.width / 2) c.drawColor(Color.GREEN) | 130 | if (dX < c.width / 2) c.drawColor(Color.GREEN) |
131 | else c.drawColor(Color.RED) | 131 | else c.drawColor(Color.RED) |
132 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | 132 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) |
133 | } else { | 133 | } else { |
134 | } | 134 | } |
135 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 135 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
136 | deleteIcon.draw(c) | 136 | deleteIcon.draw(c) |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | 140 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) |
141 | itemTouchHelper.attachToRecyclerView(rvServidores) | 141 | itemTouchHelper.attachToRecyclerView(rvServidores) |
142 | } | 142 | } |
143 | 143 | ||
144 | suspend fun deleteServer(serverName: String, serverDir: String) { | 144 | suspend fun deleteServer(serverName: String, serverDir: String) { |
145 | lifecycleScope.launch { | 145 | lifecycleScope.launch { |
146 | withContext(Dispatchers.IO) { | 146 | withContext(Dispatchers.IO) { |
147 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) | 147 | AppDb.getAppDb(requireActivity())!!.ServeInvDao()!!.deleteServer(serverName, serverDir) |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/DialogNoEncontrado.kt
File was created | 1 | package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.os.Bundle | ||
6 | import androidx.fragment.app.DialogFragment | ||
7 | |||
8 | class DialogNoEncontrado : DialogFragment() { | ||
9 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
10 | return activity?.let { | ||
11 | val title = "Busqueda de Productos" | ||
12 | val content = "Producto no encotrado." | ||
13 | val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | ||
14 | builder.setTitle(title).setMessage(content).setPositiveButton(android.R.string.ok) { _, _ -> | ||
15 | //Todo OK click | ||
16 | } | ||
17 | return builder.create() | ||
18 | } ?: throw IllegalStateException("Activity cannot be null") | ||
19 | } | ||
20 | } | ||
21 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/DialogoLogin.kt
File was created | 1 | package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.content.SharedPreferences | ||
6 | import android.os.Bundle | ||
7 | import androidx.fragment.app.DialogFragment | ||
8 | import com.focasoftware.deboinventariov20.R | ||
9 | |||
10 | class DialogoLogin() : DialogFragment() { | ||
11 | private lateinit var sharedPreferences: SharedPreferences | ||
12 | |||
13 | interface OnContinueCancelClickListener { | ||
14 | fun onPositiveClick() | ||
15 | fun onCancelClick() | ||
16 | } | ||
17 | |||
18 | fun newInstance(s: String): DialogoLogin? { | ||
19 | val dialog = DialogoLogin() | ||
20 | |||
21 | val args = Bundle() | ||
22 | args.putString("title", s) | ||
23 | dialog.arguments = args | ||
24 | |||
25 | return dialog | ||
26 | } | ||
27 | |||
28 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
29 | return activity?.let { | ||
30 | val builder = AlertDialog.Builder(it) | ||
31 | |||
32 | val inflater = requireActivity().layoutInflater; | ||
33 | |||
34 | builder.setView(inflater.inflate(R.layout.login_dialog, null)).setTitle("El producto ya fue escaneado").setPositiveButton(android.R.string.ok) { _, _ -> | ||
35 | val listener = activity as OnContinueCancelClickListener? | ||
36 | listener!!.onPositiveClick() | ||
37 | }.setNegativeButton(android.R.string.cancel) { _, _ -> | ||
38 | val listener = activity as OnContinueCancelClickListener? | ||
39 | listener!!.onCancelClick() | ||
40 | } | ||
41 | builder.create() | ||
42 | } ?: throw IllegalStateException("Activity cannot be null") | ||
43 | } | ||
44 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/InsertCant.kt
File was created | 1 | package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.content.SharedPreferences | ||
6 | import android.os.Bundle | ||
7 | import androidx.fragment.app.DialogFragment | ||
8 | import com.focasoftware.deboinventariov20.R | ||
9 | |||
10 | class InsertCant() : DialogFragment() { | ||
11 | |||
12 | private lateinit var sharedPreferences: SharedPreferences | ||
13 | |||
14 | interface OnContinueCancelClickListener { | ||
15 | fun onPositiveClick() | ||
16 | fun onCancelClick() | ||
17 | } | ||
18 | |||
19 | fun newInstance(s: String): InsertCant? { | ||
20 | val dialog = InsertCant() | ||
21 | |||
22 | val args = Bundle() | ||
23 | args.putString("title", s) | ||
24 | dialog.arguments = args | ||
25 | |||
26 | return dialog | ||
27 | } | ||
28 | |||
29 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
30 | return activity?.let { | ||
31 | val builder = AlertDialog.Builder(it) | ||
32 | |||
33 | val inflater = requireActivity().layoutInflater; | ||
34 | |||
35 | builder.setView(inflater.inflate(R.layout.ingresar_cantidad, null)).setTitle("").setPositiveButton(android.R.string.ok) { _, _ -> | ||
36 | val listener = activity as OnContinueCancelClickListener? | ||
37 | listener!!.onPositiveClick() | ||
38 | }.setNegativeButton(android.R.string.cancel) { _, _ -> | ||
39 | val listener = activity as OnContinueCancelClickListener? | ||
40 | listener!!.onCancelClick() | ||
41 | } | ||
42 | builder.create() | ||
43 | } ?: throw IllegalStateException("Activity cannot be null") | ||
44 | } | ||
45 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/util/Base/dialogos/SingleChoiceAlertDialog.kt
File was created | 1 | package com.focasoftware.deboinventariov20.ui.util.Base.dialogos | |
2 | |||
3 | import android.app.AlertDialog | ||
4 | import android.app.Dialog | ||
5 | import android.os.Bundle | ||
6 | import androidx.fragment.app.DialogFragment | ||
7 | |||
8 | class SingleChoiceAlertDialog : DialogFragment() { | ||
9 | |||
10 | interface OnDialogSelectorListener { | ||
11 | fun onSelectedOption(dialogId: Int) | ||
12 | } | ||
13 | |||
14 | |||
15 | var mDialogSelectorCallback: OnDialogSelectorListener? = null | ||
16 | |||
17 | fun newInstance(title: String, values: Array<String>, selected: Int = -1): SingleChoiceAlertDialog? { | ||
18 | val dialog = SingleChoiceAlertDialog() | ||
19 | |||
20 | val args = Bundle() | ||
21 | args.putString("title", title) | ||
22 | args.putStringArray("values", values) | ||
23 | args.putInt("selected", selected) | ||
24 | dialog.arguments = args | ||
25 | |||
26 | return dialog | ||
27 | |||
28 | } | ||
29 | |||
30 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
31 | |||
32 | return activity?.let { | ||
33 | |||
34 | val args = requireArguments() | ||
35 | val title = args.getString("title") | ||
36 | val values = args.getStringArray("values") | ||
37 | val selectedIndex = args.getInt("selected") | ||
38 | |||
39 | val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) | ||
40 | |||
41 | builder.setSingleChoiceItems(values, selectedIndex) { _, which -> | ||
42 | //val item = values?.get(which) | ||
43 | mDialogSelectorCallback?.onSelectedOption(which) | ||
44 | dialog?.dismiss() | ||
45 | } | ||
46 | builder.setTitle(title) | ||
47 | |||
48 | return builder.create() | ||
49 | } ?: throw IllegalStateException("Activity cannot be null") | ||
50 | } | ||
51 | |||
52 | |||
53 | } |
app/src/main/res/layout/fragment_descripcion.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | ||
3 | 3 | ||
4 | <androidx.constraintlayout.widget.ConstraintLayout | 4 | <androidx.constraintlayout.widget.ConstraintLayout |
5 | xmlns:android="http://schemas.android.com/apk/res/android" | 5 | xmlns:android="http://schemas.android.com/apk/res/android" |
6 | xmlns:app="http://schemas.android.com/apk/res-auto" | 6 | xmlns:app="http://schemas.android.com/apk/res-auto" |
7 | xmlns:tools="http://schemas.android.com/tools" | 7 | xmlns:tools="http://schemas.android.com/tools" |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="match_parent" | 9 | android:layout_height="match_parent" |
10 | tools:context=".ui.descripcionFragment.DescripcionFragment"> | 10 | tools:context=".ui.descripcionFragment.DescripcionFragment"> |
11 | 11 | ||
12 | 12 | ||
13 | <androidx.recyclerview.widget.RecyclerView | 13 | <androidx.recyclerview.widget.RecyclerView |
14 | android:id="@+id/rcDescripcion" | 14 | android:id="@+id/rcDescripcion" |
15 | android:layout_width="match_parent" | 15 | android:layout_width="match_parent" |
16 | android:layout_height="0dp" | 16 | android:layout_height="0dp" |
17 | android:background="@android:color/darker_gray" | 17 | android:background="@android:color/darker_gray" |
18 | android:scrollbars="vertical" | 18 | android:scrollbars="vertical" |
19 | app:layout_constraintTop_toBottomOf="@id/guideline4" | 19 | app:layout_constraintTop_toBottomOf="@id/guideline4" |
20 | app:layout_constraintBottom_toTopOf="@+id/guideline5" | 20 | app:layout_constraintBottom_toTopOf="@+id/guideline6" |
21 | app:layout_constraintEnd_toEndOf="parent" | 21 | app:layout_constraintEnd_toEndOf="parent" |
22 | app:layout_constraintStart_toStartOf="parent" | 22 | app:layout_constraintStart_toStartOf="parent" |
23 | tools:listitem="@layout/item" /> | 23 | tools:listitem="@layout/item" /> |
24 | 24 | ||
25 | <Button | 25 | <!-- <Button--> |
26 | android:id="@+id/btnSalir" | 26 | <!-- android:id="@+id/btnSalir"--> |
27 | android:layout_width="0dp" | 27 | <!-- android:layout_width="0dp"--> |
28 | android:layout_height="wrap_content" | 28 | <!-- android:layout_height="wrap_content"--> |
29 | android:text="@string/btnCancelar" | 29 | <!-- android:text="@string/btnCancelar"--> |
30 | android:textColor="@android:color/white" | 30 | <!-- android:textColor="@android:color/white"--> |
31 | android:padding="10dp" | 31 | <!-- android:padding="10dp"--> |
32 | android:background="@drawable/boton_borde_redondeado" | 32 | <!-- android:background="@drawable/boton_borde_redondeado"--> |
33 | app:layout_constraintBottom_toBottomOf="@+id/guideline6" | 33 | <!-- app:layout_constraintBottom_toBottomOf="@+id/guideline6"--> |
34 | app:layout_constraintEnd_toEndOf="parent" | 34 | <!-- app:layout_constraintEnd_toEndOf="parent"--> |
35 | app:layout_constraintHorizontal_chainStyle="spread" | 35 | <!-- app:layout_constraintHorizontal_chainStyle="spread"--> |
36 | app:layout_constraintStart_toStartOf="parent" | 36 | <!-- app:layout_constraintStart_toStartOf="parent"--> |
37 | app:layout_constraintTop_toBottomOf="@+id/rcInventarios" /> | 37 | <!-- app:layout_constraintTop_toBottomOf="@+id/rcInventarios" />--> |
38 | 38 | ||
39 | <androidx.constraintlayout.widget.Guideline | 39 | <androidx.constraintlayout.widget.Guideline |
40 | android:id="@+id/guideline4" | 40 | android:id="@+id/guideline4" |
41 | android:layout_width="wrap_content" | 41 | android:layout_width="wrap_content" |
42 | android:layout_height="wrap_content" | 42 | android:layout_height="wrap_content" |
43 | android:orientation="horizontal" | 43 | android:orientation="horizontal" |
44 | app:layout_constraintGuide_percent="0.06" /> | 44 | app:layout_constraintGuide_percent="0.06" /> |
45 | 45 | ||
46 | <androidx.constraintlayout.widget.Guideline | 46 | <androidx.constraintlayout.widget.Guideline |
47 | android:id="@+id/guideline5" | 47 | android:id="@+id/guideline5" |
48 | android:layout_width="wrap_content" | 48 | android:layout_width="wrap_content" |
49 | android:layout_height="wrap_content" | 49 | android:layout_height="wrap_content" |
50 | android:orientation="horizontal" | 50 | android:orientation="horizontal" |
51 | app:layout_constraintGuide_percent="0.88" /> | 51 | app:layout_constraintGuide_percent="0.88" /> |
52 | 52 | ||
53 | <androidx.constraintlayout.widget.Guideline | 53 | <androidx.constraintlayout.widget.Guideline |
54 | android:id="@+id/guideline6" | 54 | android:id="@+id/guideline6" |
55 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
56 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
57 | android:orientation="horizontal" | 57 | android:orientation="horizontal" |
58 | app:layout_constraintGuide_percent="0.97" /> | 58 | app:layout_constraintGuide_percent="0.97" /> |
59 | </androidx.constraintlayout.widget.ConstraintLayout> | 59 | </androidx.constraintlayout.widget.ConstraintLayout> |
60 | 60 |
app/src/main/res/layout/fragment_main.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"> | 6 | android:layout_height="match_parent"> |
7 | 7 | ||
8 | <androidx.appcompat.widget.AppCompatTextView | 8 | <androidx.appcompat.widget.AppCompatTextView |
9 | android:id="@+id/tvInvDinamicos" | 9 | android:id="@+id/tvInvDinamicos" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="90dp" | 11 | android:layout_height="90dp" |
12 | android:autoSizeMaxTextSize="150sp" | 12 | android:autoSizeMaxTextSize="150sp" |
13 | android:autoSizeMinTextSize="25sp" | 13 | android:autoSizeMinTextSize="25sp" |
14 | android:autoSizeStepGranularity="5sp" | 14 | android:autoSizeStepGranularity="5sp" |
15 | android:autoSizeTextType="uniform" | 15 | android:autoSizeTextType="uniform" |
16 | android:gravity="center" | 16 | android:gravity="center" |
17 | android:padding="10dp" | 17 | android:padding="10dp" |
18 | android:text="@string/invDinamicoVenta" | 18 | android:text="@string/invDinamicoVenta" |
19 | android:textColor="@color/colorAccent" | 19 | android:textColor="@color/colorAccent" |
20 | android:visibility="visible" | 20 | android:visibility="visible" |
21 | app:fontFamily="sans-serif" | 21 | app:fontFamily="sans-serif" |
22 | app:layout_constraintEnd_toEndOf="parent" | 22 | app:layout_constraintEnd_toEndOf="parent" |
23 | app:layout_constraintStart_toStartOf="parent" | 23 | app:layout_constraintStart_toStartOf="parent" |
24 | app:layout_constraintTop_toTopOf="parent" /> | 24 | app:layout_constraintTop_toTopOf="parent" /> |
25 | 25 | ||
26 | <androidx.appcompat.widget.AppCompatImageButton | 26 | <androidx.appcompat.widget.AppCompatImageButton |
27 | android:id="@+id/ivSort19" | 27 | android:id="@+id/ivSort19" |
28 | android:layout_width="50dp" | 28 | android:layout_width="50dp" |
29 | android:layout_height="50dp" | 29 | android:layout_height="50dp" |
30 | android:layout_margin="10dp" | 30 | android:layout_marginStart="10dp" |
31 | android:padding="5dp" | 31 | android:padding="5dp" |
32 | android:visibility="gone" | ||
33 | android:src="@drawable/ic_sort19" | 32 | android:src="@drawable/ic_sort19" |
33 | android:visibility="gone" | ||
34 | app:layout_constraintHorizontal_bias="0.0" | 34 | app:layout_constraintHorizontal_bias="0.0" |
35 | app:layout_constraintHorizontal_chainStyle="packed" | 35 | app:layout_constraintHorizontal_chainStyle="packed" |
36 | app:layout_constraintStart_toStartOf="parent" | 36 | app:layout_constraintStart_toStartOf="parent" |
37 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | 37 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
38 | 38 | ||
39 | <androidx.appcompat.widget.AppCompatImageButton | 39 | <androidx.appcompat.widget.AppCompatImageButton |
40 | android:id="@+id/ivSort91" | 40 | android:id="@+id/ivSort91" |
41 | android:layout_width="50dp" | 41 | android:layout_width="50dp" |
42 | android:layout_height="50dp" | 42 | android:layout_height="50dp" |
43 | android:layout_margin="10dp" | 43 | android:layout_marginStart="10dp" |
44 | android:padding="5dp" | 44 | android:padding="5dp" |
45 | android:layout_marginTop="12dp" | ||
46 | android:visibility="gone" | ||
47 | android:src="@drawable/ic_sort91" | 45 | android:src="@drawable/ic_sort91" |
48 | app:layout_constraintHorizontal_bias="1.0" | 46 | android:visibility="gone" |
49 | app:layout_constraintHorizontal_chainStyle="packed" | 47 | app:layout_constraintHorizontal_chainStyle="packed" |
50 | app:layout_constraintStart_toStartOf="parent" | 48 | app:layout_constraintStart_toStartOf="parent" |
51 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | 49 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
52 | 50 | ||
53 | 51 | <TextView | |
54 | <androidx.recyclerview.widget.RecyclerView | 52 | android:id="@+id/tvTipo" |
55 | android:id="@+id/rcInventario" | 53 | android:layout_width="wrap_content" |
56 | android:layout_width="match_parent" | 54 | android:layout_height="wrap_content" |
57 | android:layout_height="0dp" | 55 | android:layout_margin="5dp" |
58 | android:background="@android:color/darker_gray" | 56 | android:text="Tipo:" |
59 | android:scrollbars="vertical" | 57 | android:layout_marginTop="12dp" |
58 | android:textSize="15sp" | ||
60 | android:visibility="gone" | 59 | android:visibility="gone" |
61 | app:layout_constraintEnd_toEndOf="parent" | 60 | app:layout_constraintBaseline_toBaselineOf="@+id/cbVentas" |
62 | app:layout_constraintStart_toStartOf="parent" | 61 | app:layout_constraintEnd_toStartOf="@+id/cbVentas" /> |
63 | app:layout_constraintTop_toBottomOf="@id/ivSort19" | ||
64 | tools:listitem="@layout/item_principal" /> | ||
65 | 62 | ||
66 | <com.google.android.material.checkbox.MaterialCheckBox | 63 | <com.google.android.material.checkbox.MaterialCheckBox |
67 | android:id="@+id/cbVentas" | 64 | android:id="@+id/cbVentas" |
68 | android:layout_width="wrap_content" | 65 | android:layout_width="wrap_content" |
69 | android:layout_height="wrap_content" | 66 | android:layout_height="wrap_content" |
70 | android:layout_margin="5dp" | 67 | android:layout_margin="5dp" |
71 | android:text="Ventas" | ||
72 | android:checked="true" | 68 | android:checked="true" |
69 | android:text="Ventas" | ||
70 | android:layout_marginTop="12dp" | ||
73 | android:visibility="gone" | 71 | android:visibility="gone" |
74 | app:layout_constraintEnd_toStartOf="@+id/cbDeposito" | 72 | app:layout_constraintEnd_toStartOf="@+id/cbDeposito" |
75 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> | 73 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
76 | 74 | ||
77 | <com.google.android.material.checkbox.MaterialCheckBox | 75 | <com.google.android.material.checkbox.MaterialCheckBox |
78 | android:id="@+id/cbDeposito" | 76 | android:id="@+id/cbDeposito" |
79 | android:layout_width="wrap_content" | 77 | android:layout_width="wrap_content" |
80 | android:layout_height="wrap_content" | 78 | android:layout_height="wrap_content" |
81 | android:layout_margin="5dp" | 79 | android:layout_margin="5dp" |
82 | android:visibility="gone" | ||
83 | android:text="Deposito" | ||
84 | android:checked="true" | 80 | android:checked="true" |
81 | android:text="Deposito" | ||
82 | android:layout_marginTop="12dp" | ||
83 | android:visibility="gone" | ||
85 | app:layout_constraintEnd_toEndOf="parent" | 84 | app:layout_constraintEnd_toEndOf="parent" |
86 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> | 85 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
87 | 86 | ||
88 | <androidx.appcompat.widget.AppCompatTextView | 87 | <androidx.recyclerview.widget.RecyclerView |
89 | android:id="@+id/txtDeposito" | 88 | android:id="@+id/rcInventario" |
90 | android:layout_width="match_parent" | 89 | android:layout_width="match_parent" |
91 | android:layout_height="90dp" | 90 | android:layout_height="0dp" |
92 | android:autoSizeMaxTextSize="150sp" | 91 | android:background="@android:color/darker_gray" |
93 | android:autoSizeMinTextSize="25sp" | 92 | android:scrollbars="vertical" |
94 | android:autoSizeStepGranularity="5sp" | 93 | android:visibility="gone" |
95 | android:autoSizeTextType="uniform" | 94 | app:layout_constraintEnd_toEndOf="parent" |
96 | android:gravity="start" | 95 | app:layout_constraintStart_toStartOf="parent" |
97 | android:lines="1" | 96 | app:layout_constraintTop_toBottomOf="@id/ivSort19" |
98 | android:padding="10dp" | 97 | tools:listitem="@layout/item_principal" /> |
99 | android:text="@string/invDinamicoCompra" | 98 | |
100 | android:textColor="@color/colorAccent" | 99 | |
101 | android:visibility="visible" | 100 | <androidx.appcompat.widget.AppCompatTextView |
102 | app:fontFamily="sans-serif-condensed" | 101 | android:id="@+id/txtDeposito" |
103 | app:layout_constraintBottom_toBottomOf="parent" | 102 | android:layout_width="match_parent" |
104 | app:layout_constraintEnd_toEndOf="parent" | 103 | android:layout_height="90dp" |
105 | app:layout_constraintStart_toStartOf="parent" | 104 | android:autoSizeMaxTextSize="150sp" |
106 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" | 105 | android:autoSizeMinTextSize="25sp" |
107 | app:layout_constraintVertical_bias="0.0" /> | 106 | android:autoSizeStepGranularity="5sp" |
107 | android:autoSizeTextType="uniform" | ||
108 | android:gravity="start" | ||
109 | android:lines="1" | ||
110 | android:padding="10dp" | ||
111 | android:text="@string/invDinamicoCompra" | ||
112 | android:textColor="@color/colorAccent" |
app/src/main/res/layout/item_principal.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="5dp" | 8 | app:cardCornerRadius="5dp" |
9 | app:cardElevation="10dp" | 9 | app:cardElevation="10dp" |
10 | app:cardPreventCornerOverlap="false"> | 10 | app:cardPreventCornerOverlap="false"> |
11 | 11 | ||
12 | <androidx.constraintlayout.widget.ConstraintLayout | 12 | <androidx.constraintlayout.widget.ConstraintLayout |
13 | android:layout_width="match_parent" | 13 | android:layout_width="match_parent" |
14 | android:layout_height="wrap_content" | 14 | android:layout_height="wrap_content" |
15 | android:layout_gravity="center_horizontal|center_vertical" | 15 | android:layout_gravity="center_horizontal|center_vertical" |
16 | android:orientation="vertical"> | 16 | android:orientation="vertical"> |
17 | 17 | ||
18 | <!-- <androidx.appcompat.widget.AppCompatImageView--> | ||
19 | <!-- android:id="@+id/ivCamara"--> | ||
20 | <!-- android:layout_width="80dp"--> | ||
21 | <!-- android:layout_height="80dp"--> | ||
22 | <!-- android:layout_margin="10dp"--> | ||
23 | <!-- android:layout_marginTop="15dp"--> | ||
24 | <!-- android:background="@drawable/boton_redondo2"--> | ||
25 | <!-- android:clickable="true"--> | ||
26 | <!-- android:contentDescription="@string/ibBusCB"--> | ||
27 | <!-- android:elevation="5dp"--> | ||
28 | <!-- android:focusable="false"--> | ||
29 | <!-- android:scaleType="fitEnd"--> | ||
30 | <!-- --> | ||
31 | <!-- app:layout_constraintBottom_toTopOf="@+id/ivFondo"--> | ||
32 | <!-- app:layout_constraintCircleRadius="40dp"--> | ||
33 | <!-- app:layout_constraintStart_toStartOf="parent"--> | ||
34 | <!-- app:layout_constraintTop_toTopOf="parent"--> | ||
35 | <!-- />--> | ||
36 | |||
37 | <TextView | 18 | <TextView |
38 | android:id="@+id/tvPrincipalinventario" | 19 | android:id="@+id/tvPrincipalinventario" |
39 | android:layout_width="50dp" | 20 | android:layout_width="50dp" |
40 | android:layout_height="50dp" | 21 | android:layout_height="50dp" |
41 | android:layout_margin="10dp" | 22 | android:layout_margin="10dp" |
23 | android:background="@drawable/boton_redondo2" | ||
42 | android:gravity="center" | 24 | android:gravity="center" |
43 | android:lines="2" | 25 | android:lines="2" |
44 | android:background="@drawable/boton_redondo2" | ||
45 | android:textColor="@android:color/black" | 26 | android:textColor="@android:color/black" |
46 | android:textSize="@dimen/TitulosMedios" | 27 | android:textSize="@dimen/TitulosMedios" |
47 | android:textStyle="bold" | 28 | android:textStyle="bold" |
48 | app:layout_constraintBottom_toTopOf="@+id/ivFondo" | 29 | app:layout_constraintBottom_toTopOf="@+id/ivFondo" |
49 | app:layout_constraintStart_toStartOf="parent" | 30 | app:layout_constraintStart_toStartOf="parent" |
50 | app:layout_constraintTop_toTopOf="parent" | 31 | app:layout_constraintTop_toTopOf="parent" |
51 | tools:text="99" /> | 32 | tools:text="99" /> |
52 | 33 | ||
53 | <TextView | 34 | <TextView |
35 | android:id="@+id/textView6" | ||
36 | android:layout_width="wrap_content" | ||
37 | android:layout_height="wrap_content" | ||
38 | android:layout_marginTop="5dp" | ||
39 | android:text="Fecha Inicio" | ||
40 | android:textSize="15sp" | ||
41 | android:textStyle="bold" | ||
42 | app:layout_constraintEnd_toEndOf="parent" | ||
43 | app:layout_constraintHorizontal_bias="0.217" | ||
44 | app:layout_constraintStart_toEndOf="@id/tvPrincipalinventario" | ||
45 | app:layout_constraintTop_toTopOf="parent" /> | ||
46 | |||
47 | <TextView | ||
48 | android:id="@+id/tvFecha" | ||
49 | android:layout_width="wrap_content" | ||
50 | android:layout_height="wrap_content" | ||
51 | android:layout_marginStart="5dp" | ||
52 | android:text="01/01/2020 12:20:20" | ||
53 | android:textSize="15sp" | ||
54 | android:textStyle="bold" | ||
55 | app:layout_constraintBaseline_toBaselineOf="@+id/textView6" | ||
56 | app:layout_constraintEnd_toEndOf="parent" | ||
57 | app:layout_constraintHorizontal_bias="0.0" | ||
58 | app:layout_constraintStart_toEndOf="@id/textView6" /> | ||
59 | |||
60 | <TextView | ||
61 | android:id="@+id/textView7" | ||
62 | android:layout_width="wrap_content" | ||
63 | android:layout_height="wrap_content" | ||
64 | android:layout_marginTop="4dp" | ||
65 | android:text="Art. Contados" | ||
66 | android:textSize="15sp" | ||
67 | android:textStyle="bold" | ||
68 | app:layout_constraintEnd_toEndOf="parent" | ||
69 | app:layout_constraintHorizontal_bias="0.23" | ||
70 | app:layout_constraintStart_toEndOf="@+id/tvPrincipalinventario" | ||
71 | app:layout_constraintTop_toBottomOf="@id/textView6" /> | ||
72 | |||
73 | <TextView | ||
74 | android:id="@+id/tvCantContada" | ||
75 | android:layout_width="wrap_content" | ||
76 | android:layout_height="wrap_content" | ||
77 | android:layout_marginTop="4dp" | ||
78 | android:layout_marginStart="5dp" | ||
79 | android:text="002" | ||
80 | android:textSize="15sp" | ||
81 | android:textStyle="bold" | ||
82 | app:layout_constraintBaseline_toBaselineOf="@+id/textView7" | ||
83 | app:layout_constraintStart_toEndOf="@+id/textView7" | ||
84 | app:layout_constraintTop_toBottomOf="@+id/tvFecha" /> | ||
85 | |||
86 | <TextView | ||
54 | android:id="@+id/tvDescription" | 87 | android:id="@+id/tvDescription" |
55 | android:layout_width="wrap_content" | 88 | android:layout_width="wrap_content" |
56 | android:layout_height="wrap_content" | 89 | android:layout_height="wrap_content" |
57 | android:text="prueba" | 90 | android:text="prueba" |
58 | app:layout_constraintBottom_toTopOf="@id/ivFondo" | 91 | app:layout_constraintBottom_toTopOf="@id/ivFondo" |
59 | app:layout_constraintEnd_toEndOf="parent" | 92 | app:layout_constraintEnd_toEndOf="parent" |
app/src/main/res/layout/login_dialog.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout 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 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="wrap_content" | 5 | android:layout_height="wrap_content" |
6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
7 | android:padding="10dp"> | 7 | android:padding="10dp"> |
8 | 8 | ||
9 | <TextView | 9 | <TextView |
10 | android:id="@+id/dialogNameEt" | 10 | android:id="@+id/dialogNameEt" |
11 | android:layout_width="wrap_content" | 11 | android:layout_width="wrap_content" |
12 | android:layout_height="wrap_content" | 12 | android:layout_height="wrap_content" |
13 | android:layout_margin="5dp" | 13 | android:layout_margin="5dp" |
14 | android:text="Cantidad actual:" | 14 | android:text="Cantidad actual:" |
15 | android:textSize="20sp" | 15 | android:textSize="20sp" |
16 | app:layout_constraintEnd_toStartOf="@id/tvCantInicial" | 16 | app:layout_constraintEnd_toStartOf="@id/tvCantInicial" |
17 | app:layout_constraintHorizontal_bias="0.0" | 17 | app:layout_constraintHorizontal_bias="0.0" |
18 | app:layout_constraintHorizontal_chainStyle="packed" | 18 | app:layout_constraintHorizontal_chainStyle="packed" |
19 | app:layout_constraintStart_toStartOf="parent" | 19 | app:layout_constraintStart_toStartOf="parent" |
20 | app:layout_constraintTop_toTopOf="parent" /> | 20 | app:layout_constraintTop_toTopOf="parent" /> |
21 | 21 | ||
22 | <TextView | 22 | <TextView |
23 | android:id="@+id/tvCantInicial" | 23 | android:id="@+id/tvCantInicial" |
24 | android:layout_width="wrap_content" | 24 | android:layout_width="wrap_content" |
25 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |
26 | android:layout_margin="5dp" | 26 | android:layout_margin="5dp" |
27 | android:text="" | 27 | android:text="" |
28 | android:textSize="20sp" | 28 | android:textSize="20sp" |
29 | app:layout_constraintBaseline_toBaselineOf="@+id/dialogNameEt" | 29 | app:layout_constraintBaseline_toBaselineOf="@+id/dialogNameEt" |
30 | app:layout_constraintEnd_toEndOf="parent" | 30 | app:layout_constraintEnd_toEndOf="parent" |
31 | app:layout_constraintHorizontal_chainStyle="packed" | 31 | app:layout_constraintHorizontal_chainStyle="packed" |
32 | app:layout_constraintStart_toEndOf="@id/dialogNameEt" /> | 32 | app:layout_constraintStart_toEndOf="@id/dialogNameEt" /> |
33 | 33 | ||
34 | <TextView | 34 | <TextView |
35 | android:id="@+id/tvgenerico" | 35 | android:id="@+id/tvgenerico" |
36 | android:layout_width="wrap_content" | 36 | android:layout_width="wrap_content" |
37 | android:layout_height="wrap_content" | 37 | android:layout_height="wrap_content" |
38 | android:layout_margin="5dp" | 38 | android:layout_margin="5dp" |
39 | android:text="Nueva cantidad:" | 39 | android:text="Nueva cantidad:" |
40 | android:textSize="20sp" | 40 | android:textSize="20sp" |
41 | app:layout_constraintStart_toStartOf="parent" | 41 | app:layout_constraintStart_toStartOf="parent" |
42 | app:layout_constraintTop_toBottomOf="@+id/tvCantInicial" /> | 42 | app:layout_constraintTop_toBottomOf="@+id/tvCantInicial" /> |
43 | 43 | ||
44 | <EditText | 44 | <EditText |
45 | android:id="@+id/tvNuevaCantidad" | 45 | android:id="@+id/tvNuevaCantidad" |
46 | android:layout_width="0dp" | 46 | android:layout_width="0dp" |
47 | android:layout_height="wrap_content" | 47 | android:layout_height="wrap_content" |
48 | android:autofillHints="" | ||
48 | android:hint="" | 49 | android:hint="" |
49 | android:inputType="numberDecimal" | 50 | android:inputType="numberDecimal" |
50 | app:layout_constraintBaseline_toBaselineOf="@+id/tvgenerico" | 51 | app:layout_constraintBaseline_toBaselineOf="@+id/tvgenerico" |
51 | app:layout_constraintEnd_toEndOf="parent" | 52 | app:layout_constraintEnd_toEndOf="parent" |
52 | app:layout_constraintStart_toEndOf="@id/tvgenerico" | 53 | app:layout_constraintStart_toEndOf="@id/tvgenerico" /> |
53 | android:autofillHints="" /> | ||
54 | 54 | ||
55 | <TextView | 55 | <TextView |
56 | android:id="@+id/tvgenerico2" | 56 | android:id="@+id/tvgenerico2" |
57 | android:layout_width="wrap_content" | 57 | android:layout_width="wrap_content" |
58 | android:layout_height="wrap_content" | 58 | android:layout_height="wrap_content" |
59 | android:layout_margin="5dp" | 59 | android:layout_margin="5dp" |
60 | android:visibility="gone" | ||
61 | android:gravity="center" | 60 | android:gravity="center" |
62 | android:text="@string/tvSeleccion" | 61 | android:text="@string/tvSeleccion" |
63 | android:textSize="20sp" | 62 | android:textSize="20sp" |
63 | android:visibility="gone" | ||
64 | app:layout_constraintStart_toStartOf="parent" | 64 | app:layout_constraintStart_toStartOf="parent" |
65 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico" /> | 65 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico" /> |
66 | 66 | ||
67 | <RadioGroup | 67 | <RadioGroup |
68 | android:id="@+id/rgFechaHora" | 68 | android:id="@+id/rgFechaHora" |
69 | android:layout_width="wrap_content" | 69 | android:layout_width="wrap_content" |
70 | android:layout_height="wrap_content" | 70 | android:layout_height="wrap_content" |
71 | android:layout_margin="5dp" | ||
72 | android:gravity="start" | 71 | android:gravity="start" |
73 | android:orientation="horizontal" | 72 | android:orientation="horizontal" |
74 | app:layout_constraintEnd_toEndOf="parent" | 73 | app:layout_constraintEnd_toEndOf="parent" |
75 | app:layout_constraintHorizontal_bias="0.0" | 74 | app:layout_constraintHorizontal_bias="0.0" |
76 | app:layout_constraintStart_toStartOf="parent" | 75 | app:layout_constraintStart_toStartOf="parent" |
77 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico2"> | 76 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico2"> |
78 | 77 | ||
79 | <RadioButton | 78 | <RadioButton |
80 | android:id="@+id/rbSumar" | 79 | android:id="@+id/rbSumar" |
81 | android:layout_width="wrap_content" | 80 | android:layout_width="wrap_content" |
82 | android:layout_height="wrap_content" | 81 | android:layout_height="wrap_content" |
83 | android:layout_margin="5dp" | 82 | android:layout_margin="5dp" |
84 | android:checked="false" | 83 | android:checked="false" |
85 | android:padding="5dp" | 84 | |
86 | android:text="@string/rbSumar" | 85 | android:text="@string/rbSumar" |
87 | android:textSize="@dimen/text_size2" /> | 86 | android:textSize="@dimen/text_size2" /> |
88 | 87 | ||
89 | <RadioButton | 88 | <RadioButton |
90 | android:id="@+id/rbRestar" | 89 | android:id="@+id/rbMdodificar" |
91 | android:layout_width="wrap_content" | 90 | android:layout_width="wrap_content" |
92 | android:layout_height="wrap_content" | 91 | android:layout_height="wrap_content" |
93 | android:layout_margin="5dp" | 92 | android:layout_margin="5dp" |
94 | android:checked="false" | 93 | android:checked="false" |
95 | android:padding="5dp" | 94 | android:text="@string/rbModificar" |
96 | android:text="@string/rbRestar" | ||
97 | android:textSize="@dimen/text_size2" /> | 95 | android:textSize="@dimen/text_size2" /> |
98 | 96 | ||
99 | <RadioButton | 97 | <RadioButton |
100 | android:id="@+id/rbMdodificar" | 98 | android:id="@+id/rbRestar" |
101 | android:layout_width="wrap_content" | 99 | android:layout_width="wrap_content" |
102 | android:layout_height="wrap_content" | 100 | android:layout_height="wrap_content" |
103 | android:layout_margin="5dp" | 101 | android:layout_margin="5dp" |
104 | android:checked="false" | 102 | android:checked="false" |
105 | android:padding="5dp" | 103 | android:padding="5dp" |
106 | android:text="@string/rbModificar" | 104 | android:text="@string/rbRestar" |
107 | android:textSize="@dimen/text_size2" /> | 105 | android:textSize="@dimen/text_size2" /> |
106 | |||
108 | </RadioGroup> | 107 | </RadioGroup> |
109 | 108 | ||
110 | <TextView | 109 | <TextView |
111 | android:id="@+id/tvgenerico3" | 110 | android:id="@+id/tvgenerico3" |
112 | android:layout_width="wrap_content" | 111 | android:layout_width="wrap_content" |
113 | android:layout_height="wrap_content" | 112 | android:layout_height="wrap_content" |
114 | android:layout_margin="5dp" | 113 | android:layout_margin="5dp" |
115 | android:gravity="center" | 114 | android:gravity="center" |
116 | android:text="@string/tvResultado" | 115 | android:text="@string/tvResultado" |
117 | android:textSize="20sp" | 116 | android:textSize="20sp" |
118 | app:layout_constraintEnd_toEndOf="parent" | 117 | app:layout_constraintEnd_toEndOf="parent" |
119 | app:layout_constraintHorizontal_bias="0.0" | 118 | app:layout_constraintHorizontal_bias="0.0" |
120 | app:layout_constraintStart_toStartOf="parent" | 119 | app:layout_constraintStart_toStartOf="parent" |
121 | app:layout_constraintTop_toBottomOf="@+id/rgFechaHora" /> | 120 | app:layout_constraintTop_toBottomOf="@+id/rgFechaHora" /> |
122 | 121 | ||
123 | <TextView | 122 | <TextView |
124 | android:id="@+id/tvgenerico4" | 123 | android:id="@+id/tvResultado" |
125 | android:layout_width="wrap_content" | 124 | android:layout_width="wrap_content" |
126 | android:layout_height="wrap_content" | 125 | android:layout_height="wrap_content" |
127 | android:layout_margin="5dp" | 126 | android:layout_margin="5dp" |
128 | android:gravity="center" | 127 | android:gravity="center" |
129 | android:text="" | 128 | android:text="" |
130 | android:textSize="20sp" | 129 | android:textSize="20sp" |
131 | app:layout_constraintEnd_toEndOf="parent" | 130 | app:layout_constraintEnd_toEndOf="parent" |
132 | app:layout_constraintHorizontal_bias="0.0" | 131 | app:layout_constraintHorizontal_bias="0.0" |
133 | app:layout_constraintStart_toEndOf="@+id/tvgenerico3" | 132 | app:layout_constraintStart_toEndOf="@+id/tvgenerico3" |
134 | app:layout_constraintTop_toBottomOf="@+id/rgFechaHora" /> | 133 | app:layout_constraintTop_toBottomOf="@+id/rgFechaHora" /> |
135 | 134 | ||
136 | <LinearLayout | 135 | <LinearLayout |
137 | android:layout_width="match_parent" | 136 | android:layout_width="match_parent" |
137 | android:layout_height="wrap_content" | ||
138 | android:gravity="center" | ||
139 | android:orientation="horizontal" | ||
140 | app:layout_constraintEnd_toEndOf="parent" | ||
141 | app:layout_constraintStart_toStartOf="parent" | ||
142 | app:layout_constraintTop_toBottomOf="@+id/tvResultado"> | ||
143 | |||
144 | <Button | ||
145 | android:id="@+id/btnAceptar" | ||
146 | style="@style/Base.Widget.AppCompat.Button.Colored" | ||
147 | android:layout_width="wrap_content" | ||
148 | android:layout_height="wrap_content" | ||
149 | android:layout_margin="5dp" | ||
150 | android:background="@drawable/boton_borde_redondeado" | ||
151 | android:padding="20dp" | ||
152 | android:text="@string/btnOk" | ||
153 | android:textColor="@android:color/white" /> | ||
154 | |||
155 | <Button | ||
156 | android:id="@+id/dialogCancelBtn" | ||
157 | style="@style/Base.Widget.AppCompat.Button.Colored" | ||
158 | android:layout_width="wrap_content" | ||
138 | android:layout_height="wrap_content" | 159 | android:layout_height="wrap_content" |
139 | android:orientation="horizontal" | 160 | android:layout_margin="5dp" |
140 | android:gravity="center" | 161 | android:background="@drawable/boton_borde_redondeado" |
141 | app:layout_constraintStart_toStartOf="parent" | 162 | android:padding="20dp" |
142 | app:layout_constraintEnd_toEndOf="parent" | 163 | android:text="@string/btnCancelar" |
143 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico4"> | 164 | android:textColor="@android:color/white" /> |
app/src/main/res/navigation/mobile_navigation.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <navigation xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <navigation 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:id="@+id/mobile_navigation" | 5 | android:id="@+id/mobile_navigation" |
6 | app:startDestination="@id/mainFragment2"> | 6 | app:startDestination="@id/mainFragment2"> |
7 | 7 | ||
8 | <activity | 8 | <activity |
9 | android:id="@+id/mainActivity" | 9 | android:id="@+id/mainActivity" |
10 | android:name="com.focasoftware.deboinventariov20.ui.MainActivity" | 10 | android:name="com.focasoftware.deboinventariov20.ui.MainActivity" |
11 | android:label="app_bar_main" | 11 | android:label="app_bar_main" |
12 | tools:layout="@layout/app_bar_main" /> | 12 | tools:layout="@layout/app_bar_main" /> |
13 | <fragment | 13 | <fragment |
14 | android:id="@+id/mainFragment2" | 14 | android:id="@+id/mainFragment2" |
15 | android:name="com.focasoftware.deboinventariov20.ui.main.MainFragment" | 15 | android:name="com.focasoftware.deboinventariov20.ui.main.MainFragment" |
16 | android:label="Principal" | 16 | android:label="Principal" |
17 | tools:layout="@layout/fragment_main" > | 17 | tools:layout="@layout/fragment_main" > |
18 | <action | 18 | <action |
19 | android:id="@+id/action_mainFragment2_to_configuracionFragment" | 19 | android:id="@+id/action_mainFragment2_to_configuracionFragment" |
20 | app:destination="@id/configuracionFragment" | 20 | app:destination="@id/configuracionFragment" |
21 | app:popEnterAnim="@anim/slide_in_left" | 21 | app:popEnterAnim="@anim/slide_in_left" |
22 | app:popExitAnim="@anim/slide_out_right" | 22 | app:popExitAnim="@anim/slide_out_right" |
23 | app:enterAnim="@anim/slide_in_right" | 23 | app:enterAnim="@anim/slide_in_right" |
24 | app:exitAnim="@anim/slide_out_left" /> | 24 | app:exitAnim="@anim/slide_out_left" /> |
25 | <action | 25 | <action |
26 | android:id="@+id/action_mainFragment2_to_actuaMaestrosFragment" | 26 | android:id="@+id/action_mainFragment2_to_actuaMaestrosFragment" |
27 | app:destination="@id/actuaMaestrosFragment" | 27 | app:destination="@id/actuaMaestrosFragment" |
28 | app:popEnterAnim="@anim/slide_in_left" | 28 | app:popEnterAnim="@anim/slide_in_left" |
29 | app:popExitAnim="@anim/slide_out_right" | 29 | app:popExitAnim="@anim/slide_out_right" |
30 | app:enterAnim="@anim/slide_in_right" | 30 | app:enterAnim="@anim/slide_in_right" |
31 | app:exitAnim="@anim/slide_out_left" /> | 31 | app:exitAnim="@anim/slide_out_left" /> |
32 | <action | 32 | <action |
33 | android:id="@+id/action_mainFragment2_to_inventarioFragment" | 33 | android:id="@+id/action_mainFragment2_to_inventarioFragment" |
34 | app:destination="@id/inventarioFragment" | 34 | app:destination="@id/inventarioFragment" |
35 | app:popEnterAnim="@anim/slide_in_left" | 35 | app:popEnterAnim="@anim/slide_in_left" |
36 | app:popExitAnim="@anim/slide_out_right" | 36 | app:popExitAnim="@anim/slide_out_right" |
37 | app:enterAnim="@anim/slide_in_right" | 37 | app:enterAnim="@anim/slide_in_right" |
38 | app:exitAnim="@anim/slide_out_left" /> | 38 | app:exitAnim="@anim/slide_out_left" /> |
39 | </fragment> | 39 | </fragment> |
40 | <fragment | 40 | <fragment |
41 | android:id="@+id/actuaMaestrosFragment" | 41 | android:id="@+id/actuaMaestrosFragment" |
42 | android:name="com.focasoftware.deboinventariov20.ui.actualizacionMaestros.ActuaMaestrosFragment" | 42 | android:name="com.focasoftware.deboinventariov20.ui.actualizacionMaestros.ActuaMaestrosFragment" |
43 | android:label="Importaciones Varias" | 43 | android:label="Importaciones Varias" |
44 | tools:layout="@layout/fragment_actua_maestros" /> | 44 | tools:layout="@layout/fragment_actua_maestros" /> |
45 | 45 | ||
46 | <fragment | 46 | <fragment |
47 | android:id="@+id/servidoresFragment" | 47 | android:id="@+id/servidoresFragment" |
48 | android:name="com.focasoftware.deboinventariov20.ui.servidores.ServidoresFragment" | 48 | android:name="com.focasoftware.deboinventariov20.ui.servidores.ServidoresFragment" |
49 | android:label="Alta Servidores" | 49 | android:label="Alta Servidores" |
50 | tools:layout="@layout/fragment_servidores"> | 50 | tools:layout="@layout/fragment_servidores"> |
51 | <action | 51 | <action |
52 | android:id="@+id/action_servidoresFragment_to_configuracionFragment" | 52 | android:id="@+id/action_servidoresFragment_to_configuracionFragment" |
53 | app:destination="@id/configuracionFragment" | 53 | app:destination="@id/configuracionFragment" |
54 | app:popUpTo="@id/servidoresFragment" | 54 | app:popUpTo="@id/servidoresFragment" |
55 | app:popUpToInclusive="true" /> | 55 | app:popUpToInclusive="true" /> |
56 | </fragment> | 56 | </fragment> |
57 | 57 | ||
58 | <fragment | 58 | <fragment |
59 | android:id="@+id/inventarioFragment" | 59 | android:id="@+id/inventarioFragment" |
60 | android:name="com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment" | 60 | android:name="com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment" |
61 | android:label="Inventario Dinamico" | 61 | android:label="Inventario Dinamico" |
62 | tools:layout="@layout/fragment_inventario" > | 62 | tools:layout="@layout/fragment_inventario" > |
63 | <action | 63 | <action |
64 | android:id="@+id/action_inventarioFragment_to_descripcionFragment" | 64 | android:id="@+id/action_inventarioFragment_to_descripcionFragment" |
65 | app:destination="@id/descripcionFragment" | 65 | app:destination="@id/descripcionFragment" |
66 | app:popEnterAnim="@anim/slide_in_left" | 66 | app:popEnterAnim="@anim/slide_in_left" |
67 | app:popExitAnim="@anim/slide_out_right" | 67 | app:popExitAnim="@anim/slide_out_right" |
68 | app:enterAnim="@anim/slide_in_right" | 68 | app:enterAnim="@anim/slide_in_right" |
69 | app:exitAnim="@anim/slide_out_left" | 69 | app:exitAnim="@anim/slide_out_left" |
70 | app:popUpTo="@+id/inventarioFragment" | 70 | /> |
71 | app:popUpToInclusive="true"/> | ||
72 | <action | 71 | <action |
73 | android:id="@+id/action_inventarioFragment_to_mainFragment2" | 72 | android:id="@+id/action_inventarioFragment_to_mainFragment2" |
74 | app:destination="@id/mainFragment2" | 73 | app:destination="@id/mainFragment2" |
75 | app:popEnterAnim="@anim/slide_in_left" | 74 | app:popEnterAnim="@anim/slide_in_left" |
76 | app:popExitAnim="@anim/slide_out_right" | 75 | app:popExitAnim="@anim/slide_out_right" |
77 | app:enterAnim="@anim/slide_in_right" | 76 | app:enterAnim="@anim/slide_in_right" |
78 | app:exitAnim="@anim/slide_out_left"/> | 77 | app:exitAnim="@anim/slide_out_left"/> |
79 | <action | 78 | <action |
80 | android:id="@+id/action_inventarioFragment_to_detalleArtFragment" | 79 | android:id="@+id/action_inventarioFragment_to_detalleArtFragment" |
81 | app:destination="@id/detalleArtFragment" /> | 80 | app:destination="@id/detalleArtFragment" /> |
82 | 81 | ||
83 | </fragment> | 82 | </fragment> |
84 | <fragment | 83 | <fragment |
85 | android:id="@+id/configuracionFragment" | 84 | android:id="@+id/configuracionFragment" |
86 | android:name="com.focasoftware.deboinventariov20.ui.configuracion.ConfiguracionFragment" | 85 | android:name="com.focasoftware.deboinventariov20.ui.configuracion.ConfiguracionFragment" |
87 | android:label="Configuraciones" | 86 | android:label="Configuraciones" |
88 | tools:layout="@layout/fragment_configuracion" > | 87 | tools:layout="@layout/fragment_configuracion" > |
89 | <action | 88 | <action |
90 | android:id="@+id/action_configuracionFragment_to_servidoresFragment" | 89 | android:id="@+id/action_configuracionFragment_to_servidoresFragment" |
91 | app:destination="@id/servidoresFragment" | 90 | app:destination="@id/servidoresFragment" |
92 | app:popEnterAnim="@anim/slide_in_left" | 91 | app:popEnterAnim="@anim/slide_in_left" |
93 | app:popExitAnim="@anim/slide_out_right" | 92 | app:popExitAnim="@anim/slide_out_right" |
94 | app:enterAnim="@anim/slide_in_right" | 93 | app:enterAnim="@anim/slide_in_right" |
95 | app:exitAnim="@anim/slide_out_left" | 94 | app:exitAnim="@anim/slide_out_left" |
96 | app:popUpTo="@id/configuracionFragment" | 95 | app:popUpTo="@id/configuracionFragment" |
97 | app:popUpToInclusive="true" /> | 96 | app:popUpToInclusive="true" /> |
98 | <action | 97 | <action |
99 | android:id="@+id/action_configuracionFragment_to_mainFragment2" | 98 | android:id="@+id/action_configuracionFragment_to_mainFragment2" |
100 | app:destination="@id/mainFragment2" /> | 99 | app:destination="@id/mainFragment2" /> |
101 | </fragment> | 100 | </fragment> |
102 | <fragment | 101 | <fragment |
103 | android:id="@+id/descripcionFragment" | 102 | android:id="@+id/descripcionFragment" |
104 | android:name="com.focasoftware.deboinventariov20.ui.descripcionFragment.DescripcionFragment" | 103 | android:name="com.focasoftware.deboinventariov20.ui.descripcionFragment.DescripcionFragment" |
105 | android:label="Productos Encontrados"> | 104 | android:label="Productos Encontrados"> |
106 | 105 | ||
107 | <action | 106 | <action |
108 | android:id="@+id/action_descripcionFragment_to_inventarioFragment" | 107 | android:id="@+id/action_descripcionFragment_to_inventarioFragment" |
109 | app:destination="@id/inventarioFragment" | 108 | app:destination="@id/inventarioFragment" |
110 | app:popEnterAnim="@anim/slide_in_left" | 109 | app:popEnterAnim="@anim/slide_in_left" |
111 | app:popExitAnim="@anim/slide_out_right" | 110 | app:popExitAnim="@anim/slide_out_right" |
112 | app:enterAnim="@anim/slide_in_right" | 111 | app:enterAnim="@anim/slide_in_right" |
113 | app:exitAnim="@anim/slide_out_left" | 112 | app:exitAnim="@anim/slide_out_left" |
114 | app:popUpTo="@+id/descripcionFragment" | 113 | /> |
115 | app:popUpToInclusive="true"/> | ||
116 | </fragment> | 114 | </fragment> |
117 | <dialog | 115 | <dialog |
118 | android:id="@+id/dialogNoEncontrado" | 116 | android:id="@+id/dialogNoEncontrado" |
119 | android:name="com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado" | 117 | android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogNoEncontrado" |
120 | android:label="DialogNoEncontrado" /> | 118 | android:label="DialogNoEncontrado" /> |
121 | <fragment | 119 | <fragment |
122 | android:id="@+id/dialogoLogin" | 120 | android:id="@+id/dialogoLogin" |
123 | android:name="com.focasoftware.deboinventariov20.ui.dialogos.DialogoLogin" | 121 | android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.DialogoLogin" |
124 | android:label="dialogoLogin" /> | 122 | android:label="dialogoLogin" /> |
125 | <fragment | 123 | <fragment |
126 | android:id="@+id/singleChoiceAlertDialog" | 124 | android:id="@+id/singleChoiceAlertDialog" |
127 | android:name="com.focasoftware.deboinventariov20.ui.dialogos.SingleChoiceAlertDialog" | 125 | android:name="com.focasoftware.deboinventariov20.ui.util.Base.dialogos.SingleChoiceAlertDialog" |
128 | android:label="SingleChoiceAlertDialog" /> | 126 | android:label="SingleChoiceAlertDialog" /> |
129 | 127 | ||
130 | <fragment | 128 | <fragment |
131 | android:id="@+id/detalleArtFragment" | 129 | android:id="@+id/detalleArtFragment" |
132 | android:name="com.focasoftware.deboinventariov20.ui.detalleProducto.DetalleArtFragment" | 130 | android:name="com.focasoftware.deboinventariov20.ui.detalleProducto.DetalleArtFragment" |
133 | android:label="Detalle Articulo" | 131 | android:label="Detalle Articulo" |
134 | tools:layout="@layout/fragment_detalle_art"> | 132 | tools:layout="@layout/fragment_detalle_art"> |
135 | <action | 133 | <action |
136 | android:id="@+id/action_detalleArtFragment_to_inventarioFragment" | 134 | android:id="@+id/action_detalleArtFragment_to_inventarioFragment" |
137 | app:destination="@id/inventarioFragment" /> | 135 | app:destination="@id/inventarioFragment" /> |
138 | </fragment> | 136 | </fragment> |
139 | </navigation> | 137 | </navigation> |
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="btnConfirmar">Confirmar</string> | 33 | <string name="btnConfirmar">Confirmar</string> |
34 | <string name="btnCancela">Cancelar</string> | 34 | <string name="btnCancela">Cancelar</string> |
35 | 35 | ||
36 | 36 | ||
37 | <!-- Fragment Inventario--> | 37 | <!-- Fragment Inventario--> |
38 | <string name="invTitulo">Inventarios Dinámicos</string> | 38 | <string name="invTitulo">Inventarios Dinámicos</string> |
39 | <string name="invTituloV">Inventarios de Ventas</string> | 39 | <string name="invTituloV">Inventarios de Ventas</string> |
40 | <string name="invTituloD">Inventarios de Depositos</string> | 40 | <string name="invTituloD">Inventarios de Depositos</string> |
41 | <string name="invCodigoBarras">Código Barras:</string> | 41 | <string name="invCodigoBarras">Código Barras:</string> |
42 | <string name="btnExportarInv">Exportar Inventario</string> | 42 | <string name="btnExportarInv">Exportar Inventario</string> |
43 | <string name="btnBorrarInv">Borrar Inventario</string> | 43 | <string name="btnBorrarInv">Borrar Inventario</string> |
44 | <string name="ibBusDesc">Busqueda por Descripción</string> | 44 | <string name="ibBusDesc">Busqueda por Descripción</string> |
45 | <string name="ibBusCB">Busqueda por C. Barras</string> | 45 | <string name="ibBusCB">Busqueda por C. Barras</string> |
46 | <string name="ibBusCO">Busqueda por Código de Origen</string> | 46 | <string name="ibBusCO">Busqueda por Código de Origen</string> |
47 | <string name="switch_1">+ 1</string> | 47 | <string name="switch_1">+ 1</string> |
48 | 48 | ||
49 | <!-- Fragmento Configuraciones--> | 49 | <!-- Fragmento Configuraciones--> |
50 | <string name="tvTituloConf">Configuraciones</string> | 50 | <string name="tvTituloConf">Configuraciones</string> |
51 | <string name="tvSeleccioneServidor">Seleccione un Servidor</string> | 51 | <string name="tvSeleccioneServidor">Seleccione un Servidor</string> |
52 | <string name="btnValidarServidor">Validar</string> | 52 | <string name="btnValidarServidor">Validar</string> |
53 | <string name="btnAgregarServidor">Agregar un nuevo servidor</string> | 53 | <string name="btnAgregarServidor">Agregar un nuevo servidor</string> |
54 | <string name="tvUbicacionCarpetas">Ubicación de las carpetas de uso interno</string> | 54 | <string name="tvUbicacionCarpetas">Ubicación de las carpetas de uso interno</string> |
55 | <string name="tvTituloArea">Area de Invetnario</string> | 55 | <string name="tvTituloArea">Area de Invetnario</string> |
56 | <string name="rbVentas">Inventarios de Ventas</string> | 56 | <string name="rbVentas">Inventarios de Ventas</string> |
57 | <string name="rbDeposito">Inventarios de Depositos</string> | 57 | <string name="rbDeposito">Inventarios de Depositos</string> |
58 | <string name="tvLosProductos">Los productos no contabilizados en Inventarios</string> | 58 | <string name="tvLosProductos">Los productos no contabilizados en Inventarios</string> |
59 | <string name="tvColumnas">Columnas a Visualizar</string> | 59 | <string name="tvColumnas">Columnas a Visualizar</string> |
60 | 60 | ||
61 | <string name="rbProInclu">Solo se ajustan los productos incluidos en el conteo.</string> | 61 | <string name="rbProInclu">Solo se ajustan los productos incluidos en el conteo.</string> |
62 | <string name="rbProNoInclu">Ajusta productos no incluidos en el conteo con stock en cero.</string> | 62 | <string name="rbProNoInclu">Ajusta productos no incluidos en el conteo con stock en cero.</string> |
63 | 63 | ||
64 | <string name="cbMostrarStock">Mostror stock en el sistema al momento de la descarga del maestro.</string> | 64 | <string name="cbMostrarStock">Mostror stock en el sistema al momento de la descarga del maestro.</string> |
65 | <string name="cbHabiLectura">Habilitar Lectura de codigo de barras en balanza.</string> | 65 | <string name="cbHabiLectura">Habilitar Lectura de codigo de barras en balanza.</string> |
66 | 66 | ||
67 | <string name="tvColumMostrar">Columnas a mostrar en inventario</string> | 67 | <string name="tvColumMostrar">Columnas a mostrar en inventario</string> |
68 | 68 | ||
69 | <string name="rbCodigoDebo">Código DEBO</string> | 69 | <string name="rbCodigoDebo">Código DEBO</string> |
70 | <string name="rbCodigoOrigen">Código Origen</string> | 70 | <string name="rbCodigoOrigen">Código Origen</string> |
71 | <string name="rbCodigoBarras">Código de Barras</string> | 71 | <string name="rbCodigoBarras">Código de Barras</string> |
72 | 72 | ||
73 | 73 | ||
74 | <!-- Spinner servidor--> | 74 | <!-- Spinner servidor--> |
75 | <string-array name="spinnerServidor"> | 75 | <string-array name="spinnerServidor"> |
76 | <item>Servidor Laboratorio 1</item> | 76 | <item>Servidor Laboratorio 1</item> |
77 | <item>Servidor Laboratorio 2</item> | 77 | <item>Servidor Laboratorio 2</item> |
78 | <item>Servidor Laboratorio 3</item> | 78 | <item>Servidor Laboratorio 3</item> |
79 | </string-array> | 79 | </string-array> |
80 | <string name="leyendaSpinner">Seleccione Servidor Predeterminado</string> | 80 | <string name="leyendaSpinner">Seleccione Servidor Predeterminado</string> |
81 | 81 | ||
82 | <string name="cbMostrarExistencia">Existencia</string> | 82 | <string name="cbMostrarExistencia">Existencia</string> |
83 | <string name="cbMostrarPrecio">Precio</string> | 83 | <string name="cbMostrarPrecio">Precio</string> |
84 | 84 | ||
85 | <string name="btnGuardar">Guardar Cambios</string> | 85 | <string name="btnGuardar">Guardar Cambios</string> |
86 | 86 | ||
87 | <!-- fragment Actualizacion de Maestros--> | 87 | <!-- fragment Actualizacion de Maestros--> |
88 | <string name="tvActMaestros">Importaciones</string> | 88 | <string name="tvActMaestros">Importaciones</string> |
89 | <string name="tvMedio">Seleccione que tipo de importación desea realizar</string> | 89 | <string name="tvMedio">Seleccione que tipo de importación desea realizar</string> |
90 | <string name="obPorWifi">Importación de artículos</string> | 90 | <string name="obPorWifi">Importación de artículos</string> |
91 | <string name="obViaArchivo">Importación de inventarios</string> | 91 | <string name="obViaArchivo">Importación de inventarios</string> |
92 | 92 | ||
93 | <string name="btnConfirmarAct">Confirmar Importación</string> | 93 | <string name="btnConfirmarAct">Confirmar Importación</string> |
94 | 94 | ||
95 | <!-- Fragment Save--> | 95 | <!-- Fragment Save--> |
96 | <string name="tvConfServi">Configuración de Servidores</string> | 96 | <string name="tvConfServi">Configuración de Servidores</string> |
97 | <string name="server">Ingrese la direccion del servidor</string> | 97 | <string name="server">Ingrese la direccion del servidor</string> |
98 | <string name="etNomServer">Ingrese una descripción para la conexión</string> | 98 | <string name="etNomServer">Ingrese una descripción para la conexión</string> |
99 | <string name="btnGuardarConfServ">Guardar Conexión</string> | 99 | <string name="btnGuardarConfServ">Guardar Conexión</string> |
100 | 100 | ||
101 | <!-- Dialog--> | 101 | <!-- Dialog--> |
102 | <string name="sTitulo">Producto Buscado</string> | 102 | <string name="sTitulo">Producto Buscado</string> |
103 | <string name="btnOk">Aceptar</string> | 103 | <string name="btnOk">Aceptar</string> |
104 | <string name="btnCancelar">Cancelar</string> | 104 | <string name="btnCancelar">Cancelar</string> |
105 | <string name="sMensaje">¡No se encontro el producto ingresado!</string> | 105 | <string name="sMensaje">¡No se encontro el producto ingresado!</string> |
106 | <string name="sMensajeEncontrado">¡Ingrese nueva cantidad!</string> | 106 | <string name="sMensajeEncontrado">¡Ingrese nueva cantidad!</string> |
107 | <string name="sTituloNueva">Producto ingresado esta cargado</string> | 107 | <string name="sTituloNueva">Producto ingresado esta cargado</string> |
108 | <string name="sCantidadNueva">¡Por favor ingrese la nueva Cantidad!</string> | 108 | <string name="sCantidadNueva">¡Por favor ingrese la nueva Cantidad!</string> |
109 | 109 | ||
110 | <string name="sMensajeExportar">¡Confirma que exporta el Inventario!</string> | 110 | <string name="sMensajeExportar">¡Confirma que exporta el Inventario!</string> |
111 | <string name="sTituloExportar">Exportación de Inventarios</string> | 111 | <string name="sTituloExportar">Exportación de Inventarios</string> |
112 | 112 | ||
113 | <!-- FRAGMENT SERVIDOR--> | 113 | <!-- FRAGMENT SERVIDOR--> |
114 | <string name="tvTitutloServer">Alta de Servidores</string> | 114 | <string name="tvTitutloServer">Alta de Servidores</string> |
115 | <string name="tvNomServer">Ingrese un nombre para identificar al servidor</string> | 115 | <string name="tvNomServer">Ingrese un nombre para identificar al servidor</string> |
116 | <string name="tvDirServer">Ingrese la dirección del servidor</string> | 116 | <string name="tvDirServer">Ingrese la dirección del servidor</string> |
117 | <string name="btnGuardarServidores">Guardar Servidor</string> | 117 | <string name="btnGuardarServidores">Guardar Servidor</string> |
118 | 118 | ||
119 | <string name="tvSeleccion">Toque sobre la operación que desea realizar</string> | 119 | <string name="tvSeleccion">Toque sobre la operación que desea realizar</string> |
120 | <string name="rbSumar">Sumar</string> | 120 | <string name="rbSumar">Sumar</string> |
121 | <string name="rbRestar">Restar</string> | 121 | <string name="rbRestar">Restar</string> |
122 | <string name="rbModificar">Reemplazar</string> | 122 | <string name="rbModificar">Reemplazar</string> |
123 | <string name="tvTotal">Cantidad Final</string>tvTotal | 123 | <string name="tvTotal">Cantidad Final</string>tvTotal |
124 | <string name="tvResultado">Cantidad final:</string>tvTotal | 124 | <string name="tvResultado">Resultado:</string>tvTotal |
125 | 125 | ||
126 | <string name="large_text"> | 126 | <string name="large_text"> |
127 | "Material is the metaphor.\n\n" | 127 | "Material is the metaphor.\n\n" |
128 | 128 | ||
129 | "A material metaphor is the unifying theory of a rationalized space and a system of motion." | 129 | "A material metaphor is the unifying theory of a rationalized space and a system of motion." |
130 | "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " | 130 | "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " |
131 | "technologically advanced and open to imagination and magic.\n" | 131 | "technologically advanced and open to imagination and magic.\n" |
132 | "Surfaces and edges of the material provide visual cues that are grounded in reality. The " | 132 | "Surfaces and edges of the material provide visual cues that are grounded in reality. The " |
133 | "use of familiar tactile attributes helps users quickly understand affordances. Yet the " | 133 | "use of familiar tactile attributes helps users quickly understand affordances. Yet the " |
134 | "flexibility of the material creates new affordances that supercede those in the physical " | 134 | "flexibility of the material creates new affordances that supercede those in the physical " |
135 | "world, without breaking the rules of physics.\n" | 135 | "world, without breaking the rules of physics.\n" |
136 | "The fundamentals of light, surface, and movement are key to conveying how objects move, " | 136 | "The fundamentals of light, surface, and movement are key to conveying how objects move, " |
137 | "interact, and exist in space and in relation to each other. Realistic lighting shows " | 137 | "interact, and exist in space and in relation to each other. Realistic lighting shows " |
138 | "seams, divides space, and indicates moving parts.\n\n" | 138 | "seams, divides space, and indicates moving parts.\n\n" |
139 | 139 | ||
140 | "Bold, graphic, intentional.\n\n" | 140 | "Bold, graphic, intentional.\n\n" |
141 | 141 | ||
142 | "The foundational elements of print based design typography, grids, space, scale, color, " | 142 | "The foundational elements of print based design typography, grids, space, scale, color, " |
143 | "and use of imagery guide visual treatments. These elements do far more than please the " | 143 | "and use of imagery guide visual treatments. These elements do far more than please the " |
144 | "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " | 144 | "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " |
145 | "imagery, large scale typography, and intentional white space create a bold and graphic " | 145 | "imagery, large scale typography, and intentional white space create a bold and graphic " |
146 | "interface that immerse the user in the experience.\n" | 146 | "interface that immerse the user in the experience.\n" |
147 | "An emphasis on user actions makes core functionality immediately apparent and provides " | 147 | "An emphasis on user actions makes core functionality immediately apparent and provides " |
148 | "waypoints for the user.\n\n" | 148 | "waypoints for the user.\n\n" |
149 | 149 | ||
150 | "Motion provides meaning.\n\n" | 150 | "Motion provides meaning.\n\n" |
151 | 151 | ||
152 | "Motion respects and reinforces the user as the prime mover. Primary user actions are " | 152 | "Motion respects and reinforces the user as the prime mover. Primary user actions are " |
153 | "inflection points that initiate motion, transforming the whole design.\n" | 153 | "inflection points that initiate motion, transforming the whole design.\n" |
154 | "All action takes place in a single environment. Objects are presented to the user without " | 154 | "All action takes place in a single environment. Objects are presented to the user without " |
155 | "breaking the continuity of experience even as they transform and reorganize.\n" | 155 | "breaking the continuity of experience even as they transform and reorganize.\n" |
156 | "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " | 156 | "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " |
157 | "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" | 157 | "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" |
158 | 158 | ||
159 | "3D world.\n\n" | 159 | "3D world.\n\n" |
160 | 160 | ||
161 | "The material environment is a 3D space, which means all objects have x, y, and z " | 161 | "The material environment is a 3D space, which means all objects have x, y, and z " |
162 | "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " | 162 | "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " |
163 | "positive z-axis extending towards the viewer. Every sheet of material occupies a single " | 163 | "positive z-axis extending towards the viewer. Every sheet of material occupies a single " |
164 | "position along the z-axis and has a standard 1dp thickness.\n" | 164 | "position along the z-axis and has a standard 1dp thickness.\n" |
165 | "On the web, the z-axis is used for layering and not for perspective. The 3D world is " | 165 | "On the web, the z-axis is used for layering and not for perspective. The 3D world is " |
166 | "emulated by manipulating the y-axis.\n\n" | 166 | "emulated by manipulating the y-axis.\n\n" |
167 | 167 | ||
168 | "Light and shadow.\n\n" | 168 | "Light and shadow.\n\n" |
169 | 169 | ||
170 | "Within the material environment, virtual lights illuminate the scene. Key lights create " | 170 | "Within the material environment, virtual lights illuminate the scene. Key lights create " |
171 | "directional shadows, while ambient light creates soft shadows from all angles.\n" | 171 | "directional shadows, while ambient light creates soft shadows from all angles.\n" |
172 | "Shadows in the material environment are cast by these two light sources. In Android " | 172 | "Shadows in the material environment are cast by these two light sources. In Android " |
173 | "development, shadows occur when light sources are blocked by sheets of material at " | 173 | "development, shadows occur when light sources are blocked by sheets of material at " |
174 | "various positions along the z-axis. On the web, shadows are depicted by manipulating the " | 174 | "various positions along the z-axis. On the web, shadows are depicted by manipulating the " |
175 | "y-axis only. The following example shows the card with a height of 6dp.\n\n" | 175 | "y-axis only. The following example shows the card with a height of 6dp.\n\n" |
176 | 176 | ||
177 | "Resting elevation.\n\n" | 177 | "Resting elevation.\n\n" |
178 | 178 | ||
179 | "All material objects, regardless of size, have a resting elevation, or default elevation " | 179 | "All material objects, regardless of size, have a resting elevation, or default elevation " |
180 | "that does not change. If an object changes elevation, it should return to its resting " | 180 | "that does not change. If an object changes elevation, it should return to its resting " |
181 | "elevation as soon as possible.\n\n" | 181 | "elevation as soon as possible.\n\n" |
182 | 182 | ||
183 | "Component elevations.\n\n" | 183 | "Component elevations.\n\n" |
184 | 184 | ||
185 | "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " | 185 | "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " |
186 | "does not vary from 6dp in one app to 16dp in another app).\n" | 186 | "does not vary from 6dp in one app to 16dp in another app).\n" |
187 | "Components may have different resting elevations across platforms, depending on the depth " | 187 | "Components may have different resting elevations across platforms, depending on the depth " |
188 | "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" | 188 | "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" |
189 | 189 | ||
190 | "Responsive elevation and dynamic elevation offsets.\n\n" | 190 | "Responsive elevation and dynamic elevation offsets.\n\n" |
191 | 191 | ||
192 | "Some component types have responsive elevation, meaning they change elevation in response " | 192 | "Some component types have responsive elevation, meaning they change elevation in response " |
193 | "to user input (e.g., normal, focused, and pressed) or system events. These elevation " | 193 | "to user input (e.g., normal, focused, and pressed) or system events. These elevation " |
194 | "changes are consistently implemented using dynamic elevation offsets.\n" | 194 | "changes are consistently implemented using dynamic elevation offsets.\n" |
195 | "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " | 195 | "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " |
196 | "to the component’s resting state. They ensure that elevation changes are consistent " | 196 | "to the component’s resting state. They ensure that elevation changes are consistent " |
197 | "across actions and component types. For example, all components that lift on press have " | 197 | "across actions and component types. For example, all components that lift on press have " |
198 | "the same elevation change relative to their resting elevation.\n" | 198 | "the same elevation change relative to their resting elevation.\n" |
199 | "Once the input event is completed or cancelled, the component will return to its resting " | 199 | "Once the input event is completed or cancelled, the component will return to its resting " |
200 | "elevation.\n\n" | 200 | "elevation.\n\n" |
201 | 201 | ||
202 | "Avoiding elevation interference.\n\n" | 202 | "Avoiding elevation interference.\n\n" |
203 | 203 | ||
204 | "Components with responsive elevations may encounter other components as they move between " | 204 | "Components with responsive elevations may encounter other components as they move between " |
205 | "their resting elevations and dynamic elevation offsets. Because material cannot pass " | 205 | "their resting elevations and dynamic elevation offsets. Because material cannot pass " |
206 | "through other material, components avoid interfering with one another any number of ways, " | 206 | "through other material, components avoid interfering with one another any number of ways, " |
207 | "whether on a per component basis or using the entire app layout.\n" | 207 | "whether on a per component basis or using the entire app layout.\n" |
208 | "On a component level, components can move or be removed before they cause interference. " | 208 | "On a component level, components can move or be removed before they cause interference. " |
209 | "For example, a floating action button (FAB) can disappear or move off screen before a " | 209 | "For example, a floating action button (FAB) can disappear or move off screen before a " |
210 | "user picks up a card, or it can move if a snackbar appears.\n" | 210 | "user picks up a card, or it can move if a snackbar appears.\n" |
211 | "On the layout level, design your app layout to minimize opportunities for interference. " | 211 | "On the layout level, design your app layout to minimize opportunities for interference. " |
212 | "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " | 212 | "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " |
213 | "when a user tries to pick up one of cards.\n\n" | 213 | "when a user tries to pick up one of cards.\n\n" |
214 | </string> | 214 | </string> |
215 | </resources> | 215 | </resources> |