feat loginApp #refs 6868
This commit is contained in:
parent
284d4509b1
commit
c34a52bde1
|
@ -38,9 +38,7 @@ import es.verdnatura.presentation.view.feature.login.adapter.WorkFormAdapter
|
||||||
import es.verdnatura.presentation.view.feature.login.model.WorkForms
|
import es.verdnatura.presentation.view.feature.login.model.WorkForms
|
||||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class LoginFragment(private var imageUri: Uri?) :
|
class LoginFragment(private var imageUri: Uri?) :
|
||||||
|
@ -71,6 +69,17 @@ class LoginFragment(private var imageUri: Uri?) :
|
||||||
password = binding.edittextPassword.text.toString()
|
password = binding.edittextPassword.text.toString()
|
||||||
|
|
||||||
)
|
)
|
||||||
|
//Tarea 6868
|
||||||
|
/* viewModel.loginApp(
|
||||||
|
LoginApp(
|
||||||
|
user = binding.edittextUsername.text.toString(),
|
||||||
|
password = binding.edittextPassword.text.toString(),
|
||||||
|
deviceId = getDevicePDA(),
|
||||||
|
androidId = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
|
||||||
|
versionApp = getInfoVersionNameApp(),
|
||||||
|
nameApp = getString(R.string.nameApp),
|
||||||
|
)
|
||||||
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mobileApplication.dataStoreApp.readDataStoreKey<String>(TOKEN)
|
if (mobileApplication.dataStoreApp.readDataStoreKey<String>(TOKEN)
|
||||||
|
@ -326,7 +335,7 @@ class LoginFragment(private var imageUri: Uri?) :
|
||||||
if (it.version == getInfoVersionNameApp()) {
|
if (it.version == getInfoVersionNameApp()) {
|
||||||
goToMain()
|
goToMain()
|
||||||
} else {
|
} else {
|
||||||
|
mobileApplication.clearApplicationData()
|
||||||
customDialog.setTitle(getString(R.string.Actualizar))
|
customDialog.setTitle(getString(R.string.Actualizar))
|
||||||
.setDescription(getString(R.string.updatemng)).setOkButton(
|
.setDescription(getString(R.string.updatemng)).setOkButton(
|
||||||
getString(
|
getString(
|
||||||
|
|
|
@ -20,6 +20,8 @@ import es.verdnatura.presentation.common.Event
|
||||||
import es.verdnatura.presentation.common.ResponseItemVO
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.DeviceLogSalix
|
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.DeviceLogSalix
|
||||||
import es.verdnatura.presentation.view.feature.login.model.DataUserSalix
|
import es.verdnatura.presentation.view.feature.login.model.DataUserSalix
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.LoginApp
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.LoginAppData
|
||||||
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
|
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
|
||||||
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
||||||
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
||||||
|
@ -33,10 +35,14 @@ import retrofit2.Response
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
private val _loginSalixItem by lazy { MutableLiveData<LoginSalixVO>() }
|
private val _loginSalixItem by lazy { MutableLiveData<LoginSalixVO>() }
|
||||||
val loginSalixItem: LiveData<LoginSalixVO>
|
val loginSalixItem: LiveData<LoginSalixVO>
|
||||||
get() = _loginSalixItem
|
get() = _loginSalixItem
|
||||||
|
|
||||||
|
private val _loginApp by lazy { MutableLiveData<LoginAppData>() }
|
||||||
|
val loginApp: LiveData<LoginAppData> = _loginApp
|
||||||
|
|
||||||
private val _devicelogresponse by lazy { MutableLiveData<ResponseItemVO>() }
|
private val _devicelogresponse by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
val devicelogresponse: LiveData<ResponseItemVO>
|
val devicelogresponse: LiveData<ResponseItemVO>
|
||||||
get() = _devicelogresponse
|
get() = _devicelogresponse
|
||||||
|
@ -117,6 +123,32 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun loginApp(
|
||||||
|
login: LoginApp,
|
||||||
|
|
||||||
|
) {
|
||||||
|
salix.loginApp(login)
|
||||||
|
.enqueue(object : SalixCallback<LoginAppData>(context) {
|
||||||
|
override fun onSuccess(response: Response<LoginAppData>) {
|
||||||
|
|
||||||
|
_loginApp.value = response.body()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(t: Throwable) {
|
||||||
|
/* val loginSalixVO = LoginAppData(
|
||||||
|
user,
|
||||||
|
password,
|
||||||
|
"",
|
||||||
|
isError = true,
|
||||||
|
errorMessage = getMessageFromAllResponse(
|
||||||
|
nameofFunction(this), t.message!!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_loginSalixItem.value = loginSalixVO*/
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun deviceCheckLogin(userId: Int, androidId: String) {
|
fun deviceCheckLogin(userId: Int, androidId: String) {
|
||||||
// FALTA EL USUARI
|
// FALTA EL USUARI
|
||||||
/* fun deviceCheckLogin(androidId: String) {
|
/* fun deviceCheckLogin(androidId: String) {
|
||||||
|
|
|
@ -9,6 +9,33 @@ class LoginSalixVO(
|
||||||
var isError: Boolean = false,
|
var isError: Boolean = false,
|
||||||
var errorMessage: String = ""
|
var errorMessage: String = ""
|
||||||
)
|
)
|
||||||
|
data class LoginApp(
|
||||||
|
val user: String ,
|
||||||
|
val password: String,
|
||||||
|
val deviceId: Int?,
|
||||||
|
val androidId:String,
|
||||||
|
val versionApp:String,
|
||||||
|
val nameApp:String
|
||||||
|
|
||||||
|
)
|
||||||
|
data class LoginAppData(
|
||||||
|
val id: Int,
|
||||||
|
val token: String,
|
||||||
|
val ttl: Long,
|
||||||
|
val numberOfWagons: Int,
|
||||||
|
var warehouseFk: Int,
|
||||||
|
val itemPackingTypeFk: String,
|
||||||
|
val printer: Printer,
|
||||||
|
val train: Train,
|
||||||
|
val sector: Sector,
|
||||||
|
val name: String,
|
||||||
|
val nickname: String,
|
||||||
|
val serialNumber: String,
|
||||||
|
val isVersionCritical: Boolean,
|
||||||
|
val version: String,
|
||||||
|
val vIsAuthorized: String,
|
||||||
|
val vMessage: String,
|
||||||
|
)
|
||||||
|
|
||||||
class DataUserSalix(
|
class DataUserSalix(
|
||||||
val id: Int? = null,
|
val id: Int? = null,
|
||||||
|
@ -38,6 +65,7 @@ class SalixGrupo(
|
||||||
val message: String = ""
|
val message: String = ""
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//Tarea 5870
|
//Tarea 5870
|
||||||
class OperatorSalix(
|
class OperatorSalix(
|
||||||
val sector: Sector? = null,
|
val sector: Sector? = null,
|
||||||
|
@ -48,11 +76,11 @@ class OperatorSalix(
|
||||||
val isError: Boolean = false,
|
val isError: Boolean = false,
|
||||||
var errorMessage: String = ""
|
var errorMessage: String = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Sector(val id: Int, val description: String, val warehouseFk: Int)
|
data class Sector(val id: Int, val description: String, val warehouseFk: Int)
|
||||||
data class Printer(val id: Int, val name: String)
|
data class Printer(val id: Int, val name: String)
|
||||||
data class Train(val id: Int, val name: String)
|
data class Train(val id: Int, val name: String)
|
||||||
|
|
||||||
|
|
||||||
class accessConfigSalix(
|
class accessConfigSalix(
|
||||||
val id: Number = 0,
|
val id: Number = 0,
|
||||||
val renewPeriod: Long = 0,
|
val renewPeriod: Long = 0,
|
||||||
|
|
Loading…
Reference in New Issue