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