From 03e6a9b81c6f53a941a02de7d52788c191d1cce8 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 18 Jun 2024 12:47:12 +0200 Subject: [PATCH] clear data app --- .../java/es/verdnatura/MobileApplication.kt | 31 +++++++++++++++++++ .../presentation/common/ResponseItemVO.kt | 7 ----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/es/verdnatura/MobileApplication.kt b/app/src/main/java/es/verdnatura/MobileApplication.kt index ddb6eac9..11220466 100644 --- a/app/src/main/java/es/verdnatura/MobileApplication.kt +++ b/app/src/main/java/es/verdnatura/MobileApplication.kt @@ -20,6 +20,7 @@ import kotlinx.coroutines.runBlocking import org.koin.android.ext.koin.androidContext import org.koin.core.context.loadKoinModules import org.koin.core.context.startKoin +import java.io.File class MobileApplication : Application(), InteceptorListener { private lateinit var interceptoreListener: InteceptorListener @@ -119,4 +120,34 @@ class MobileApplication : Application(), InteceptorListener { val settings = this.resources.configuration return settings.locales.get(0).language } + fun clearApplicationData() { + try { + val cacheDir = this.cacheDir + val appDir = File(cacheDir.parent ?: return) + if (appDir.exists()) { + val children = appDir.list() ?: return + for (child in children) { + if (child != "lib") { + deleteDir(File(appDir, child)) + } + } + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + private fun deleteDir(dir: File): Boolean { + if (dir.isDirectory) { + val children = dir.list() ?: return false + for (child in children) { + val success = deleteDir(File(dir, child)) + if (!success) { + return false + } + } + } + return dir.delete() + } + } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/common/ResponseItemVO.kt b/app/src/main/java/es/verdnatura/presentation/common/ResponseItemVO.kt index 2305ff9b..0fe68250 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/ResponseItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/ResponseItemVO.kt @@ -38,13 +38,6 @@ class ResponseItemMachineControl( var type: String ) -class DataMessageSalix( - var ticket: Int, - var item: String = "", - var quantity: String = "", - var personSale: String = "" - -) class GeneralItem( var code: String? = "",