Remove a possible race condition for nulls

This commit is contained in:
Adolfo Santiago 2022-06-25 11:34:54 +02:00
parent 508b63147f
commit d4a55dbdcf
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65

View file

@ -43,26 +43,26 @@ class CrashHandler @Inject constructor(
private val huskyApp: Application
) : UncaughtExceptionHandler {
private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
private var activityCounter = 0
private var lastActivity: Activity? = null
private val activityCallbacks = object : ActivityCallback() {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
lastActivity = activity
activityCounter++
Timber.d("onActivityCreated[${activity::class.simpleName}]")
}
override fun onActivityResumed(activity: Activity) {
lastActivity = activity
Timber.d("onActivityResumed[${activity::class.simpleName}]")
}
override fun onActivityStopped(activity: Activity) {
lastActivity = null
activityCounter--
if(activityCounter <= 0) {
lastActivity = null
}
Timber.d("onActivityStopped[${activity::class.simpleName}]")
}
}
private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
private var lastActivity: Activity? = null
override fun uncaughtException(thread: Thread, throwable: Throwable) {
try {
sendLogEmail(throwable.stackTraceToString())