Commit 15c37e974eb2af5cdaf737ef807f0d620d706dcc
1 parent
6aec0e86d9
Exists in
master
31022020 2309
Showing
12 changed files
with
229 additions
and
246 deletions
Show diff stats
Solicitudes API Articulos y Time.docx
No preview for this file type
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 | apply plugin: 'kotlin-kapt' |
| 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 | |||
| 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 17 | javaCompileOptions { | ||
| 18 | annotationProcessorOptions { | ||
| 19 | arguments = ["room.incremental":"true"] | ||
| 20 | } | ||
| 21 | } | ||
| 18 | } | 22 | } |
| 19 | 23 | ||
| 20 | buildTypes { | 24 | buildTypes { |
| 21 | release { | 25 | release { |
| 22 | minifyEnabled false | 26 | minifyEnabled false |
| 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 24 | } | 28 | } |
| 25 | } | 29 | } |
| 26 | compileOptions { | 30 | compileOptions { |
| 27 | sourceCompatibility JavaVersion.VERSION_1_8 | 31 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 28 | targetCompatibility JavaVersion.VERSION_1_8 | 32 | targetCompatibility JavaVersion.VERSION_1_8 |
| 33 | |||
| 29 | } | 34 | } |
| 30 | kotlinOptions { | 35 | kotlinOptions { |
| 31 | jvmTarget = '1.8' | 36 | jvmTarget = '1.8' |
| 32 | } | 37 | } |
| 33 | } | 38 | } |
| 34 | 39 | ||
| 35 | dependencies { | 40 | dependencies { |
| 36 | implementation fileTree(dir: "libs", include: ["*.jar"]) | 41 | implementation fileTree(dir: "libs", include: ["*.jar"]) |
| 37 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
| 38 | implementation 'androidx.core:core-ktx:1.3.1' | 43 | implementation 'androidx.core:core-ktx:1.3.1' |
| 39 | implementation 'androidx.appcompat:appcompat:1.2.0' | 44 | implementation 'androidx.appcompat:appcompat:1.2.0' |
| 40 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' | 45 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
| 41 | implementation 'com.google.android.material:material:1.2.0' | 46 | implementation 'com.google.android.material:material:1.2.0' |
| 42 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0' | 47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0' |
| 43 | implementation 'androidx.navigation:navigation-fragment:2.3.0' | 48 | implementation 'androidx.navigation:navigation-fragment:2.3.0' |
| 44 | implementation 'androidx.navigation:navigation-ui:2.3.0' | 49 | implementation 'androidx.navigation:navigation-ui:2.3.0' |
| 45 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | 50 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' |
| 46 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' | 51 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' |
| 47 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' | 52 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' |
| 48 | implementation 'androidx.recyclerview:recyclerview:1.1.0' | 53 | implementation 'androidx.recyclerview:recyclerview:1.1.0' |
| 49 | testImplementation 'junit:junit:4.13' | 54 | testImplementation 'junit:junit:4.13' |
| 50 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' | 55 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| 51 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| 52 | 57 | ||
| 53 | 58 | ||
| 54 | //Room | 59 | //Room |
| 55 | implementation 'androidx.room:room-ktx:2.2.5' | 60 | implementation 'androidx.room:room-ktx:2.2.5' |
| 56 | implementation "androidx.room:room-runtime:2.2.5" | 61 | implementation "androidx.room:room-runtime:2.2.5" |
| 57 | kapt "androidx.room:room-compiler:2.2.5" | 62 | kapt "androidx.room:room-compiler:2.2.5" |
| 58 | 63 | ||
| 59 | //Retrofit | 64 | //Retrofit |
| 60 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' | 65 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' |
| 61 | implementation 'com.google.code.gson:gson:2.8.6' | 66 | implementation 'com.google.code.gson:gson:2.8.6' |
| 62 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | 67 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' |
| 63 | implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1' | 68 | implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1' |
| 64 | 69 | ||
| 65 | //Gson library | 70 | //Gson library |
| 66 | implementation "com.google.code.gson:gson:2.8.6" | 71 | implementation "com.google.code.gson:gson:2.8.6" |
| 67 | annotationProcessor 'androidx.room:room-compiler:2.2.5' | 72 | annotationProcessor 'androidx.room:room-compiler:2.2.5' |
| 68 | 73 |
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(): ArrayList<InvHead> | 49 | suspend fun fetchAllInvHead(): List<InvHead> |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @Dao | 52 | @Dao |
| 53 | interface InvBodyDAO { | 53 | interface InvBodyDAO { |
| 54 | @Insert() | 54 | @Insert() |
| 55 | suspend fun insertInvBody(invBody: InvBody?) | 55 | suspend fun insertInvBody(invBody: InvBody?) |
| 56 | 56 | ||
| 57 | @Query("DELETE FROM $TABLA_INV_B") | 57 | @Query("DELETE FROM $TABLA_INV_B") |
| 58 | suspend fun deleteAllInvBody() | 58 | suspend fun deleteAllInvBody() |
| 59 | 59 | ||
| 60 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven") | 60 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven") |
| 61 | suspend fun deleteInvBody(inven: Int) | 61 | suspend fun deleteInvBody(inven: Int) |
| 62 | 62 | ||
| 63 | @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod") | 63 | @Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod") |
| 64 | suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) | 64 | suspend fun UpdateInvBody(cant: Float, sec: String, cod: String) |
| 65 | 65 | ||
| 66 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") | 66 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC") |
| 67 | suspend fun fetchAllInvBody(inven:Int): List<InvBody> | 67 | suspend fun fetchAllInvBody(inven:Int): List<InvBody> |
| 68 | 68 | ||
| 69 | @Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") | 69 | @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 | 70 | suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody |
| 71 | 71 | ||
| 72 | @Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo") | 72 | @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 | 73 | suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int |
| 74 | } | 74 | } |
| 75 | @Dao | 75 | @Dao |
| 76 | interface ServeInvDao { | 76 | interface ServeInvDao { |
| 77 | @Insert(onConflict = OnConflictStrategy.REPLACE) | 77 | @Insert(onConflict = OnConflictStrategy.REPLACE) |
| 78 | fun insertServer(servidor: ServeInv) | 78 | fun insertServer(servidor: ServeInv) |
| 79 | 79 | ||
| 80 | @Query("SELECT * FROM ServeInv") | 80 | @Query("SELECT * FROM ServeInv") |
| 81 | suspend fun fetchAllServers(): List<ServeInv> | 81 | suspend fun fetchAllServers(): List<ServeInv> |
| 82 | 82 | ||
| 83 | @Query("DELETE FROM ServeInv WHERE SER_NUM = :number") | 83 | @Query("DELETE FROM ServeInv WHERE SER_NUM = :number") |
| 84 | suspend fun deleteServer(number: Long) | 84 | suspend fun deleteServer(number: Long) |
| 85 | 85 | ||
| 86 | @Query("SELECT SER_NUM FROM ServeInv ORDER BY SER_NUM DESC") | 86 | @Query("SELECT SER_NUM FROM ServeInv ORDER BY SER_NUM DESC") |
| 87 | suspend fun findLastSer(): Long | 87 | suspend fun findLastSer(): Long |
| 88 | } | 88 | } |
app/src/main/java/com/focasoftware/deboinventariov20/Model/ProductosService.kt
| 1 | package com.focasoftware.deboinventariov20.Model | 1 | package com.focasoftware.deboinventariov20.Model |
| 2 | 2 | ||
| 3 | import retrofit2.Retrofit | 3 | import retrofit2.Retrofit |
| 4 | import retrofit2.converter.gson.GsonConverterFactory | 4 | import retrofit2.converter.gson.GsonConverterFactory |
| 5 | 5 | ||
| 6 | object ProductosService { | 6 | object ProductosService { |
| 7 | private val BASE_URL ="http://192.168.0.2:3000/" | 7 | private val BASE_URL ="http://10.0.2.2:3000/" |
| 8 | //"http://10.0.2.2:3000/" | 8 | //"http://192.168.0.2:3000/" |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | fun getProductosService(): ProductosApi { | 11 | fun getProductosService(): ProductosApi { |
| 12 | return Retrofit.Builder() | 12 | return Retrofit.Builder() |
| 13 | .baseUrl(BASE_URL) | 13 | .baseUrl(BASE_URL) |
| 14 | .addConverterFactory(GsonConverterFactory.create()) | 14 | .addConverterFactory(GsonConverterFactory.create()) |
| 15 | .build() | 15 | .build() |
| 16 | .create(ProductosApi::class.java) | 16 | .create(ProductosApi::class.java) |
| 17 | } | 17 | } |
| 18 | } | 18 | } |
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.view.LayoutInflater | 11 | import android.view.LayoutInflater |
| 11 | import android.view.View | 12 | import android.view.View |
| 12 | import android.view.ViewGroup | 13 | import android.view.ViewGroup |
| 13 | import android.widget.Button | 14 | import android.widget.Button |
| 14 | import androidx.fragment.app.Fragment | 15 | import androidx.fragment.app.Fragment |
| 15 | import androidx.fragment.app.FragmentActivity | 16 | import androidx.fragment.app.FragmentActivity |
| 16 | import androidx.lifecycle.lifecycleScope | 17 | import androidx.lifecycle.lifecycleScope |
| 17 | import androidx.navigation.NavController | 18 | import androidx.navigation.NavController |
| 18 | import androidx.navigation.Navigation | 19 | import androidx.navigation.Navigation |
| 19 | import androidx.recyclerview.widget.ItemTouchHelper | 20 | import androidx.recyclerview.widget.ItemTouchHelper |
| 20 | import androidx.recyclerview.widget.LinearLayoutManager | 21 | import androidx.recyclerview.widget.LinearLayoutManager |
| 21 | import androidx.recyclerview.widget.RecyclerView | 22 | import androidx.recyclerview.widget.RecyclerView |
| 22 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 23 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
| 23 | import com.focasoftware.deboinventariov20.Model.Articles | 24 | import com.focasoftware.deboinventariov20.Model.Articles |
| 24 | import com.focasoftware.deboinventariov20.Model.InvBody | 25 | import com.focasoftware.deboinventariov20.Model.InvBody |
| 25 | import com.focasoftware.deboinventariov20.R | 26 | import com.focasoftware.deboinventariov20.R |
| 26 | import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment | 27 | import com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment |
| 27 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | 28 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* |
| 28 | import kotlinx.android.synthetic.main.login_dialog.view.* | 29 | import kotlinx.android.synthetic.main.login_dialog.view.* |
| 29 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | 30 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar |
| 30 | import kotlinx.coroutines.* | 31 | import kotlinx.coroutines.* |
| 31 | 32 | ||
| 32 | class DescripcionFragment : Fragment() { | 33 | class DescripcionFragment : Fragment() { |
| 33 | private var artAcargar2: List<Articles>? = null | 34 | private var artAcargar2: List<Articles>? = null |
| 34 | private var listArticulos2: List<Articles>? = null | 35 | private var listArticulos2: List<Articles>? = null |
| 35 | lateinit var viewAdapter2: RecyclerView.Adapter<*> | 36 | lateinit var viewAdapter2: RecyclerView.Adapter<*> |
| 36 | private lateinit var viewManager2: RecyclerView.LayoutManager | 37 | private lateinit var viewManager2: RecyclerView.LayoutManager |
| 37 | private lateinit var rcDescripcion: RecyclerView | 38 | private lateinit var rcDescripcion: RecyclerView |
| 38 | private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) | 39 | private var swipeBackground: ColorDrawable = ColorDrawable(Color.YELLOW) |
| 39 | private var cantidad = 0F | 40 | private var cantidad = 0F |
| 40 | private var numeroInventario = 0 | 41 | private var numeroInventario = 0 |
| 41 | lateinit var navController: NavController | 42 | lateinit var navController: NavController |
| 42 | lateinit var sharedPreferences: SharedPreferences | 43 | lateinit var sharedPreferences: SharedPreferences |
| 43 | private var indice = 0 | 44 | private var indice = 0 |
| 44 | private var artCargadoEnBD: InvBody? = null | 45 | private var artCargadoEnBD: InvBody? = null |
| 45 | 46 | ||
| 46 | override fun onCreate(savedInstanceState: Bundle?) { | 47 | override fun onCreate(savedInstanceState: Bundle?) { |
| 47 | super.onCreate(savedInstanceState) | 48 | super.onCreate(savedInstanceState) |
| 48 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 49 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
| 49 | arguments.apply { | 50 | arguments.apply { |
| 50 | artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> | 51 | artAcargar2 = requireArguments().getSerializable("ArrayDesc") as List<Articles> |
| 51 | numeroInventario = requireArguments().getInt("numeroInv") | 52 | numeroInventario = requireArguments().getInt("numeroInv") |
| 52 | } | 53 | } |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 56 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 56 | super.onViewCreated(view, savedInstanceState) | 57 | super.onViewCreated(view, savedInstanceState) |
| 57 | navController = Navigation.findNavController(view) | 58 | navController = Navigation.findNavController(view) |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 61 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
| 61 | val v = inflater.inflate(R.layout.fragment_descripcion, container, false) | 62 | val v = inflater.inflate(R.layout.fragment_descripcion, container, false) |
| 62 | rcDescripcion = v.findViewById(R.id.rcDescripcion) | 63 | rcDescripcion = v.findViewById(R.id.rcDescripcion) |
| 63 | val btnSalir = v.findViewById<Button>(R.id.btnSalir) | 64 | val btnSalir = v.findViewById<Button>(R.id.btnSalir) |
| 64 | 65 | ||
| 65 | IngresarRecicler(artAcargar2) | 66 | IngresarRecicler(artAcargar2) |
| 66 | 67 | ||
| 67 | btnSalir.setOnClickListener { | 68 | btnSalir.setOnClickListener { |
| 68 | VolverAinventario() | 69 | VolverAinventario() |
| 69 | } | 70 | } |
| 70 | return v | 71 | return v |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | fun IngresarRecicler(articulos: List<Articles>?) { | 74 | fun IngresarRecicler(articulos: List<Articles>?) { |
| 74 | 75 | ||
| 75 | viewAdapter2 = DescripcionListAdapter(articulos) | 76 | viewAdapter2 = DescripcionListAdapter(articulos) |
| 76 | viewManager2 = LinearLayoutManager(requireContext()) | 77 | viewManager2 = LinearLayoutManager(requireContext()) |
| 77 | 78 | ||
| 78 | rcDescripcion.apply { | 79 | rcDescripcion.apply { |
| 79 | adapter = viewAdapter2 | 80 | adapter = viewAdapter2 |
| 80 | layoutManager = viewManager2 | 81 | layoutManager = viewManager2 |
| 81 | } | 82 | } |
| 82 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { | 83 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { |
| 83 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | 84 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { |
| 84 | return false | 85 | return false |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { | 88 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, position: Int) { |
| 88 | 89 | ||
| 89 | var indice = 0 | 90 | var indice = 0 |
| 90 | indice = viewHolder.layoutPosition | 91 | indice = viewHolder.layoutPosition |
| 91 | GlobalScope.launch(Dispatchers.Main) { | 92 | GlobalScope.launch(Dispatchers.Main) { |
| 92 | //TODO BUSCO EN BASE DE DATOS | 93 | //TODO BUSCO EN BASE DE DATOS |
| 93 | artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), | 94 | artCargadoEnBD = buscarCodigoDeboEnBD((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.sector.toString(), |
| 94 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), | 95 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)?.codigo.toString(), |
| 95 | numeroInventario.toString()) | 96 | numeroInventario.toString()) |
| 96 | if (artCargadoEnBD == null) { | 97 | if (artCargadoEnBD == null) { |
| 97 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | 98 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) |
| 98 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setCancelable(false) | 99 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView) |
| 100 | .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 | mDialogView.etCantidad.inputType= InputType.TYPE_CLASS_NUMBER | ||
| 99 | mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" | 103 | mDialogView.tvTitulo.text = "${(viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion}" |
| 100 | val mAlertDialog = mBuilder.show() | 104 | val mAlertDialog = mBuilder.show() |
| 101 | mDialogView.btnAceptar.setOnClickListener { | 105 | mDialogView.btnAceptar.setOnClickListener { |
| 102 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { | 106 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { |
| 103 | mDialogView.etCantidad.error = "No vacio" | 107 | mDialogView.etCantidad.error = "No vacio" |
| 104 | mDialogView.etCantidad.requestFocus() | 108 | mDialogView.etCantidad.requestFocus() |
| 105 | mDialogView.etCantidad.hint = "Ingrese un valor" | 109 | mDialogView.etCantidad.hint = "Ingrese un valor" |
| 106 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | 110 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { |
| 107 | cantidad = mDialogView.etCantidad.text.toString().toFloat() | 111 | cantidad = mDialogView.etCantidad.text.toString().toFloat() |
| 108 | val body = InvBody(numeroInventario, | 112 | val body = InvBody(numeroInventario, |
| 109 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, | 113 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector, |
| 110 | // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD | 114 | // TODO: PREPARO PARA MANDAR A CARGAR EN LA BD |
| 111 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, | 115 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo, |
| 112 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, | 116 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.descripcion, |
| 113 | cantidad.toString(), | 117 | cantidad.toString(), |
| 114 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, | 118 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codBar, |
| 115 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, | 119 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codOrigen, |
| 116 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | 120 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, |
| 117 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, | 121 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.precio, |
| 118 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, | 122 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.balanza, |
| 119 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, | 123 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.depSn, |
| 120 | InventarioFragment().ObtenerFechaActual(), | 124 | InventarioFragment().ObtenerFechaActual(), |
| 121 | InventarioFragment().ObtenerFechaActual()) | 125 | InventarioFragment().ObtenerFechaActual()) |
| 122 | InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS | 126 | InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS |
| 123 | VolverAinventario() | 127 | VolverAinventario() |
| 124 | mAlertDialog.dismiss() | 128 | mAlertDialog.dismiss() |
| 125 | } | 129 | } |
| 126 | } | 130 | } |
| 127 | } else if (artCargadoEnBD != null) { | 131 | } else if (artCargadoEnBD != null) { |
| 128 | 132 | ||
| 129 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 133 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
| 130 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${artCargadoEnBD!!.descripcion}', se encuentra cargado.").setCancelable(false) | 134 | 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 | ||
| 131 | mDialogView.tvCantInicial.text = artCargadoEnBD!!.cantTomada | 136 | mDialogView.tvCantInicial.text = artCargadoEnBD!!.cantTomada |
| 132 | 137 | ||
| 133 | val mAlertDialog = mBuilder.show() | 138 | val mAlertDialog = mBuilder.show() |
| 134 | mDialogView.rbSumar.setOnClickListener { | 139 | mDialogView.rbSumar.setOnClickListener { |
| 135 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 140 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 136 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 141 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 137 | mDialogView.tvNuevaCantidad.isEnabled=false | 142 | mDialogView.tvNuevaCantidad.isEnabled=false |
| 138 | } | 143 | } |
| 139 | } | 144 | } |
| 140 | mDialogView.rbRestar.setOnClickListener { | 145 | mDialogView.rbRestar.setOnClickListener { |
| 141 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 146 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 142 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 147 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
| 143 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 148 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 144 | mDialogView.tvNuevaCantidad.isEnabled=false | 149 | mDialogView.tvNuevaCantidad.isEnabled=false |
| 145 | } | 150 | } |
| 146 | } | 151 | } |
| 147 | } | 152 | } |
| 148 | mDialogView.rbMdodificar.setOnClickListener { | 153 | mDialogView.rbMdodificar.setOnClickListener { |
| 149 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 154 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 150 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 155 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 151 | mDialogView.tvNuevaCantidad.isEnabled=false | 156 | mDialogView.tvNuevaCantidad.isEnabled=false |
| 152 | } | 157 | } |
| 153 | } | 158 | } |
| 154 | mDialogView.btnAceptar.setOnClickListener { | 159 | mDialogView.btnAceptar.setOnClickListener { |
| 155 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 160 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 156 | val name = mDialogView.tvgenerico4.text.toString().toFloat() | 161 | val name = mDialogView.tvgenerico4.text.toString().toFloat() |
| 157 | updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), | 162 | updateCantidad((viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.sector.toString(), |
| 158 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), | 163 | (viewAdapter2 as DescripcionListAdapter).items2?.get(indice)!!.codigo.toString(), |
| 159 | name) | 164 | name) |
| 160 | VolverAinventario() | 165 | VolverAinventario() |
| 161 | mAlertDialog.dismiss() | 166 | mAlertDialog.dismiss() |
| 162 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 167 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 163 | mDialogView.tvNuevaCantidad.error = "No vacio" | 168 | mDialogView.tvNuevaCantidad.error = "No vacio" |
| 164 | mDialogView.tvNuevaCantidad.requestFocus() | 169 | mDialogView.tvNuevaCantidad.requestFocus() |
| 165 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | 170 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" |
| 166 | } | 171 | } |
| 167 | } | 172 | } |
| 168 | mDialogView.dialogCancelBtn.setOnClickListener { | 173 | mDialogView.dialogCancelBtn.setOnClickListener { |
| 169 | mAlertDialog.dismiss() | 174 | mAlertDialog.dismiss() |
| 170 | } | 175 | } |
| 171 | } | 176 | } |
| 172 | } | 177 | } |
| 173 | } | 178 | } |
| 174 | 179 | ||
| 175 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | 180 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
| 176 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 181 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
| 177 | val itemView = viewHolder.itemView | 182 | val itemView = viewHolder.itemView |
| 178 | 183 | ||
| 179 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | 184 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) |
| 180 | 185 | ||
| 181 | if (dX > 0) { | 186 | if (dX > 0) { |
| 182 | 187 | ||
| 183 | c.drawColor(Color.RED) | 188 | c.drawColor(Color.RED) |
| 184 | } else if (dX < 0) { | 189 | } else if (dX < 0) { |
| 185 | // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) | 190 | // swipeBackground.setBounds(itemView.right+dX.toInt(),itemView.top,itemView.right,itemView.bottom) |
| 186 | c.drawColor(Color.YELLOW) | 191 | c.drawColor(Color.YELLOW) |
| 187 | } | 192 | } |
| 188 | swipeBackground.draw(c) | 193 | swipeBackground.draw(c) |
| 189 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 194 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
| 190 | } | 195 | } |
| 191 | } | 196 | } |
| 192 | val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) | 197 | val itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallback) |
| 193 | itemTouchHelper2.attachToRecyclerView(rcDescripcion) | 198 | itemTouchHelper2.attachToRecyclerView(rcDescripcion) |
| 194 | 199 | ||
| 195 | } | 200 | } |
| 196 | 201 | ||
| 197 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { | 202 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { |
| 198 | lifecycleScope.launch { | 203 | lifecycleScope.launch { |
| 199 | withContext(Dispatchers.IO) { | 204 | withContext(Dispatchers.IO) { |
| 200 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | 205 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) |
| 201 | } | 206 | } |
| 202 | } | 207 | } |
| 203 | } | 208 | } |
| 204 | 209 | ||
| 205 | fun VolverAinventario() { | 210 | fun VolverAinventario() { |
| 206 | 211 | ||
| 207 | val editor = sharedPreferences.edit() | 212 | val editor = sharedPreferences.edit() |
| 208 | editor?.putString("Inventario", numeroInventario.toString()) | 213 | editor?.putString("Inventario", numeroInventario.toString()) |
| 209 | editor?.apply() | 214 | editor?.apply() |
| 210 | editor.commit() | 215 | editor.commit() |
| 211 | navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | 216 | navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) |
| 212 | } | 217 | } |
| 213 | 218 | ||
| 214 | suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { | 219 | suspend fun buscarCodigoDeboEnBD(sector: String, codigo: String, numInventario: String): InvBody? { |
| 215 | //TODO BUSQUEDA POR CODIGO DE BARRAS | 220 | //TODO BUSQUEDA POR CODIGO DE BARRAS |
| 216 | var busqueda: InvBody? = null | 221 | var busqueda: InvBody? = null |
| 217 | return GlobalScope.async(Dispatchers.IO) { | 222 | return GlobalScope.async(Dispatchers.IO) { |
| 218 | busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) | 223 | busqueda = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.fetchArtInInvBody(sector, codigo, numInventario) |
| 219 | return@async busqueda | 224 | return@async busqueda |
| 220 | }.await() | 225 | }.await() |
| 221 | } | 226 | } |
| 222 | 227 | ||
| 223 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | 228 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { |
| 224 | lifecycleScope.launch { | 229 | lifecycleScope.launch { |
| 225 | withContext(Dispatchers.IO) { | 230 | withContext(Dispatchers.IO) { |
| 226 | val activity: FragmentActivity? = activity | 231 | val activity: FragmentActivity? = activity |
| 227 | if (activity != null && isAdded) { | 232 | if (activity != null && isAdded) { |
| 228 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | 233 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) |
| 229 | } | 234 | } |
| 230 | 235 | ||
| 231 | } | 236 | } |
| 232 | } | 237 | } |
| 233 | } | 238 | } |
| 234 | } | 239 | } |
| 235 | 240 | ||
| 236 | 241 |
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 | ||
| 14 | import android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL | ||
| 12 | import android.view.KeyEvent | 15 | import android.view.KeyEvent |
| 13 | import android.view.LayoutInflater | 16 | import android.view.LayoutInflater |
| 14 | import android.view.View | 17 | import android.view.View |
| 15 | import android.view.ViewGroup | 18 | import android.view.ViewGroup |
| 16 | import android.widget.EditText | 19 | import android.widget.EditText |
| 17 | import android.widget.TextView | 20 | import android.widget.TextView |
| 18 | import android.widget.Toast | 21 | import android.widget.Toast |
| 19 | import androidx.core.content.ContextCompat | 22 | import androidx.core.content.ContextCompat |
| 20 | import androidx.core.os.bundleOf | 23 | import androidx.core.os.bundleOf |
| 21 | import androidx.fragment.app.Fragment | 24 | import androidx.fragment.app.Fragment |
| 22 | import androidx.lifecycle.lifecycleScope | 25 | import androidx.lifecycle.lifecycleScope |
| 23 | import androidx.navigation.NavController | 26 | import androidx.navigation.NavController |
| 24 | import androidx.navigation.Navigation | 27 | import androidx.navigation.Navigation |
| 25 | import androidx.recyclerview.widget.ItemTouchHelper | 28 | import androidx.recyclerview.widget.ItemTouchHelper |
| 26 | import androidx.recyclerview.widget.LinearLayoutManager | 29 | import androidx.recyclerview.widget.LinearLayoutManager |
| 27 | import androidx.recyclerview.widget.RecyclerView | 30 | import androidx.recyclerview.widget.RecyclerView |
| 28 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 31 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
| 29 | import com.focasoftware.deboinventariov20.Model.Articles | 32 | import com.focasoftware.deboinventariov20.Model.Articles |
| 30 | import com.focasoftware.deboinventariov20.Model.InvBody | 33 | import com.focasoftware.deboinventariov20.Model.InvBody |
| 31 | import com.focasoftware.deboinventariov20.Model.InvHead | 34 | import com.focasoftware.deboinventariov20.Model.InvHead |
| 32 | import com.focasoftware.deboinventariov20.R | 35 | import com.focasoftware.deboinventariov20.R |
| 33 | import com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado | 36 | import com.focasoftware.deboinventariov20.ui.dialogos.DialogNoEncontrado |
| 34 | import com.focasoftware.deboinventariov20.ui.util.Base.AlertDialogBorrarInv | ||
| 35 | import com.focasoftware.deboinventariov20.ui.util.Base.NoEncontradoSimple | ||
| 36 | import kotlinx.android.synthetic.main.fragment_inventario.* | 37 | import kotlinx.android.synthetic.main.fragment_inventario.* |
| 37 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* | 38 | import kotlinx.android.synthetic.main.ingresar_cantidad.view.* |
| 38 | import kotlinx.android.synthetic.main.login_dialog.view.* | 39 | import kotlinx.android.synthetic.main.login_dialog.view.* |
| 39 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar | 40 | import kotlinx.android.synthetic.main.login_dialog.view.btnAceptar |
| 40 | import kotlinx.coroutines.* | 41 | import kotlinx.coroutines.* |
| 42 | import java.lang.Integer.TYPE | ||
| 41 | import java.time.LocalDateTime | 43 | import java.time.LocalDateTime |
| 42 | import java.time.format.DateTimeFormatter | 44 | import java.time.format.DateTimeFormatter |
| 43 | import java.util.* | 45 | import java.util.* |
| 44 | 46 | ||
| 45 | 47 | ||
| 46 | class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener{ | 48 | class InventarioFragment : Fragment(), ProductosListAdapter.OnImageDotsClickListener{ |
| 47 | 49 | ||
| 48 | private lateinit var sharedPreferences: SharedPreferences | 50 | private lateinit var sharedPreferences: SharedPreferences |
| 49 | private var iArea: Int = 0 | 51 | private var iArea: Int = 0 |
| 50 | private lateinit var invHead: InvHead | 52 | private lateinit var invHead: InvHead |
| 51 | private lateinit var rcInventarios: RecyclerView | 53 | private lateinit var rcInventarios: RecyclerView |
| 52 | private lateinit var viewAdapter: RecyclerView.Adapter<*> | 54 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
| 53 | private lateinit var viewManager: RecyclerView.LayoutManager | 55 | private lateinit var viewManager: RecyclerView.LayoutManager |
| 54 | private lateinit var sChangeUpper: String | 56 | private lateinit var sChangeUpper: String |
| 55 | private var listArticulos = ArrayList<ItemsRecycler>() | 57 | private var listArticulos = ArrayList<ItemsRecycler>() |
| 56 | private lateinit var navController: NavController | 58 | private lateinit var navController: NavController |
| 57 | private var InventarioNuevo: Int = 0 | 59 | private var InventarioNuevo: Int = 0 |
| 58 | private var iEstado = 0 | 60 | private var iEstado = 0 |
| 59 | private var iBusquedaPor = 0 | 61 | private var iBusquedaPor = 0 |
| 60 | private var fCant = 0F | 62 | private var fCant = 0F |
| 61 | private var bFirst = false | 63 | private var bFirst = false |
| 62 | private lateinit var deleteIcon: Drawable | 64 | private lateinit var deleteIcon: Drawable |
| 63 | 65 | ||
| 64 | override fun onCreate(savedInstanceState: Bundle?) { | 66 | override fun onCreate(savedInstanceState: Bundle?) { |
| 65 | super.onCreate(savedInstanceState) | 67 | super.onCreate(savedInstanceState) |
| 66 | 68 | ||
| 67 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 69 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
| 68 | if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { | 70 | if (sharedPreferences.contains("Inventario")) if (sharedPreferences.getString("Inventario", "").toString() != "-1") { |
| 69 | InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() | 71 | InventarioNuevo = sharedPreferences.getString("Inventario", "").toString().toInt() |
| 70 | val editor = sharedPreferences.edit() | 72 | val editor = sharedPreferences.edit() |
| 71 | editor?.putString("Inventario", "-1") | 73 | editor?.putString("Inventario", "-1") |
| 72 | editor?.apply() | 74 | editor?.apply() |
| 73 | editor.commit() | 75 | editor.commit() |
| 74 | } | 76 | } |
| 75 | } | 77 | } |
| 76 | 78 | ||
| 77 | 79 | ||
| 78 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 80 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
| 79 | val v = inflater.inflate(R.layout.fragment_inventario, container, false) | 81 | val v = inflater.inflate(R.layout.fragment_inventario, container, false) |
| 80 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 82 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
| 81 | val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) | 83 | val tCodigoBarras = v.findViewById<EditText>(R.id.etCodigoBarras) |
| 82 | rcInventarios = v.findViewById(R.id.rcInventarios) | 84 | rcInventarios = v.findViewById(R.id.rcInventarios) |
| 83 | val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) | 85 | val tvTitulo = v.findViewById<TextView>(R.id.tvTitulo) |
| 84 | 86 | ||
| 85 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO | 87 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO |
| 86 | GlobalScope.launch(Dispatchers.Main) { | 88 | GlobalScope.launch(Dispatchers.Main) { |
| 87 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO | 89 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO |
| 88 | InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 | 90 | InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 |
| 89 | SerchArea() | ||
| 90 | val descripInv: String = if (iArea == 0) "Ventas" else "Deposito" | ||
| 91 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO | 91 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO |
| 92 | invHead = InvHead(InventarioNuevo, descripInv, 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, iArea, AjusteProductos(), ProdNoCont()) | 92 | invHead = InvHead(InventarioNuevo, if (SerchArea() == 0) "Ventas" else "Deposito", 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, SerchArea(), AjusteProductos(), ProdNoCont()) |
| 93 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) | 93 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) |
| 94 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" | 94 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" |
| 95 | } | 95 | } |
| 96 | } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) | 96 | } else {// TODO (SI VENGO DE FRAGMENT DESCRIPCION) |
| 97 | listArticulos.clear() | 97 | listArticulos.clear() |
| 98 | CargarDeBdInventario(InventarioNuevo) | 98 | CargarDeBdInventario(InventarioNuevo) |
| 99 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" | 99 | tvTitulo.text = "Inventario Dinamico" + " N° $InventarioNuevo" |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> | 102 | tCodigoBarras.setOnKeyListener { _, keyCode, keyEvent -> |
| 103 | if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { | 103 | if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_UP) { |
| 104 | sChangeUpper = tCodigoBarras.text.toString() | 104 | sChangeUpper = tCodigoBarras.text.toString() |
| 105 | var indiceDelArtEncontrado = 0 | 105 | var indiceDelArtEncontrado = 0 |
| 106 | 106 | ||
| 107 | if (tCodigoBarras.text.isNullOrBlank()) { | 107 | if (tCodigoBarras.text.isNullOrBlank()) { |
| 108 | tCodigoBarras.error = "No puede estar vacio" | 108 | tCodigoBarras.error = "No puede estar vacio" |
| 109 | tCodigoBarras.requestFocus() | 109 | tCodigoBarras.requestFocus() |
| 110 | tCodigoBarras.hint = "No puede estar vacio" | 110 | tCodigoBarras.hint = "No puede estar vacio" |
| 111 | } else { | 111 | } else { |
| 112 | 112 | ||
| 113 | //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS | 113 | //TODO COMIENZA LA BUSQUEDA POR CODIGO DE BARRAS |
| 114 | when (iBusquedaPor) { | 114 | when (iBusquedaPor) { |
| 115 | 0 -> { | 115 | 0 -> { |
| 116 | GlobalScope.launch(Dispatchers.Main) { | 116 | GlobalScope.launch(Dispatchers.Main) { |
| 117 | indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 0)//TODO Si encuentra el articulo en el RV devuelve el indice | 117 | 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) | 118 | //TODO (Si no lo encuentra devuelve -1) |
| 119 | if (indiceDelArtEncontrado != -1) { | 119 | if (indiceDelArtEncontrado != -1) { |
| 120 | if (swSumaUno!!.isChecked) { | 120 | if (swSumaUno!!.isChecked) { |
| 121 | // fCant = 0F | 121 | // fCant = 0F |
| 122 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 122 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 123 | // fCant += 1F | 123 | // fCant += 1F |
| 124 | //TODO ACTUALIZO LA CANTIDAD EN LA BD | 124 | //TODO ACTUALIZO LA CANTIDAD EN LA BD |
| 125 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), listArticulos[indiceDelArtEncontrado].cantTomada+1) | 125 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), listArticulos[indiceDelArtEncontrado].cantTomada+1) |
| 126 | //TODO ACTUALIZO LA CANTIDAD EN EL RV | 126 | //TODO ACTUALIZO LA CANTIDAD EN EL RV |
| 127 | listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada+1 | 127 | listArticulos[indiceDelArtEncontrado].cantTomada = listArticulos[indiceDelArtEncontrado].cantTomada+1 |
| 128 | viewAdapter.notifyDataSetChanged() | 128 | viewAdapter.notifyDataSetChanged() |
| 129 | } else { | 129 | } else { |
| 130 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 130 | dialogoSumaResta(requireContext(),indiceDelArtEncontrado, listArticulos[indiceDelArtEncontrado].univta) |
| 131 | val mBuilder = | ||
| 132 | AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | ||
| 133 | // .setCancelable(false) | ||
| 134 | mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | ||
| 135 | val mAlertDialog = mBuilder.show() | ||
| 136 | mDialogView.rbSumar.setOnClickListener { | ||
| 137 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 138 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 139 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 140 | } | ||
| 141 | } | ||
| 142 | mDialogView.rbRestar.setOnClickListener { | ||
| 143 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 144 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | ||
| 145 | mDialogView.tvgenerico4.text = | ||
| 146 | (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 147 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | mDialogView.rbMdodificar.setOnClickListener { | ||
| 152 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 153 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 154 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 155 | } | ||
| 156 | } | ||
| 157 | mDialogView.btnAceptar.setOnClickListener { | ||
| 158 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 159 | mAlertDialog.dismiss() | ||
| 160 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | ||
| 161 | // fCant = 0F | ||
| 162 | // fCant = name | ||
| 163 | listArticulos[indiceDelArtEncontrado].cantTomada = mDialogView.tvgenerico4.text.toString().toFloat() | ||
| 164 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), mDialogView.tvgenerico4.text.toString().toFloat()) | ||
| 165 | viewAdapter.notifyDataSetChanged() | ||
| 166 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 167 | mDialogView.tvNuevaCantidad.error = "No vacio" | ||
| 168 | mDialogView.tvNuevaCantidad.requestFocus() | ||
| 169 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | ||
| 170 | } | ||
| 171 | } | ||
| 172 | mDialogView.dialogCancelBtn.setOnClickListener { | ||
| 173 | mAlertDialog.dismiss() | ||
| 174 | } | ||
| 175 | } | 131 | } |
| 176 | 132 | ||
| 177 | } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | 133 | } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD |
| 178 | 134 | ||
| 179 | 135 | ||
| 180 | //TODO BUSCO EN BASE DE DATOS | 136 | //TODO BUSCO EN BASE DE DATOS |
| 181 | val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 137 | val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 182 | ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE | 138 | ContinuarCargaCB(artEncontrado)//TODO SE MANDA CERO POR QUE ES UN ARTICULO ESCANEADO NUEVO PARA QUE SEA COMPATIBLE |
| 183 | } | 139 | } |
| 184 | 140 | ||
| 185 | 141 | ||
| 186 | tCodigoBarras.focusable = View.FOCUSABLE | 142 | tCodigoBarras.focusable = View.FOCUSABLE |
| 187 | tCodigoBarras.setText("") | 143 | tCodigoBarras.setText("") |
| 188 | tCodigoBarras.selectAll() | 144 | tCodigoBarras.selectAll() |
| 189 | } | 145 | } |
| 190 | return@setOnKeyListener true | 146 | return@setOnKeyListener true |
| 191 | 147 | ||
| 192 | 148 | ||
| 193 | } | 149 | } |
| 194 | 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | 150 | 1 -> {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** |
| 195 | // | 151 | // |
| 196 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | 152 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice |
| 197 | // //TODO Si no lo encuentra devuelve -1 | 153 | // //TODO Si no lo encuentra devuelve -1 |
| 198 | // if (indiceDelArtEncontrado != -1) { | 154 | // if (indiceDelArtEncontrado != -1) { |
| 199 | //// if (swSumaUno!!.isChecked) { | 155 | //// if (swSumaUno!!.isChecked) { |
| 200 | //// fCant = 0F | 156 | //// fCant = 0F |
| 201 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 157 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 202 | //// fCant += 1F | 158 | //// fCant += 1F |
| 203 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 159 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 204 | //// viewAdapter.notifyDataSetChanged() | 160 | //// viewAdapter.notifyDataSetChanged() |
| 205 | //// } else { | 161 | //// } else { |
| 206 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 162 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 207 | // MaterialDialog(requireContext()).show { | 163 | // MaterialDialog(requireContext()).show { |
| 208 | // title(R.string.sTituloNueva) | 164 | // title(R.string.sTituloNueva) |
| 209 | // message(R.string.sCantidadNueva) | 165 | // message(R.string.sCantidadNueva) |
| 210 | // input { materialDialog, charSequence -> | 166 | // input { materialDialog, charSequence -> |
| 211 | // fCant = 0F | 167 | // fCant = 0F |
| 212 | // fCant = charSequence.toString().toFloat() | 168 | // fCant = charSequence.toString().toFloat() |
| 213 | // } | 169 | // } |
| 214 | // positiveButton(R.string.btnOk) { | 170 | // positiveButton(R.string.btnOk) { |
| 215 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 171 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 216 | // viewAdapter.notifyDataSetChanged() | 172 | // viewAdapter.notifyDataSetChanged() |
| 217 | // dismiss() | 173 | // dismiss() |
| 218 | // } | 174 | // } |
| 219 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 175 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 220 | //// } | 176 | //// } |
| 221 | // | 177 | // |
| 222 | // } else if | 178 | // } else if |
| 223 | // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | 179 | // (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD |
| 224 | GlobalScope.launch(Dispatchers.Main) { | 180 | GlobalScope.launch(Dispatchers.Main) { |
| 225 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 181 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 226 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) | 182 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) |
| 227 | } | 183 | } |
| 228 | // } | 184 | // } |
| 229 | 185 | ||
| 230 | return@setOnKeyListener true | 186 | return@setOnKeyListener true |
| 231 | } | 187 | } |
| 232 | // 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** | 188 | // 2 -> {//TODO: BUSQUEDA POR CODIGO DE ORIGEN************************************************************************** |
| 233 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice | 189 | // indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 3)//TODO Si encuentra el articulo en el RV devuelve el indice |
| 234 | // //TODO Si no lo encuentra devuelve -1 | 190 | // //TODO Si no lo encuentra devuelve -1 |
| 235 | // if (indiceDelArtEncontrado != -1) { | 191 | // if (indiceDelArtEncontrado != -1) { |
| 236 | // if (swSumaUno!!.isChecked) { | 192 | // if (swSumaUno!!.isChecked) { |
| 237 | // fCant = 0F | 193 | // fCant = 0F |
| 238 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 194 | // fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 239 | // fCant += 1F | 195 | // fCant += 1F |
| 240 | // //TODO ACTUALIZO LA CANTIDAD EN LA BD | 196 | // //TODO ACTUALIZO LA CANTIDAD EN LA BD |
| 241 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 197 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
| 242 | // //TODO ACTUALIZO LA CANTIDAD EN EL RV | 198 | // //TODO ACTUALIZO LA CANTIDAD EN EL RV |
| 243 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 199 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 244 | // viewAdapter.notifyDataSetChanged() | 200 | // viewAdapter.notifyDataSetChanged() |
| 245 | // } else { | 201 | // } else { |
| 246 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | 202 | // val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) |
| 247 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") | 203 | // val mBuilder = AlertDialog.Builder(context).setView(mDialogView).setTitle("Producto '${listArticulos[indiceDelArtEncontrado].descripcion}', se encuentra cargado.") |
| 248 | // .setCancelable(false) | 204 | // .setCancelable(false) |
| 249 | // mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | 205 | // mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() |
| 250 | // val mAlertDialog = mBuilder.show() | 206 | // val mAlertDialog = mBuilder.show() |
| 251 | // mDialogView.rbSumar.setOnClickListener { | 207 | // mDialogView.rbSumar.setOnClickListener { |
| 252 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 208 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 253 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 209 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 254 | // } | 210 | // } |
| 255 | // } | 211 | // } |
| 256 | // mDialogView.rbRestar.setOnClickListener { | 212 | // mDialogView.rbRestar.setOnClickListener { |
| 257 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 213 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 258 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | 214 | // if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { |
| 259 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 215 | // mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 260 | // } | 216 | // } |
| 261 | // } | 217 | // } |
| 262 | // } | 218 | // } |
| 263 | // mDialogView.rbMdodificar.setOnClickListener { | 219 | // mDialogView.rbMdodificar.setOnClickListener { |
| 264 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | 220 | // if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { |
| 265 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | 221 | // mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() |
| 266 | // } | 222 | // } |
| 267 | // } | 223 | // } |
| 268 | // mDialogView.btnAceptar.setOnClickListener { | 224 | // mDialogView.btnAceptar.setOnClickListener { |
| 269 | // mAlertDialog.dismiss() | 225 | // mAlertDialog.dismiss() |
| 270 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | 226 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() |
| 271 | // fCant = 0F | 227 | // fCant = 0F |
| 272 | // fCant = name | 228 | // fCant = name |
| 273 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 229 | // listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 274 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 230 | // updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
| 275 | // viewAdapter.notifyDataSetChanged() | 231 | // viewAdapter.notifyDataSetChanged() |
| 276 | // } | 232 | // } |
| 277 | // mDialogView.dialogCancelBtn.setOnClickListener { | 233 | // mDialogView.dialogCancelBtn.setOnClickListener { |
| 278 | // mAlertDialog.dismiss() | 234 | // mAlertDialog.dismiss() |
| 279 | // } | 235 | // } |
| 280 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | 236 | //// fCant = listArticulos[indiceDelArtEncontrado].cantTomada |
| 281 | //// val type = InputType.TYPE_CLASS_NUMBER | 237 | //// val type = InputType.TYPE_CLASS_NUMBER |
| 282 | //// MaterialDialog(requireContext()).show { | 238 | //// MaterialDialog(requireContext()).show { |
| 283 | //// | 239 | //// |
| 284 | //// title(text = "Producto '$sChangeUpper', se encuentra cargado.") | 240 | //// title(text = "Producto '$sChangeUpper', se encuentra cargado.") |
| 285 | //// message(R.string.sCantidadNueva) | 241 | //// message(R.string.sCantidadNueva) |
| 286 | //// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> | 242 | //// input(waitForPositiveButton = false, hint = "99.99", inputType = type) { materialDialog, charSequence -> |
| 287 | //// fCant = 0F | 243 | //// fCant = 0F |
| 288 | //// fCant = charSequence.toString().toFloat() | 244 | //// fCant = charSequence.toString().toFloat() |
| 289 | //// } | 245 | //// } |
| 290 | //// positiveButton(R.string.btnOk) { | 246 | //// positiveButton(R.string.btnOk) { |
| 291 | //// //TODO ACTUALIZO CANTIADAD EN BD | 247 | //// //TODO ACTUALIZO CANTIADAD EN BD |
| 292 | //// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) | 248 | //// updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), fCant) |
| 293 | //// //TODO ACTUALIZO CANTIDAD EN RV | 249 | //// //TODO ACTUALIZO CANTIDAD EN RV |
| 294 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | 250 | //// listArticulos[indiceDelArtEncontrado].cantTomada = fCant |
| 295 | //// viewAdapter.notifyDataSetChanged() | 251 | //// viewAdapter.notifyDataSetChanged() |
| 296 | //// dismiss() | 252 | //// dismiss() |
| 297 | //// } | 253 | //// } |
| 298 | //// }.cancelOnTouchOutside(false).cornerRadius(10F) | 254 | //// }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 299 | // } | 255 | // } |
| 300 | // } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD | 256 | // } else if (indiceDelArtEncontrado == -1) {// no lo encontro en el RV, lo va a buscar en al BD |
| 301 | // | 257 | // |
| 302 | // GlobalScope.launch(Dispatchers.Main) { | 258 | // GlobalScope.launch(Dispatchers.Main) { |
| 303 | // //TODO BUSCO EN BASE DE DATOS | 259 | // //TODO BUSCO EN BASE DE DATOS |
| 304 | // listArticulos[indiceDelArtEncontrado].cantTomada | 260 | // listArticulos[indiceDelArtEncontrado].cantTomada |
| 305 | // val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) | 261 | // val artEncontrado = buscarCBEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 306 | // ContinuarCargaCB(artEncontrado) | 262 | // ContinuarCargaCB(artEncontrado) |
| 307 | // } | 263 | // } |
| 308 | // } | 264 | // } |
| 309 | // return@setOnKeyListener true | 265 | // return@setOnKeyListener true |
| 310 | // } | 266 | // } |
| 311 | } | 267 | } |
| 312 | } | 268 | } |
| 313 | } | 269 | } |
| 314 | return@setOnKeyListener false | 270 | return@setOnKeyListener false |
| 315 | } | 271 | } |
| 316 | return v | 272 | return v |
| 317 | } | 273 | } |
| 318 | 274 | ||
| 319 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 275 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 320 | super.onViewCreated(view, savedInstanceState) | 276 | super.onViewCreated(view, savedInstanceState) |
| 321 | navController = Navigation.findNavController(view) | 277 | navController = Navigation.findNavController(view) |
| 322 | etCodigoBarras.requestFocus() | 278 | etCodigoBarras.requestFocus() |
| 323 | val modalDialog = NoEncontradoSimple() | 279 | // val modalDialog = NoEncontradoSimple() |
| 324 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 280 | // modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
| 325 | 281 | ||
| 326 | btnBorrarInv.setOnClickListener { | 282 | btnBorrarInv.setOnClickListener { |
| 327 | AlertDialog.Builder(requireContext()) | 283 | AlertDialog.Builder(requireContext()) |
| 328 | .setTitle("Eliminación de Inventarios") | 284 | .setTitle("Eliminación de Inventarios") |
| 329 | .setMessage("¿Confirma que desea eliminar el inventario?") | 285 | .setMessage("¿Confirma que desea eliminar el inventario?") |
| 330 | .setPositiveButton(R.string.btnOk, | 286 | .setPositiveButton(R.string.btnOk, |
| 331 | DialogInterface.OnClickListener { dialog, which -> | 287 | DialogInterface.OnClickListener { dialog, which -> |
| 332 | BorrarInvActual() | 288 | BorrarInvActual() |
| 333 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | 289 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() |
| 334 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 290 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
| 335 | InventarioNuevo = 0 | 291 | InventarioNuevo = 0 |
| 336 | 292 | ||
| 337 | }) | 293 | }) |
| 338 | .setNegativeButton(R.string.btnCancelar, | 294 | .setNegativeButton(R.string.btnCancelar, |
| 339 | DialogInterface.OnClickListener { dialog, which -> | 295 | DialogInterface.OnClickListener { dialog, which -> |
| 340 | //botón cancel pulsado | 296 | //botón cancel pulsado |
| 341 | }) | 297 | }) |
| 342 | .show() | 298 | .show() |
| 343 | |||
| 344 | |||
| 345 | // MaterialDialog(requireContext()).show { | ||
| 346 | // title(R.string.sTituloBorrarInv) | ||
| 347 | // message(R.string.sMensajeBorrarInv) | ||
| 348 | // positiveButton(R.string.btnOk) { | ||
| 349 | // BorrarInvActual() | ||
| 350 | // Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Borrado", Toast.LENGTH_LONG).show() | ||
| 351 | // navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | ||
| 352 | // InventarioNuevo = 0 | ||
| 353 | // dismiss() | ||
| 354 | // } | ||
| 355 | // negativeButton { | ||
| 356 | // dismiss() | ||
| 357 | // } | ||
| 358 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | ||
| 359 | } | 299 | } |
| 360 | 300 | ||
| 361 | btnExportarInv.setOnClickListener { | 301 | btnExportarInv.setOnClickListener { |
| 362 | AlertDialog.Builder(requireContext()) | 302 | AlertDialog.Builder(requireContext()) |
| 363 | .setTitle(R.string.sTituloExportar) | 303 | .setTitle(R.string.sTituloExportar) |
| 364 | .setMessage(R.string.sMensajeExportar) | 304 | .setMessage(R.string.sMensajeExportar) |
| 365 | .setPositiveButton(R.string.btnOk, | 305 | .setPositiveButton(R.string.btnOk, |
| 366 | DialogInterface.OnClickListener { dialog, which -> | 306 | DialogInterface.OnClickListener { dialog, which -> |
| 367 | BorrarInvActual() | 307 | BorrarInvActual() |
| 368 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | 308 | Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() |
| 369 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 309 | navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
| 370 | InventarioNuevo = 0 | 310 | InventarioNuevo = 0 |
| 371 | 311 | ||
| 372 | }) | 312 | }) |
| 373 | .setNegativeButton(R.string.btnCancelar, | 313 | .setNegativeButton(R.string.btnCancelar, |
| 374 | DialogInterface.OnClickListener { dialog, which -> | 314 | DialogInterface.OnClickListener { dialog, which -> |
| 375 | //botón cancel pulsado | 315 | //botón cancel pulsado |
| 376 | }) | 316 | }) |
| 377 | .show() | 317 | .show() |
| 378 | 318 | ||
| 379 | // MaterialDialog(requireContext()).show { | 319 | // MaterialDialog(requireContext()).show { |
| 380 | // title(R.string.sTituloExportar) | 320 | // title(R.string.sTituloExportar) |
| 381 | // message(R.string.sMensajeExportar) | 321 | // message(R.string.sMensajeExportar) |
| 382 | // positiveButton(R.string.btnOk) { | 322 | // positiveButton(R.string.btnOk) { |
| 383 | // BorrarInvActual() | 323 | // BorrarInvActual() |
| 384 | // Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | 324 | // Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() |
| 385 | // navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | 325 | // navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) |
| 386 | // InventarioNuevo = 0 | 326 | // InventarioNuevo = 0 |
| 387 | // dismiss() | 327 | // dismiss() |
| 388 | // } | 328 | // } |
| 389 | // negativeButton { | 329 | // negativeButton { |
| 390 | // dismiss() | 330 | // dismiss() |
| 391 | // } | 331 | // } |
| 392 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 332 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 393 | } | 333 | } |
| 394 | ivCamara.setOnClickListener { | 334 | ivCamara.setOnClickListener { |
| 395 | if (!bFirst) { | 335 | if (!bFirst) { |
| 396 | iEstado = 1 | 336 | iEstado = 1 |
| 397 | bFirst = true | 337 | bFirst = true |
| 398 | } | 338 | } |
| 399 | 339 | ||
| 400 | when (iEstado) { | 340 | when (iEstado) { |
| 401 | 0 -> { | 341 | 0 -> { |
| 402 | ivCamara.setImageResource(R.drawable.codbar) | 342 | ivCamara.setImageResource(R.drawable.codbar) |
| 403 | etCodigoBarras.hint = "Busqueda por C. Barras" | 343 | etCodigoBarras.hint = "Busqueda por C. Barras" |
| 404 | swSumaUno.visibility = View.VISIBLE | 344 | swSumaUno.visibility = View.VISIBLE |
| 405 | iBusquedaPor = 0 | 345 | iBusquedaPor = 0 |
| 406 | iEstado = 1 | 346 | iEstado = 1 |
| 407 | } | 347 | } |
| 408 | 1 -> { | 348 | 1 -> { |
| 409 | ivCamara.setImageResource(R.drawable.desc) | 349 | ivCamara.setImageResource(R.drawable.desc) |
| 410 | etCodigoBarras.hint = "Busqueda por Descripción" | 350 | etCodigoBarras.hint = "Busqueda por Descripción" |
| 411 | swSumaUno.visibility = View.GONE | 351 | swSumaUno.visibility = View.GONE |
| 412 | iBusquedaPor = 1 | 352 | iBusquedaPor = 1 |
| 413 | iEstado = 2 | 353 | iEstado = 2 |
| 414 | } | 354 | } |
| 415 | 2 -> { | 355 | 2 -> { |
| 416 | ivCamara.setImageResource(R.drawable.cod_origen) | 356 | ivCamara.setImageResource(R.drawable.cod_origen) |
| 417 | etCodigoBarras.hint = "Busqueda por C. Origen" | 357 | etCodigoBarras.hint = "Busqueda por C. Origen" |
| 418 | swSumaUno.visibility = View.GONE | 358 | swSumaUno.visibility = View.GONE |
| 419 | iBusquedaPor = 2 | 359 | iBusquedaPor = 2 |
| 420 | iEstado = 0 | 360 | iEstado = 0 |
| 421 | } | 361 | } |
| 422 | } | 362 | } |
| 423 | } | 363 | } |
| 424 | } | 364 | } |
| 425 | 365 | ||
| 426 | private fun BorrarInvActual() { | 366 | private fun BorrarInvActual() { |
| 427 | lifecycleScope.launch { | 367 | lifecycleScope.launch { |
| 428 | withContext(Dispatchers.IO) { | 368 | withContext(Dispatchers.IO) { |
| 429 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) | 369 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.deleteinvHead(InventarioNuevo) |
| 430 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) | 370 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.deleteInvBody(InventarioNuevo) |
| 431 | } | 371 | } |
| 432 | } | 372 | } |
| 433 | } | 373 | } |
| 434 | 374 | ||
| 435 | private fun CargarDeBdInventario(ultimoInv: Int) { | 375 | private fun CargarDeBdInventario(ultimoInv: Int) { |
| 436 | GlobalScope.launch(Dispatchers.Main) { | 376 | GlobalScope.launch(Dispatchers.Main) { |
| 437 | val invbody = cargarInventario(ultimoInv) | 377 | val invbody = cargarInventario(ultimoInv) |
| 438 | for ((i, item) in invbody!!.withIndex()) { | 378 | for ((i, item) in invbody!!.withIndex()) { |
| 439 | val art = Articles(invbody[i].sector, | 379 | val art = Articles(invbody[i].sector, |
| 440 | invbody[i].codigo, | 380 | invbody[i].codigo, |
| 441 | invbody[i].descripcion, | 381 | invbody[i].descripcion, |
| 442 | invbody[i].codBar, | 382 | invbody[i].codBar, |
| 443 | invbody[i].codOrigen, | 383 | invbody[i].codOrigen, |
| 444 | invbody[i].precio, | 384 | invbody[i].precio, |
| 445 | invbody[i].costo, | 385 | invbody[i].costo, |
| 446 | "", | 386 | "", |
| 447 | "", | 387 | "", |
| 448 | "", | 388 | "", |
| 449 | invbody[i].balanza, | 389 | invbody[i].balanza, |
| 450 | invbody[i].depSn, | 390 | invbody[i].depSn, |
| 451 | invbody[i].costo) | 391 | invbody[i].costo) |
| 452 | cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) | 392 | cargarRecicler(art, invbody[i].cantTomada!!.toFloat()) |
| 453 | } | 393 | } |
| 454 | } | 394 | } |
| 455 | 395 | ||
| 456 | } | 396 | } |
| 457 | 397 | ||
| 458 | @SuppressLint("RestrictedApi") | 398 | @SuppressLint("RestrictedApi") |
| 459 | private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { | 399 | private fun ContinuarCargaDesc(artAcargar: ArrayList<Articles>) { |
| 460 | //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS | 400 | //TODO DESPUES DE INGRESAR LA DESCRIPCION Y DE BUSCAR LOS CAINCIDENCIAS EN LA BASE SE VA A MOSTRAR LAS MISMAS |
| 461 | //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV | 401 | //TODO SI LA CANTIDAD ENCONTRADA ES UNO, LO CARGO DIRECTAMENTE EN EL RV |
| 462 | 402 | ||
| 463 | if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD | 403 | if (artAcargar.isNotEmpty() || !artAcargar.isNullOrEmpty()) {// TODO: Si lo encuentra en la BD |
| 464 | // if (swSumaUno!!.isChecked) {// TODO: SI ESTA +1, PONE CANTIDAD 1 | 404 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV |
| 465 | if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | 405 | // fCant = 0F |
| 466 | fCant = 0F | 406 | // fCant += 1F |
| 467 | fCant += 1F | 407 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV |
| 468 | // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | 408 | // val acargarPorDesc = Articles(artAcargar[0].sector, |
| 469 | val acargarPorDesc = Articles(artAcargar[0].sector, | 409 | // artAcargar[0].codigo, |
| 470 | artAcargar[0].codigo, | 410 | // artAcargar[0].descripcion, |
| 471 | artAcargar[0].descripcion, | 411 | // artAcargar[0].codBar, |
| 472 | artAcargar[0].codBar, | 412 | // artAcargar[0].codOrigen, |
| 473 | artAcargar[0].codOrigen, | 413 | // artAcargar[0].precio, |
| 474 | artAcargar[0].precio, | 414 | // artAcargar[0].costo, |
| 475 | artAcargar[0].costo, | 415 | // "", |
| 476 | "", | 416 | // "", |
| 477 | "", | 417 | // "", |
| 478 | "", | 418 | // artAcargar[0].balanza, |
| 479 | artAcargar[0].balanza, | 419 | // artAcargar[0].depSn, |
| 480 | artAcargar[0].depSn, | 420 | // "") |
| 481 | "") | 421 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD |
| 482 | // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | 422 | // cargarArtEnBd(acargarPorDesc, fCant) |
| 483 | cargarArtEnBd(acargarPorDesc, fCant) | 423 | // cargarRecicler(acargarPorDesc, fCant) |
| 484 | cargarRecicler(acargarPorDesc, fCant) | 424 | // } else { |
| 485 | } else { | ||
| 486 | var bundle = Bundle() | 425 | var bundle = Bundle() |
| 487 | bundle = bundleOf("ArrayDesc" to artAcargar) | 426 | bundle = bundleOf("ArrayDesc" to artAcargar) |
| 488 | bundle.putInt("numeroInv", InventarioNuevo) | 427 | bundle.putInt("numeroInv", InventarioNuevo) |
| 489 | navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | 428 | navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) |
| 490 | //navController.backStack.removeLast() | 429 | //navController.backStack.removeLast() |
| 491 | } | 430 | // } |
| 492 | // } else {//SI NO ESTA +1 | 431 | // } else {//SI NO ESTA +1 |
| 493 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV | 432 | // if (artAcargar.size == 1) { // TODO: SI EN EL ARRAY SOLO HAY UN ITEM LO METE DIRECTAMENTE AL RV |
| 494 | // fCant = listArticulos[0].cantTomada | 433 | // fCant = listArticulos[0].cantTomada |
| 495 | // MaterialDialog(requireContext()).show { | 434 | // MaterialDialog(requireContext()).show { |
| 496 | // title(R.string.sTituloNueva) | 435 | // title(R.string.sTituloNueva) |
| 497 | // message(R.string.sCantidadNueva) | 436 | // message(R.string.sCantidadNueva) |
| 498 | // input { materialDialog, charSequence -> | 437 | // input { materialDialog, charSequence -> |
| 499 | // fCant = 0F | 438 | // fCant = 0F |
| 500 | // fCant = charSequence.toString().toFloat() | 439 | // fCant = charSequence.toString().toFloat() |
| 501 | // } | 440 | // } |
| 502 | // positiveButton(R.string.btnOk) { | 441 | // positiveButton(R.string.btnOk) { |
| 503 | // listArticulos[0].cantTomada = fCant | 442 | // listArticulos[0].cantTomada = fCant |
| 504 | // viewAdapter.notifyDataSetChanged() | 443 | // viewAdapter.notifyDataSetChanged() |
| 505 | // dismiss() | 444 | // dismiss() |
| 506 | // } | 445 | // } |
| 507 | // }.cancelOnTouchOutside(false).cornerRadius(10F) | 446 | // }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 508 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV | 447 | // // TODO PASO DEL ARRAY A UN ITEM PARA QUE LO CARGUE EN EL RV |
| 509 | // val acargarPorDesc = Articles(artAcargar[0].sector, | 448 | // val acargarPorDesc = Articles(artAcargar[0].sector, |
| 510 | // artAcargar[0].codigo, | 449 | // artAcargar[0].codigo, |
| 511 | // artAcargar[0].descripcion, | 450 | // artAcargar[0].descripcion, |
| 512 | // artAcargar[0].codBar, | 451 | // artAcargar[0].codBar, |
| 513 | // artAcargar[0].cod_origen, | 452 | // artAcargar[0].cod_origen, |
| 514 | // artAcargar[0].precio, | 453 | // artAcargar[0].precio, |
| 515 | // artAcargar[0].costo, | 454 | // artAcargar[0].costo, |
| 516 | // artAcargar[0].balanza, | 455 | // artAcargar[0].balanza, |
| 517 | // artAcargar[0].depSn, | 456 | // artAcargar[0].depSn, |
| 518 | // "") | 457 | // "") |
| 519 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD | 458 | // // TODO LO ENVIO A CARGAR EN EL RV Y EN LA BD |
| 520 | // cargarArtEnBd(acargarPorDesc, fCant) | 459 | // cargarArtEnBd(acargarPorDesc, fCant) |
| 521 | // cargarRecicler(acargarPorDesc, fCant) | 460 | // cargarRecicler(acargarPorDesc, fCant) |
| 522 | // } else { | 461 | // } else { |
| 523 | // var bundle = Bundle() | 462 | // var bundle = Bundle() |
| 524 | // bundle = bundleOf("ArrayDesc" to artAcargar) | 463 | // bundle = bundleOf("ArrayDesc" to artAcargar) |
| 525 | // bundle.putInt("numeroInv", InventarioNuevo) | 464 | // bundle.putInt("numeroInv", InventarioNuevo) |
| 526 | // navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) | 465 | // navController.navigate(R.id.action_inventarioFragment_to_descripcionFragment, bundle) |
| 527 | // } | 466 | // } |
| 528 | // } | 467 | // } |
| 529 | } else {//TODO si no lo encuentra en la BD | 468 | } else {//TODO si no lo encuentra en la BD |
| 530 | val modalDialog = DialogNoEncontrado() | 469 | val modalDialog = DialogNoEncontrado() |
| 531 | |||
| 532 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 470 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
| 533 | |||
| 534 | // MaterialDialog(requireContext()).show { | ||
| 535 | // val t=etCodigoBarras.text | ||
| 536 | // title(text = "El articulo ${etCodigoBarras.text.toString()}") | ||
| 537 | // message(R.string.sMensaje) | ||
| 538 | // positiveButton(R.string.btnOk) { | ||
| 539 | // dismiss() | ||
| 540 | // } | ||
| 541 | // }.cornerRadius(10F) | ||
| 542 | } | 471 | } |
| 543 | etCodigoBarras.focusable = View.FOCUSABLE | 472 | etCodigoBarras.focusable = View.FOCUSABLE |
| 544 | etCodigoBarras.setText("") | 473 | etCodigoBarras.setText("") |
| 545 | etCodigoBarras.selectAll() | 474 | etCodigoBarras.selectAll() |
| 546 | } | 475 | } |
| 547 | 476 | ||
| 548 | private fun ContinuarCargaCB(artAcargar: Articles?) { | 477 | private fun ContinuarCargaCB(artAcargar: Articles?) { |
| 549 | 478 | ||
| 550 | if (artAcargar != null) {// TODO: Si lo encuentra en la BD | 479 | if (artAcargar != null) {// TODO: Si lo encuentra en la BD |
| 551 | if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 | 480 | if (swSumaUno!!.isChecked) {//TODO: SI ESTA +1, PONE CANTIDAD 1 |
| 552 | fCant = 0F | 481 | fCant = 0F |
| 553 | fCant += 1F | 482 | fCant += 1F |
| 554 | cargarArtEnBd(artAcargar, fCant) | 483 | cargarArtEnBd(artAcargar, fCant) |
| 555 | cargarRecicler(artAcargar, fCant) | 484 | cargarRecicler(artAcargar, fCant) |
| 556 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD | 485 | } else {//SI NO ESTA +1 PREGUNTA CANTIDAD |
| 557 | 486 | ||
| 558 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.ingresar_cantidad, null) | 487 | DialogingresarCantidad(requireContext(),artAcargar) |
| 559 | val mBuilder = AlertDialog.Builder(context).setView(mDialogView) | ||
| 560 | .setCancelable(false) | ||
| 561 | mDialogView.tvTitulo.text = "${artAcargar.descripcion.toString()}" | ||
| 562 | val mAlertDialog = mBuilder.show() | ||
| 563 | mDialogView.btnAceptar.setOnClickListener { | ||
| 564 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { | ||
| 565 | mDialogView.etCantidad.error = "No vacio" | ||
| 566 | mDialogView.etCantidad.requestFocus() | ||
| 567 | mDialogView.etCantidad.hint = "Ingrese un valor" | ||
| 568 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | ||
| 569 | mAlertDialog.dismiss() | ||
| 570 | // fCant = 0F | ||
| 571 | // fCant = mDialogView.etCantidad.text.toString().toFloat() | ||
| 572 | cargarArtEnBd(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | ||
| 573 | cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | ||
| 574 | } | ||
| 575 | } | ||
| 576 | } | 488 | } |
| 577 | } else {// TODO si no lo encuentra en la BD | 489 | } else {// TODO si no lo encuentra en la BD |
| 578 | val modalDialog = NoEncontradoSimple() | 490 | val modalDialog = DialogNoEncontrado() |
| 579 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") | 491 | modalDialog.show(requireActivity().supportFragmentManager, "confirmDialog") |
| 580 | // MaterialDialog(requireContext()).show { | ||
| 581 | // | ||
| 582 | // title(text = "El producto: $sChangeUpper") | ||
| 583 | // message(text = "¡No fue encontrado!") | ||
| 584 | // positiveButton(R.string.btnOk) {} | ||
| 585 | // dismiss() | ||
| 586 | // } | ||
| 587 | } | 492 | } |
| 588 | etCodigoBarras.focusable = View.FOCUSABLE | 493 | etCodigoBarras.focusable = View.FOCUSABLE |
| 589 | etCodigoBarras.setText("") | 494 | etCodigoBarras.setText("") |
| 590 | etCodigoBarras.selectAll() | 495 | etCodigoBarras.selectAll() |
| 591 | } | 496 | } |
| 592 | 497 | ||
| 498 | fun DialogingresarCantidad(cnxt: Context, artAcargar: Articles?) { | ||
| 499 | val mDialogView = LayoutInflater.from(cnxt).inflate(R.layout.ingresar_cantidad, null) | ||
| 500 | val mBuilder = AlertDialog.Builder(cnxt).setView(mDialogView) | ||
| 501 | .setCancelable(false) | ||
| 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() | ||
| 504 | val mAlertDialog = mBuilder.show() | ||
| 505 | mDialogView.btnAceptar.setOnClickListener { | ||
| 506 | if (mDialogView.etCantidad.text.isNullOrEmpty()) { | ||
| 507 | mDialogView.etCantidad.error = "No vacio" | ||
| 508 | mDialogView.etCantidad.requestFocus() | ||
| 509 | mDialogView.etCantidad.hint = "Ingrese un valor" | ||
| 510 | } else if (!mDialogView.etCantidad.text.isNullOrEmpty()) { | ||
| 511 | mAlertDialog.dismiss() | ||
| 512 | cargarArtEnBd(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | ||
| 513 | cargarRecicler(artAcargar, mDialogView.etCantidad.text.toString().toFloat()) | ||
| 514 | } | ||
| 515 | } | ||
| 516 | } | ||
| 517 | |||
| 518 | fun dialogoSumaResta(context: Context, indiceDelArtEncontrado: Int, univta: String) { | ||
| 519 | val mDialogView = LayoutInflater.from(context).inflate(R.layout.login_dialog, null) | ||
| 520 | val mBuilder = | ||
| 521 | AlertDialog.Builder(context).setView(mDialogView).setTitle("${listArticulos[indiceDelArtEncontrado].descripcion} se encuentra cargado.") | ||
| 522 | // .setCancelable(false) | ||
| 523 | if (univta.contains("1" ) || univta.contains("3") || univta.contains("7")) mDialogView.tvNuevaCantidad.inputType=TYPE_CLASS_NUMBER | ||
| 524 | |||
| 525 | mDialogView.tvCantInicial.text = listArticulos[indiceDelArtEncontrado].cantTomada.toString() | ||
| 526 | val mAlertDialog = mBuilder.show() | ||
| 527 | mDialogView.rbSumar.setOnClickListener { | ||
| 528 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 529 | mDialogView.tvgenerico4.text = (mDialogView.tvCantInicial.text.toString().toFloat() + mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 530 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 531 | } | ||
| 532 | } | ||
| 533 | mDialogView.rbRestar.setOnClickListener { | ||
| 534 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 535 | if (mDialogView.tvCantInicial.text.toString().toFloat() >= mDialogView.tvNuevaCantidad.text.toString().toFloat()) { | ||
| 536 | mDialogView.tvgenerico4.text = | ||
| 537 | (mDialogView.tvCantInicial.text.toString().toFloat() - mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 538 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 539 | } | ||
| 540 | } | ||
| 541 | } | ||
| 542 | mDialogView.rbMdodificar.setOnClickListener { | ||
| 543 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 544 | mDialogView.tvgenerico4.text = (mDialogView.tvNuevaCantidad.text.toString().toFloat()).toString() | ||
| 545 | mDialogView.tvNuevaCantidad.isEnabled=false | ||
| 546 | } | ||
| 547 | } | ||
| 548 | mDialogView.btnAceptar.setOnClickListener { | ||
| 549 | if (!mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 550 | mAlertDialog.dismiss() | ||
| 551 | // val name = mDialogView.tvgenerico4.text.toString().toFloat() | ||
| 552 | // fCant = 0F | ||
| 553 | // fCant = name | ||
| 554 | listArticulos[indiceDelArtEncontrado].cantTomada = mDialogView.tvgenerico4.text.toString().toFloat() | ||
| 555 | updateCantidad(listArticulos[indiceDelArtEncontrado].sector.toString(), listArticulos[indiceDelArtEncontrado].codigo.toString(), mDialogView.tvgenerico4.text.toString().toFloat()) | ||
| 556 | viewAdapter.notifyDataSetChanged() | ||
| 557 | } else if (mDialogView.tvNuevaCantidad.text.isNullOrEmpty()) { | ||
| 558 | mDialogView.tvNuevaCantidad.error = "No vacio" | ||
| 559 | mDialogView.tvNuevaCantidad.requestFocus() | ||
| 560 | mDialogView.tvNuevaCantidad.hint = "Ingrese un valor" | ||
| 561 | } | ||
| 562 | } | ||
| 563 | mDialogView.dialogCancelBtn.setOnClickListener { | ||
| 564 | mAlertDialog.dismiss() | ||
| 565 | } | ||
| 566 | } | ||
| 567 | |||
| 593 | suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { | 568 | suspend fun buscarCBEnBD(CodigoBarras: String): Articles? { |
| 594 | //TODO BUSQUEDA POR CODIGO DE BARRAS | 569 | //TODO BUSQUEDA POR CODIGO DE BARRAS |
| 595 | var busqueda: Articles? = null | 570 | var busqueda: Articles? = null |
| 596 | return GlobalScope.async(Dispatchers.IO) { | 571 | return GlobalScope.async(Dispatchers.IO) { |
| 597 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, iArea) | 572 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(CodigoBarras, SerchArea()) |
| 598 | return@async busqueda | 573 | return@async busqueda |
| 599 | }.await() | 574 | }.await() |
| 600 | } | 575 | } |
| 601 | 576 | ||
| 602 | suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { | 577 | suspend fun buscarDescEnBD(descripcion: String): List<Articles>? { |
| 603 | //TODO BUSQUEDA POR DESCRIPCION | 578 | //TODO BUSQUEDA POR DESCRIPCION |
| 604 | var busqueda: List<Articles>? = null | 579 | var busqueda: List<Articles>? = null |
| 605 | return GlobalScope.async(Dispatchers.IO) { | 580 | return GlobalScope.async(Dispatchers.IO) { |
| 606 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, iArea) | 581 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByDesc(descripcion, SerchArea()) |
| 607 | return@async busqueda | 582 | return@async busqueda |
| 608 | }.await() | 583 | }.await() |
| 609 | } | 584 | } |
| 610 | 585 | ||
| 611 | suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { | 586 | suspend fun borrarArticulo(sector: String, codigo: String, inventario: String): Int? { |
| 612 | //TODO BUSQUEDA POR DESCRIPCION | 587 | //TODO BUSQUEDA POR DESCRIPCION |
| 613 | var result: Int | 588 | var result: Int |
| 614 | return GlobalScope.async(Dispatchers.IO) { | 589 | return GlobalScope.async(Dispatchers.IO) { |
| 615 | result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) | 590 | result = AppDb.getAppDb(requireContext())!!.InvBodyDAO()!!.deleteItemFromInvBody(sector, codigo, inventario) |
| 616 | return@async result | 591 | return@async result |
| 617 | }.await() | 592 | }.await() |
| 618 | } | 593 | } |
| 619 | 594 | ||
| 620 | private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { | 595 | private suspend fun buscoArtEnRv(codigoBarras: String, sTipoBusqueda: Int): Int { |
| 621 | 596 | ||
| 622 | return GlobalScope.async(Dispatchers.IO) { | 597 | return GlobalScope.async(Dispatchers.IO) { |
| 623 | var indice = 0 | 598 | var indice = 0 |
| 624 | var bEncontrado = false | 599 | var bEncontrado = false |
| 625 | if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS | 600 | if (sTipoBusqueda == 0) {//TODO BUSQUEDA POR CODIGO DE BARRAS |
| 626 | // TODO CAMBIO DE CB A CODIGO DEBO | 601 | // TODO CAMBIO DE CB A CODIGO DEBO |
| 627 | val any = cambioCBporCodigoDebo(codigoBarras) | 602 | val any = cambioCBporCodigoDebo(codigoBarras) |
| 628 | if (any != null) { | 603 | if (any != null) { |
| 629 | for (item in listArticulos) { | 604 | for (item in listArticulos) { |
| 630 | if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { | 605 | if (item.sector!!.toInt() == any.sector!!.toInt() && item.codigo!!.toInt() == any.codigo!!.toInt()) { |
| 631 | bEncontrado = true | 606 | bEncontrado = true |
| 632 | break | 607 | break |
| 633 | } | 608 | } |
| 634 | indice += 1 | 609 | indice += 1 |
| 635 | } | 610 | } |
| 636 | } | 611 | } |
| 637 | 612 | ||
| 638 | } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION | 613 | } else if (sTipoBusqueda == 1) {//TODO BUSQUEDA POR DESCRIPCION |
| 639 | for (item in listArticulos) { | 614 | for (item in listArticulos) { |
| 640 | if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | 615 | if (item.descripcion!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
| 641 | bEncontrado = true | 616 | bEncontrado = true |
| 642 | break | 617 | break |
| 643 | } | 618 | } |
| 644 | indice += 1 | 619 | indice += 1 |
| 645 | } | 620 | } |
| 646 | } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN | 621 | } else if (sTipoBusqueda == 2) {//TODO BUSQUEDA POR CODIGO DE ORIGEN |
| 647 | for (item in listArticulos) { | 622 | for (item in listArticulos) { |
| 648 | if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { | 623 | if (item.codigoOrigen!!.toUpperCase(Locale.ROOT).contains(codigoBarras)) { |
| 649 | bEncontrado = true | 624 | bEncontrado = true |
| 650 | break | 625 | break |
| 651 | } | 626 | } |
| 652 | indice += 1 | 627 | indice += 1 |
| 653 | } | 628 | } |
| 654 | } | 629 | } |
| 655 | return@async if (bEncontrado) indice else -1 | 630 | return@async if (bEncontrado) indice else -1 |
| 656 | }.await() | 631 | }.await() |
| 657 | } | 632 | } |
| 658 | 633 | ||
| 659 | suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { | 634 | suspend fun cambioCBporCodigoDebo(codigoBarras: String): Articles? { |
| 660 | //TODO BUSQUEDA POR DESCRIPCION | 635 | //TODO BUSQUEDA POR DESCRIPCION |
| 661 | var busqueda: Articles? = null | 636 | var busqueda: Articles? = null |
| 662 | return GlobalScope.async(Dispatchers.IO) { | 637 | return GlobalScope.async(Dispatchers.IO) { |
| 663 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, iArea) | 638 | busqueda = AppDb.getAppDb(requireContext())!!.ArticulosDAO()!!.findArticuloByCodBar(codigoBarras, SerchArea()) |
| 664 | return@async busqueda | 639 | return@async busqueda |
| 665 | }.await() | 640 | }.await() |
| 666 | } | 641 | } |
| 667 | 642 | ||
| 668 | private fun cargarArtEnBd(articulos: Articles, cant: Float) { | 643 | private fun cargarArtEnBd(articulos: Articles, cant: Float) { |
| 669 | val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD | 644 | val body = InvBody(InventarioNuevo,// TODO PREPARO PARA MANDAR A CARGAR EN LA BD |
| 670 | articulos.sector, | 645 | articulos.sector, |
| 671 | articulos.codigo, | 646 | articulos.codigo, |
| 672 | articulos.descripcion, | 647 | articulos.descripcion, |
| 673 | cant.toString(), | 648 | cant.toString(), |
| 674 | articulos.codBar, | 649 | articulos.codBar, |
| 675 | articulos.codOrigen, | 650 | articulos.codOrigen, |
| 676 | articulos.precio, | 651 | articulos.precio, |
| 677 | articulos.precio, | 652 | articulos.precio, |
| 678 | articulos.balanza, | 653 | articulos.balanza, |
| 679 | articulos.depSn, | 654 | articulos.depSn, |
| 680 | ObtenerFechaActual(), | 655 | ObtenerFechaActual(), |
| 681 | ObtenerFechaActual()) | 656 | ObtenerFechaActual()) |
| 682 | InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS | 657 | InsertarArtEnDB(body)// TODO MANDO A CARGAR A LA BASE DE DATOS |
| 683 | } | 658 | } |
| 684 | 659 | ||
| 685 | fun cargarRecicler(articulos: Articles, cant: Float) { | 660 | fun cargarRecicler(articulos: Articles, cant: Float) { |
| 686 | //TODO CARGO EN LE RV | 661 | //TODO CARGO EN LE RV |
| 687 | val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen) | 662 | val item = ItemsRecycler(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar, articulos.codOrigen, articulos.balanza.toString(),articulos.de.toString()) |
| 688 | listArticulos.add(item) | 663 | listArticulos.add(item) |
| 689 | 664 | ||
| 690 | viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) | 665 | viewAdapter = ProductosListAdapter(requireContext(), listArticulos, this) |
| 691 | viewManager = LinearLayoutManager(requireContext()) | 666 | viewManager = LinearLayoutManager(requireContext()) |
| 692 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! | 667 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! |
| 693 | rcInventarios.apply { | 668 | rcInventarios.apply { |
| 694 | adapter = viewAdapter | 669 | adapter = viewAdapter |
| 695 | layoutManager = viewManager | 670 | layoutManager = viewManager |
| 696 | } | 671 | } |
| 697 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { | 672 | val itemTouchHelperCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { |
| 698 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { | 673 | override fun onMove(p0: RecyclerView, p1: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { |
| 699 | return false | 674 | return false |
| 700 | } | 675 | } |
| 701 | 676 | ||
| 702 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | 677 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { |
| 703 | 678 | ||
| 704 | GlobalScope.launch(Dispatchers.Main) { | 679 | GlobalScope.launch(Dispatchers.Main) { |
| 705 | borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) | 680 | borrarArticulo(listArticulos[viewHolder.adapterPosition].sector.toString(), listArticulos[viewHolder.adapterPosition].codigo.toString(), InventarioNuevo.toString()) |
| 706 | (viewAdapter as ProductosListAdapter).removeItem(viewHolder) | 681 | (viewAdapter as ProductosListAdapter).removeItem(viewHolder) |
| 707 | viewAdapter.notifyDataSetChanged() | 682 | viewAdapter.notifyDataSetChanged() |
| 708 | } | 683 | } |
| 709 | } | 684 | } |
| 710 | 685 | ||
| 711 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { | 686 | override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { |
| 712 | val itemView = viewHolder.itemView | 687 | val itemView = viewHolder.itemView |
| 713 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 | 688 | val iconMargin = (itemView.height - deleteIcon.intrinsicHeight) / 2 |
| 714 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) | 689 | c.clipRect(0f, itemView.top.toFloat(), dX, itemView.bottom.toFloat()) |
| 715 | 690 | ||
| 716 | if (dX > 0) { | 691 | if (dX > 0) { |
| 717 | 692 | ||
| 718 | if (dX < c.width / 2) c.drawColor(Color.GREEN) | 693 | if (dX < c.width / 2) c.drawColor(Color.GREEN) |
| 719 | else c.drawColor(Color.RED) | 694 | else c.drawColor(Color.RED) |
| 720 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | 695 | deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) |
| 721 | } else { | 696 | } else { |
| 722 | } | 697 | } |
| 723 | 698 | ||
| 724 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) | 699 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) |
| 725 | deleteIcon.draw(c) | 700 | deleteIcon.draw(c) |
| 726 | } | 701 | } |
| 727 | } | 702 | } |
| 728 | 703 | ||
| 729 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) | 704 | val itemTouchHelper = ItemTouchHelper(itemTouchHelperCallback) |
| 730 | itemTouchHelper.attachToRecyclerView(rcInventarios) | 705 | itemTouchHelper.attachToRecyclerView(rcInventarios) |
| 731 | } | 706 | } |
| 732 | 707 | ||
| 733 | private fun ProdNoCont(): Int? { | 708 | private fun ProdNoCont(): Int? { |
| 734 | var mostrarStock = 0 | 709 | var mostrarStock = 0 |
| 735 | if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 | 710 | if (sharedPreferences.contains("cbMostrarStock")) if (sharedPreferences.getString("cbMostrarStock", "").toString() == "1") mostrarStock = 1 |
| 736 | return mostrarStock | 711 | return mostrarStock |
| 737 | } | 712 | } |
| 738 | 713 | ||
| 739 | private fun AjusteProductos(): Int? { | 714 | private fun AjusteProductos(): Int? { |
| 740 | var prodInclu = 0 | 715 | var prodInclu = 0 |
| 741 | if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 | 716 | if (sharedPreferences.contains("rbProInclu")) if (sharedPreferences.getString("rbProInclu", "").toString() == "1") prodInclu = 1 |
| 742 | 717 | ||
| 743 | if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 | 718 | if (sharedPreferences.contains("rbProNoInclu")) if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") prodInclu = 0 |
| 744 | return prodInclu | 719 | return prodInclu |
| 745 | } | 720 | } |
| 746 | 721 | ||
| 747 | private fun SerchArea() { | 722 | private fun SerchArea(): Int { |
| 748 | if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 | 723 | if (sharedPreferences.contains("rbVentas")) if (sharedPreferences.getString("rbVentas", "").toString() == "1") iArea = 0 |
| 749 | if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 | 724 | if (sharedPreferences.contains("rbDeposito")) if (sharedPreferences.getString("rbDeposito", "").toString() == "1") iArea = 1 |
| 725 | return iArea | ||
| 750 | } | 726 | } |
| 751 | 727 | ||
| 752 | fun ObtenerFechaActual(): String? { | 728 | fun ObtenerFechaActual(): String? { |
| 753 | //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD | 729 | //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD |
| 754 | val current = LocalDateTime.now() | 730 | val current = LocalDateTime.now() |
| 755 | val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") | 731 | val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") |
| 756 | val dFechaHora = current.format(formatter) | 732 | val dFechaHora = current.format(formatter) |
| 757 | return dFechaHora.toString() | 733 | return dFechaHora.toString() |
| 758 | } | 734 | } |
| 759 | 735 | ||
| 760 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { | 736 | fun InsertarArtEnDB(cuarpoInventario: InvBody) { |
| 761 | lifecycleScope.launch { | 737 | lifecycleScope.launch { |
| 762 | withContext(Dispatchers.IO) { | 738 | withContext(Dispatchers.IO) { |
| 763 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) | 739 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.insertInvBody(cuarpoInventario) |
| 764 | } | 740 | } |
| 765 | } | 741 | } |
| 766 | } | 742 | } |
| 767 | 743 | ||
| 768 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { | 744 | fun updateCantidad(sector: String, codigo: String, cantidad: Float) { |
| 769 | lifecycleScope.launch { | 745 | lifecycleScope.launch { |
| 770 | withContext(Dispatchers.IO) { | 746 | withContext(Dispatchers.IO) { |
| 771 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) | 747 | AppDb.getAppDb(requireActivity())!!.InvBodyDAO()!!.UpdateInvBody(cantidad, sector, codigo) |
| 772 | } | 748 | } |
| 773 | } | 749 | } |
| 774 | } | 750 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ItemsRecycler.kt
| 1 | package com.focasoftware.deboinventariov20.ui.inventario | 1 | package com.focasoftware.deboinventariov20.ui.inventario |
| 2 | 2 | ||
| 3 | import android.widget.ImageView | 3 | import android.widget.ImageView |
| 4 | 4 | ||
| 5 | data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?) { | 5 | data class ItemsRecycler(val sector: String?,val codigo: String?, val descripcion: String?, var cantTomada: Float, val codigoBarras: String?, val codigoOrigen: String?,val univta: String,val dev:String) { |
| 6 | 6 | ||
| 7 | } | 7 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/ProductosListAdapter.kt
| 1 | package com.focasoftware.deboinventariov20.ui.inventario | 1 | package com.focasoftware.deboinventariov20.ui.inventario |
| 2 | 2 | ||
| 3 | import android.content.Context | 3 | import android.content.Context |
| 4 | import android.view.LayoutInflater | 4 | import android.view.LayoutInflater |
| 5 | import android.view.View | 5 | import android.view.View |
| 6 | import android.view.ViewGroup | 6 | import android.view.ViewGroup |
| 7 | import androidx.recyclerview.widget.RecyclerView | 7 | import androidx.recyclerview.widget.RecyclerView |
| 8 | import com.focasoftware.deboinventariov20.R | 8 | import com.focasoftware.deboinventariov20.R |
| 9 | import com.focasoftware.deboinventariov20.ui.main.ItemInventario | 9 | import com.focasoftware.deboinventariov20.ui.main.ItemInventario |
| 10 | import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder | 10 | import com.focasoftware.deboinventariov20.ui.util.Base.BaseViewHolder |
| 11 | import com.google.android.material.snackbar.Snackbar | 11 | import com.google.android.material.snackbar.Snackbar |
| 12 | import kotlinx.android.synthetic.main.item.view.* | 12 | import kotlinx.android.synthetic.main.item.view.* |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) : | 15 | class ProductosListAdapter(private val context: Context,private val productos: ArrayList<ItemsRecycler>, private val itemImageClickListener: OnImageDotsClickListener) : |
| 16 | RecyclerView.Adapter<BaseViewHolder<*>>() { | 16 | RecyclerView.Adapter<BaseViewHolder<*>>() { |
| 17 | 17 | ||
| 18 | private var removePosition: Int = 0 | 18 | private var removePosition: Int = 0 |
| 19 | private var removedItem: ItemsRecycler? = null | 19 | private var removedItem: ItemsRecycler? = null |
| 20 | // private var items2: ArrayList<ItemsRecycler>? = null | ||
| 21 | 20 | ||
| 22 | interface OnImageDotsClickListener { | 21 | interface OnImageDotsClickListener { |
| 23 | fun onImageDotsClick(sector: String?,codigo: String?) | 22 | fun onImageDotsClick(sector: String?,codigo: String?) |
| 24 | fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) | 23 | fun onImagePenClick(sector: String?, codigo: String?, cantidad: String?, position: String) |
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | // init { | ||
| 28 | // this.items2 = productos | ||
| 29 | // } | ||
| 30 | |||
| 31 | override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) | 26 | override fun onCreateViewHolder(parent: ViewGroup, p1: Int) = ItemsViewHolder(LayoutInflater.from(context).inflate(R.layout.item, parent, false)) |
| 32 | 27 | ||
| 33 | override fun getItemCount() = productos.size | 28 | override fun getItemCount() = productos.size |
| 34 | 29 | ||
| 35 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | 30 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { |
| 36 | when (holder) { | 31 | when (holder) { |
| 37 | is ItemsViewHolder -> { holder.bind(productos[position], position) } | 32 | is ItemsViewHolder -> { holder.bind(productos[position], position) } |
| 38 | 33 | ||
| 39 | } | 34 | } |
| 40 | } | 35 | } |
| 41 | inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) { | 36 | inner class ItemsViewHolder (itemView: View) : BaseViewHolder<ItemsRecycler>(itemView) { |
| 42 | override fun bind(item: ItemsRecycler, position: Int) { | 37 | override fun bind(item: ItemsRecycler, position: Int) { |
| 43 | itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) } | 38 | itemView.ivDots.setOnClickListener {itemImageClickListener.onImageDotsClick(item.sector,item.codigo) } |
| 44 | itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) } | 39 | itemView.ivPen.setOnClickListener {itemImageClickListener.onImagePenClick(item.sector,item.codigo,item.cantTomada.toString(),adapterPosition.toString()) } |
| 45 | 40 | ||
| 46 | itemView.tvSector.text=item.sector | 41 | itemView.tvSector.text=item.sector |
| 47 | itemView.tvCodigo.text=item.codigo | 42 | itemView.tvCodigo.text=item.codigo |
| 48 | itemView.tvDescripcion.text=item.descripcion | 43 | itemView.tvDescripcion.text=item.descripcion |
| 49 | itemView.tvCantidad.text=item.cantTomada.toString() | 44 | itemView.tvCantidad.text=item.cantTomada.toString() |
| 50 | itemView.tvCodigoBarras.text=item.sector | 45 | itemView.tvCodigoBarras.text=item.sector |
| 51 | itemView.tvCodigoOrigen.text=item.sector | 46 | itemView.tvCodigoOrigen.text=item.sector |
| 52 | itemView.ivPen.setImageResource(R.drawable.pen) | 47 | itemView.ivPen.setImageResource(R.drawable.pen) |
| 53 | itemView.ivDots.setImageResource(R.drawable.more) | 48 | itemView.ivDots.setImageResource(R.drawable.more) |
| 54 | |||
| 55 | } | 49 | } |
| 56 | // val sector = itemView.tvSector | ||
| 57 | // val codigo = itemView.tvCodigo | ||
| 58 | // val descripcion = itemView.tvDescripcion | ||
| 59 | // val cantCont = itemView.tvCantidad | ||
| 60 | // val codigoBarras = itemView.tvCodigoBarras | ||
| 61 | // val codigoOrigen = itemView.tvCodigoOrigen | ||
| 62 | // val imageDots = itemView.ivDots | ||
| 63 | // val imagePen = itemView.ivPen | ||
| 64 | // | ||
| 65 | // fun bind(pro: ItemsRecycler) { | ||
| 66 | // | ||
| 67 | // } | ||
| 68 | |||
| 69 | |||
| 70 | } | 50 | } |
| 71 | 51 | ||
| 72 | fun removeItem(viewHolder: RecyclerView.ViewHolder) { | 52 | fun removeItem(viewHolder: RecyclerView.ViewHolder) { |
| 73 | removePosition = viewHolder.adapterPosition | 53 | removePosition = viewHolder.adapterPosition |
| 74 | removedItem = productos[viewHolder.adapterPosition] | 54 | removedItem = productos[viewHolder.adapterPosition] |
| 75 | 55 | ||
| 76 | productos.removeAt(viewHolder.adapterPosition) | 56 | productos.removeAt(viewHolder.adapterPosition) |
| 77 | notifyItemRemoved(viewHolder.adapterPosition) | 57 | notifyItemRemoved(viewHolder.adapterPosition) |
| 78 | // | ||
| 79 | // Snackbar.make(viewHolder.itemView, "El articulo fue ${removedItem!!.descripcion} eliminado", Snackbar.LENGTH_LONG).setAction("Rehacer") { | ||
| 80 | // productos.add(removePosition, removedItem!!) | ||
| 81 | // notifyItemInserted(removePosition) | ||
| 82 | // }.show() | ||
| 83 | } | 58 | } |
| 84 | 59 | ||
| 85 | 60 | ||
| 86 | } | 61 | } |
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: ArrayList<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 = item.invNum.toString() |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { | 32 | override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { |
| 33 | when (holder) { | 33 | when (holder) { |
| 34 | is ItemsViewHolder -> holder.bind(inv[position], position) | 34 | is ItemsViewHolder -> holder.bind(inv[position], position) |
| 35 | else -> IllegalArgumentException("No se pudo pasar el ViewHolder") | 35 | else -> IllegalArgumentException("No se pudo pasar el ViewHolder") |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 |
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.CheckBox | 9 | import android.widget.CheckBox |
| 10 | import android.widget.ImageView | 10 | import android.widget.ImageView |
| 11 | import android.widget.LinearLayout | 11 | import android.widget.LinearLayout |
| 12 | import android.widget.TextView | 12 | import android.widget.TextView |
| 13 | import androidx.fragment.app.Fragment | 13 | import androidx.fragment.app.Fragment |
| 14 | import androidx.navigation.NavController | 14 | import androidx.navigation.NavController |
| 15 | import androidx.navigation.Navigation | 15 | import androidx.navigation.Navigation |
| 16 | import androidx.recyclerview.widget.LinearLayoutManager | 16 | import androidx.recyclerview.widget.LinearLayoutManager |
| 17 | import androidx.recyclerview.widget.RecyclerView | 17 | import androidx.recyclerview.widget.RecyclerView |
| 18 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb | 18 | import com.focasoftware.deboinventariov20.DB.DataBase.AppDb |
| 19 | import com.focasoftware.deboinventariov20.Model.InvHead | 19 | import com.focasoftware.deboinventariov20.Model.InvHead |
| 20 | import com.focasoftware.deboinventariov20.R | 20 | import com.focasoftware.deboinventariov20.R |
| 21 | import com.focasoftware.deboinventariov20.ui.inventario.ItemsRecycler | ||
| 21 | import kotlinx.coroutines.Dispatchers | 22 | import kotlinx.coroutines.Dispatchers |
| 22 | import kotlinx.coroutines.GlobalScope | 23 | import kotlinx.coroutines.GlobalScope |
| 23 | import kotlinx.coroutines.async | 24 | import kotlinx.coroutines.async |
| 24 | import kotlinx.coroutines.launch | 25 | import kotlinx.coroutines.launch |
| 25 | import java.util.* | 26 | import java.util.* |
| 26 | 27 | ||
| 27 | class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { | 28 | class MainFragment : Fragment(), InventarioListAdapter.OnInventarioClickListener { |
| 28 | private lateinit var inventarios: ArrayList<InvHead> | 29 | private lateinit var inventarios: List<InvHead> |
| 29 | private lateinit var ordenado: ArrayList<InvHead> | 30 | private lateinit var ordenado: List<InvHead> |
| 30 | private lateinit var rcInventario: RecyclerView | 31 | private lateinit var rcInventario: RecyclerView |
| 31 | private lateinit var viewAdapter: RecyclerView.Adapter<*> | 32 | private lateinit var viewAdapter: RecyclerView.Adapter<*> |
| 32 | private lateinit var viewManager: RecyclerView.LayoutManager | 33 | private lateinit var viewManager: RecyclerView.LayoutManager |
| 33 | private var listIvn = ArrayList<InvHead>() | 34 | // private var listIvn2 = List<InvHead>() |
| 35 | private var listIvn2 = ArrayList<InvHead>() | ||
| 34 | private lateinit var navController: NavController | 36 | private lateinit var navController: NavController |
| 35 | private lateinit var sharedPreferences: SharedPreferences | 37 | private lateinit var sharedPreferences: SharedPreferences |
| 36 | private var cantidadInventarios: Int = 0 | 38 | private var cantidadInventarios: Int = 0 |
| 37 | 39 | ||
| 38 | override fun onCreate(savedInstanceState: Bundle?) { | 40 | override fun onCreate(savedInstanceState: Bundle?) { |
| 39 | super.onCreate(savedInstanceState) | 41 | super.onCreate(savedInstanceState) |
| 40 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) | 42 | sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE) |
| 41 | } | 43 | } |
| 42 | 44 | ||
| 43 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | 45 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
| 44 | var bAbiertoCerrado = false | 46 | var bAbiertoCerrado = false |
| 45 | val v = inflater.inflate(R.layout.fragment_main, container, false) | 47 | val v = inflater.inflate(R.layout.fragment_main, container, false) |
| 46 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) | 48 | val tvInvDinamicos = v.findViewById<TextView>(R.id.tvInvDinamicos) |
| 47 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) | 49 | val txtDeposito = v.findViewById<TextView>(R.id.txtDeposito) |
| 48 | val tvFecha = v.findViewById<TextView>(R.id.tvFecha) | ||
| 49 | val ivSort19= v.findViewById<ImageView>(R.id.ivSort19) | 50 | val ivSort19= v.findViewById<ImageView>(R.id.ivSort19) |
| 50 | val ivSort91= v.findViewById<ImageView>(R.id.ivSort91) | 51 | val ivSort91= v.findViewById<ImageView>(R.id.ivSort91) |
| 51 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) | 52 | val cbVentas= v.findViewById<CheckBox>(R.id.cbVentas) |
| 52 | val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) | 53 | val cbDeposito= v.findViewById<CheckBox>(R.id.cbDeposito) |
| 53 | 54 | ||
| 54 | rcInventario = v.findViewById(R.id.rcInventario) | 55 | rcInventario = v.findViewById(R.id.rcInventario) |
| 55 | 56 | ||
| 56 | GlobalScope.launch(Dispatchers.Main) { | 57 | GlobalScope.launch(Dispatchers.Main) { |
| 57 | inventarios = buscarEnBDInvHead() | 58 | inventarios = buscarEnBDInvHead() |
| 58 | for ((i, item) in inventarios.withIndex()) { | 59 | for ((i, item) in inventarios.withIndex()) { |
| 59 | val inv = InvHead(inventarios[i].invNum, | 60 | val inv = InvHead(inventarios[i].invNum, |
| 60 | inventarios[i].descripcion, | 61 | inventarios[i].descripcion, |
| 61 | inventarios[i].estado, | 62 | inventarios[i].estado, |
| 62 | inventarios[i].fechaInicio, | 63 | inventarios[i].fechaInicio, |
| 63 | inventarios[i].fechaFinal, | 64 | inventarios[i].fechaFinal, |
| 64 | inventarios[i].prodContados, | 65 | inventarios[i].prodContados, |
| 65 | inventarios[i].lugar, | 66 | inventarios[i].lugar, |
| 66 | inventarios[i].stDesc, | 67 | inventarios[i].stDesc, |
| 67 | inventarios[i].proNoCont) | 68 | inventarios[i].proNoCont) |
| 68 | cargarRecicler(inv) | 69 | cargarRecicler(inv) |
| 69 | cantidadInventarios = i + 1 | 70 | cantidadInventarios = i + 1 |
| 70 | } | 71 | } |
| 71 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})+" | 72 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" |
| 72 | tvInvDinamicos.setOnClickListener { | 73 | tvInvDinamicos.setOnClickListener { |
| 73 | if (!bAbiertoCerrado) { | 74 | if (!bAbiertoCerrado) { |
| 74 | bAbiertoCerrado = true | 75 | bAbiertoCerrado = true |
| 75 | txtDeposito.visibility = View.GONE | 76 | txtDeposito.visibility = View.GONE |
| 76 | rcInventario.visibility = View.VISIBLE | 77 | rcInventario.visibility = View.VISIBLE |
| 77 | ivSort91.visibility = View.VISIBLE | 78 | ivSort91.visibility = View.INVISIBLE |
| 78 | ivSort19.visibility = View.INVISIBLE | 79 | ivSort19.visibility = View.VISIBLE |
| 79 | tvFecha.visibility = View.VISIBLE | ||
| 80 | cbVentas.visibility = View.VISIBLE | 80 | cbVentas.visibility = View.VISIBLE |
| 81 | cbDeposito.visibility = View.VISIBLE | 81 | cbDeposito.visibility = View.VISIBLE |
| 82 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})-" | 82 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) -" |
| 83 | } else { | 83 | } else { |
| 84 | bAbiertoCerrado = false | 84 | bAbiertoCerrado = false |
| 85 | rcInventario.visibility = View.GONE | 85 | rcInventario.visibility = View.GONE |
| 86 | ivSort91.visibility = View.GONE | 86 | ivSort91.visibility = View.GONE |
| 87 | ivSort19.visibility = View.GONE | 87 | ivSort19.visibility = View.GONE |
| 88 | tvFecha.visibility = View.GONE | ||
| 89 | txtDeposito.visibility = View.VISIBLE | 88 | txtDeposito.visibility = View.VISIBLE |
| 90 | cbVentas.visibility = View.GONE | 89 | cbVentas.visibility = View.GONE |
| 91 | cbDeposito.visibility = View.GONE | 90 | cbDeposito.visibility = View.GONE |
| 92 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()})+" | 91 | tvInvDinamicos.text = "Inventarios Dinamicos (${cantidadInventarios.toString()}) +" |
| 93 | } | 92 | } |
| 94 | } | 93 | } |
| 95 | ivSort91.setOnClickListener { | 94 | ivSort19.setOnClickListener { |
| 96 | ordenado= inventarios.sortedByDescending { | 95 | ordenado= inventarios.sortedByDescending { |
| 97 | it.invNum | 96 | it.invNum |
| 98 | } as ArrayList<InvHead> | 97 | } |
| 98 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | ||
| 99 | viewManager = LinearLayoutManager(requireContext()) | ||
| 100 | |||
| 101 | rcInventario.apply { | ||
| 102 | adapter = viewAdapter | ||
| 103 | layoutManager = viewManager | ||
| 104 | } | ||
| 105 | viewAdapter.notifyDataSetChanged() | ||
| 106 | ivSort19.visibility=View.INVISIBLE | ||
| 107 | ivSort91.visibility=View.VISIBLE | ||
| 108 | } | ||
| 109 | ivSort91.setOnClickListener { | ||
| 110 | ordenado= inventarios.sortedBy { | ||
| 111 | it.invNum | ||
| 112 | } | ||
| 99 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) | 113 | viewAdapter = InventarioListAdapter(requireContext(), ordenado, this@MainFragment) |
| 100 | viewManager = LinearLayoutManager(requireContext()) | 114 | viewManager = LinearLayoutManager(requireContext()) |
| 101 | 115 | ||
| 102 | rcInventario.apply { | 116 | rcInventario.apply { |
| 103 | adapter = viewAdapter | 117 | adapter = viewAdapter |
| 104 | layoutManager = viewManager | 118 | layoutManager = viewManager |
| 105 | } | 119 | } |
| 106 | viewAdapter.notifyDataSetChanged() | 120 | viewAdapter.notifyDataSetChanged() |
| 121 | ivSort91.visibility=View.INVISIBLE | ||
| 122 | ivSort19.visibility=View.VISIBLE | ||
| 107 | } | 123 | } |
| 108 | } | 124 | } |
| 109 | return v | 125 | return v |
| 110 | } | 126 | } |
| 111 | 127 | ||
| 112 | suspend fun buscarEnBDInvHead(): ArrayList<InvHead> { | 128 | suspend fun buscarEnBDInvHead(): List<InvHead> { |
| 113 | //TODO BUSQUEDA POR DESCRIPCION | 129 | //TODO BUSQUEDA POR DESCRIPCION |
| 114 | var busqueda: ArrayList<InvHead> | 130 | var busqueda: List<InvHead> |
| 115 | return GlobalScope.async(Dispatchers.IO) { | 131 | return GlobalScope.async(Dispatchers.IO) { |
| 116 | busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() | 132 | busqueda = AppDb.getAppDb(requireContext())!!.InvHeadDAO()!!.fetchAllInvHead() |
| 117 | return@async busqueda | 133 | return@async busqueda |
| 118 | }.await() | 134 | }.await() |
| 119 | } | 135 | } |
| 120 | 136 | ||
| 121 | fun cargarRecicler(inv: InvHead) { | 137 | fun cargarRecicler(inv: InvHead) { |
| 122 | //TODO CARGO EN LE RV | 138 | //TODO CARGO EN LE RV |
| 123 | 139 | ||
| 124 | val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() | 140 | val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString() |
| 125 | val item = ItemInventario("N° $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") | 141 | val item = ItemInventario("N° $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") |
| 126 | //(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar) | 142 | //(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar) |
| 127 | // listIvn.add(item) | 143 | // listIvn.add(item) |
| 128 | listIvn.add(inv) | 144 | listIvn2.add(inv) |
| 129 | viewAdapter = InventarioListAdapter(requireContext(), listIvn, this) | 145 | viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this) |
| 130 | viewManager = LinearLayoutManager(requireContext()) | 146 | viewManager = LinearLayoutManager(requireContext()) |
| 131 | 147 | ||
| 132 | rcInventario.apply { | 148 | rcInventario.apply { |
| 133 | adapter = viewAdapter | 149 | adapter = viewAdapter |
| 134 | layoutManager = viewManager | 150 | layoutManager = viewManager |
| 135 | } | 151 | } |
| 136 | } | 152 | } |
| 137 | 153 | ||
| 138 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 154 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 139 | super.onViewCreated(view, savedInstanceState) | 155 | super.onViewCreated(view, savedInstanceState) |
| 140 | navController = Navigation.findNavController(view) | 156 | navController = Navigation.findNavController(view) |
| 141 | listIvn.clear() | 157 | listIvn2.clear() |
| 142 | } | 158 | } |
| 143 | 159 | ||
| 144 | override fun onItemClick(inventario: String?) { | 160 | override fun onItemClick(inventario: String?) { |
| 145 | 161 | ||
| 146 | val editor = sharedPreferences.edit() | 162 | val editor = sharedPreferences.edit() |
| 147 | // var invSel: String = inventario.toString() | 163 | // var invSel: String = inventario.toString() |
| 148 | // invSel = invSel.substring(3, 5) | 164 | // invSel = invSel.substring(3, 5) |
| 149 | editor?.putString("Inventario", inventario) | 165 | editor?.putString("Inventario", inventario) |
| 150 | editor?.apply() | 166 | editor?.apply() |
| 151 | editor.commit() | 167 | editor.commit() |
| 152 | navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) | 168 | navController.navigate(R.id.action_mainFragment2_to_inventarioFragment) |
| 153 | } | 169 | } |
| 154 | 170 | ||
| 155 | 171 |
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 | <ImageView | 26 | <ImageView |
| 27 | android:id="@+id/ivSort19" | 27 | android:id="@+id/ivSort19" |
| 28 | android:layout_width="wrap_content" | 28 | android:layout_width="35dp" |
| 29 | android:layout_height="wrap_content" | 29 | android:layout_height="35dp" |
| 30 | android:layout_margin="10dp" | 30 | android:layout_margin="10dp" |
| 31 | android:padding="5dp" | ||
| 31 | android:contentDescription=" " | 32 | android:contentDescription=" " |
| 32 | android:visibility="gone" | 33 | android:visibility="gone" |
| 33 | android:src="@drawable/ic_sort19" | 34 | android:src="@drawable/ic_sort19" |
| 34 | app:layout_constraintHorizontal_bias="0.0" | 35 | app:layout_constraintHorizontal_bias="0.0" |
| 35 | app:layout_constraintHorizontal_chainStyle="packed" | 36 | app:layout_constraintHorizontal_chainStyle="packed" |
| 36 | app:layout_constraintStart_toStartOf="parent" | 37 | app:layout_constraintStart_toStartOf="parent" |
| 37 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | 38 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
| 38 | 39 | ||
| 39 | <ImageView | 40 | <ImageView |
| 40 | android:id="@+id/ivSort91" | 41 | android:id="@+id/ivSort91" |
| 41 | android:layout_width="wrap_content" | 42 | android:layout_width="35dp" |
| 42 | android:layout_height="wrap_content" | 43 | android:layout_height="35dp" |
| 43 | android:layout_margin="10dp" | 44 | android:layout_margin="10dp" |
| 45 | android:padding="5dp" | ||
| 44 | android:layout_marginTop="12dp" | 46 | android:layout_marginTop="12dp" |
| 45 | android:contentDescription=" " | 47 | android:contentDescription="Fecha" |
| 46 | android:visibility="gone" | 48 | android:visibility="gone" |
| 47 | android:src="@drawable/ic_sort91" | 49 | android:src="@drawable/ic_sort91" |
| 48 | app:layout_constraintHorizontal_bias="1.0" | 50 | app:layout_constraintHorizontal_bias="1.0" |
| 49 | app:layout_constraintHorizontal_chainStyle="packed" | 51 | app:layout_constraintHorizontal_chainStyle="packed" |
| 50 | app:layout_constraintStart_toStartOf="parent" | 52 | app:layout_constraintStart_toStartOf="parent" |
| 51 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | 53 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> |
| 52 | 54 | ||
| 53 | <TextView | ||
| 54 | android:id="@+id/tvFecha" | ||
| 55 | android:layout_width="wrap_content" | ||
| 56 | android:layout_height="wrap_content" | ||
| 57 | android:layout_marginTop="5dp" | ||
| 58 | android:text="Fecha" | ||
| 59 | android:textColor="@android:color/black" | ||
| 60 | android:textSize="25sp" | ||
| 61 | android:visibility="gone" | ||
| 62 | android:textStyle="bold" | ||
| 63 | app:layout_constraintBottom_toTopOf="@id/rcInventario" | ||
| 64 | app:layout_constraintHorizontal_chainStyle="packed" | ||
| 65 | app:layout_constraintStart_toEndOf="@+id/ivSort19" | ||
| 66 | app:layout_constraintTop_toBottomOf="@id/tvInvDinamicos" /> | ||
| 67 | 55 | ||
| 68 | <androidx.recyclerview.widget.RecyclerView | 56 | <androidx.recyclerview.widget.RecyclerView |
| 69 | android:id="@+id/rcInventario" | 57 | android:id="@+id/rcInventario" |
| 70 | android:layout_width="match_parent" | 58 | android:layout_width="match_parent" |
| 71 | android:layout_height="0dp" | 59 | android:layout_height="0dp" |
| 72 | android:background="@android:color/darker_gray" | 60 | android:background="@android:color/darker_gray" |
| 73 | android:scrollbars="vertical" | 61 | android:scrollbars="vertical" |
| 74 | android:visibility="gone" | 62 | android:visibility="gone" |
| 75 | app:layout_constraintEnd_toEndOf="parent" | 63 | app:layout_constraintEnd_toEndOf="parent" |
| 76 | app:layout_constraintStart_toStartOf="parent" | 64 | app:layout_constraintStart_toStartOf="parent" |
| 77 | app:layout_constraintTop_toBottomOf="@id/tvFecha" | 65 | app:layout_constraintTop_toBottomOf="@id/ivSort19" |
| 78 | tools:listitem="@layout/item_principal" /> | 66 | tools:listitem="@layout/item_principal" /> |
| 79 | 67 | ||
| 80 | <com.google.android.material.checkbox.MaterialCheckBox | 68 | <com.google.android.material.checkbox.MaterialCheckBox |
| 81 | android:id="@+id/cbVentas" | 69 | android:id="@+id/cbVentas" |
| 82 | android:layout_width="wrap_content" | 70 | android:layout_width="wrap_content" |
| 83 | android:layout_height="wrap_content" | 71 | android:layout_height="wrap_content" |
| 84 | android:layout_margin="5dp" | 72 | android:layout_margin="5dp" |
| 85 | android:text="Ventas" | 73 | android:text="Ventas" |
| 74 | android:checked="true" | ||
| 86 | android:visibility="gone" | 75 | android:visibility="gone" |
| 87 | app:layout_constraintEnd_toStartOf="@+id/cbDeposito" | 76 | app:layout_constraintEnd_toStartOf="@+id/cbDeposito" |
| 88 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> | 77 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
| 89 | 78 | ||
| 90 | <com.google.android.material.checkbox.MaterialCheckBox | 79 | <com.google.android.material.checkbox.MaterialCheckBox |
| 91 | android:id="@+id/cbDeposito" | 80 | android:id="@+id/cbDeposito" |
| 92 | android:layout_width="wrap_content" | 81 | android:layout_width="wrap_content" |
| 93 | android:layout_height="wrap_content" | 82 | android:layout_height="wrap_content" |
| 94 | android:layout_margin="5dp" | 83 | android:layout_margin="5dp" |
| 95 | android:visibility="gone" | 84 | android:visibility="gone" |
| 96 | android:text="Deposito" | 85 | android:text="Deposito" |
| 86 | android:checked="true" | ||
| 97 | app:layout_constraintEnd_toEndOf="parent" | 87 | app:layout_constraintEnd_toEndOf="parent" |
| 98 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> | 88 | app:layout_constraintTop_toBottomOf="@+id/tvInvDinamicos" /> |
| 99 | 89 | ||
| 100 | <androidx.appcompat.widget.AppCompatTextView | 90 | <androidx.appcompat.widget.AppCompatTextView |
| 101 | android:id="@+id/txtDeposito" | 91 | android:id="@+id/txtDeposito" |
| 102 | android:layout_width="match_parent" | 92 | android:layout_width="match_parent" |
| 103 | android:layout_height="90dp" | 93 | android:layout_height="90dp" |
| 104 | android:autoSizeMaxTextSize="150sp" | 94 | android:autoSizeMaxTextSize="150sp" |
| 105 | android:autoSizeMinTextSize="25sp" | 95 | android:autoSizeMinTextSize="25sp" |
| 106 | android:autoSizeStepGranularity="5sp" | 96 | android:autoSizeStepGranularity="5sp" |
| 107 | android:autoSizeTextType="uniform" | 97 | android:autoSizeTextType="uniform" |
| 108 | android:gravity="start" | 98 | android:gravity="start" |
| 109 | android:lines="1" | 99 | android:lines="1" |
| 110 | android:padding="10dp" | 100 | android:padding="10dp" |
| 111 | android:text="@string/invDinamicoCompra" | 101 | android:text="@string/invDinamicoCompra" |
| 112 | android:textColor="@color/colorAccent" | 102 | android:textColor="@color/colorAccent" |
| 113 | android:visibility="visible" | 103 | android:visibility="visible" |
| 114 | app:fontFamily="sans-serif-condensed" | 104 | app:fontFamily="sans-serif-condensed" |
| 115 | app:layout_constraintBottom_toBottomOf="parent" | 105 | app:layout_constraintBottom_toBottomOf="parent" |
| 116 | app:layout_constraintEnd_toEndOf="parent" | 106 | app:layout_constraintEnd_toEndOf="parent" |
gradle/wrapper/gradle-wrapper.properties
| 1 | #Thu Aug 13 18:28:21 ART 2020 | 1 | #Thu Aug 13 18:28:21 ART 2020 |
| 2 | distributionBase=GRADLE_USER_HOME | 2 | distributionBase=GRADLE_USER_HOME |
| 3 | distributionPath=wrapper/dists | 3 | distributionPath=wrapper/dists |
| 4 | zipStoreBase=GRADLE_USER_HOME | 4 | zipStoreBase=GRADLE_USER_HOME |
| 5 | zipStorePath=wrapper/dists | 5 | zipStorePath=wrapper/dists |
| 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip | 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
| 7 | |||
| 8 | # Enable Kapt Incremental annotation processing requeste | ||
| 9 | kapt.incremental.apt=true | ||
| 10 | |||
| 11 | # Enable android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC) | ||
| 12 | android.databinding.incremental=true | ||
| 13 | |||
| 14 | # Decrease gradle builds time | ||
| 15 | kapt.use.worker.api=true | ||
| 16 | |||
| 17 | # turn off AP discovery in compile path, and therefore turn on Compile Avoidance | ||
| 18 | kapt.include.compile.classpath=false | ||
| 19 | |||
| 20 | # Enable In Logcat to determine Kapt | ||
| 21 | kapt.verbose=true |