Remove a possible race condition for nulls
This commit is contained in:
parent
508b63147f
commit
d4a55dbdcf
1 changed files with 9 additions and 9 deletions
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue