refs ##5613 login
This commit is contained in:
parent
1771608eff
commit
a8071581a0
|
@ -13,8 +13,8 @@ android {
|
|||
applicationId "es.verdnatura"
|
||||
minSdkVersion 24 //21
|
||||
targetSdkVersion 33
|
||||
versionCode 214
|
||||
versionName = "23.28Beta" //Esta rama viene de esta version
|
||||
versionCode 217
|
||||
versionName = "23.28" //Esta rama viene de esta version
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package es.verdnatura.domain
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
|
@ -35,10 +35,14 @@ abstract class SilexCallback<T>(val context: Context) : Callback<T> {
|
|||
var message = JSONObject(response.message()).getString("Message")
|
||||
onError(Error(message))
|
||||
} else if (response.code() == 401) {
|
||||
val intent = Intent(context, LoginActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
exitProcess(0)
|
||||
if (!isActivityRunning(context, LoginActivity::class.java)) {
|
||||
val intent = Intent(context, LoginActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
exitProcess(0)
|
||||
} else {
|
||||
onError(Error(response.message().toString()))
|
||||
}
|
||||
} else {
|
||||
onError(Error(response.message().toString()))
|
||||
}
|
||||
|
@ -70,5 +74,18 @@ abstract class SilexCallback<T>(val context: Context) : Callback<T> {
|
|||
throw t
|
||||
}
|
||||
|
||||
fun isActivityRunning(context: Context, activityClass: Class<*>): Boolean {
|
||||
val packageName = context.packageName
|
||||
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val runningActivities = activityManager.getRunningTasks(Int.MAX_VALUE)
|
||||
|
||||
for (taskInfo in runningActivities) {
|
||||
if (taskInfo.baseActivity?.className == activityClass.name && taskInfo.topActivity?.packageName == packageName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
|
@ -95,6 +95,7 @@ class LoginFragment(var imageUri: Uri?) :
|
|||
//deleteWorkForm("all")
|
||||
listForms = getWorkForm().sortedBy { it.created }
|
||||
|
||||
|
||||
binding.edittextServer.keyListener = null
|
||||
binding.edittextServer.setOnLongClickListener {
|
||||
showWorkingForms()
|
||||
|
@ -526,8 +527,8 @@ class LoginFragment(var imageUri: Uri?) :
|
|||
|
||||
} else {
|
||||
if (!it.list[0].isError) {
|
||||
app.renewPeriod = it.list[0].renewPeriod!!
|
||||
app.renewInterval = it.list[0].renewInterval!!
|
||||
/* app.renewPeriod = it.list[0].renewPeriod!!
|
||||
app.renewInterval = it.list[0].renewInterval!!*/
|
||||
saveDataLong("renewPeriod", it.list[0].renewPeriod!!)
|
||||
saveDataLong("renewInterval", it.list[0].renewInterval)
|
||||
viewModel.operator_add()
|
||||
|
|
Loading…
Reference in New Issue