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
|
private val huskyApp: Application
|
||||||
) : UncaughtExceptionHandler {
|
) : UncaughtExceptionHandler {
|
||||||
|
|
||||||
|
private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
|
||||||
|
private var activityCounter = 0
|
||||||
|
private var lastActivity: Activity? = null
|
||||||
|
|
||||||
private val activityCallbacks = object : ActivityCallback() {
|
private val activityCallbacks = object : ActivityCallback() {
|
||||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||||
lastActivity = activity
|
lastActivity = activity
|
||||||
|
activityCounter++
|
||||||
Timber.d("onActivityCreated[${activity::class.simpleName}]")
|
Timber.d("onActivityCreated[${activity::class.simpleName}]")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResumed(activity: Activity) {
|
|
||||||
lastActivity = activity
|
|
||||||
Timber.d("onActivityResumed[${activity::class.simpleName}]")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityStopped(activity: Activity) {
|
override fun onActivityStopped(activity: Activity) {
|
||||||
lastActivity = null
|
activityCounter--
|
||||||
|
if(activityCounter <= 0) {
|
||||||
|
lastActivity = null
|
||||||
|
}
|
||||||
Timber.d("onActivityStopped[${activity::class.simpleName}]")
|
Timber.d("onActivityStopped[${activity::class.simpleName}]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
|
|
||||||
private var lastActivity: Activity? = null
|
|
||||||
|
|
||||||
override fun uncaughtException(thread: Thread, throwable: Throwable) {
|
override fun uncaughtException(thread: Thread, throwable: Throwable) {
|
||||||
try {
|
try {
|
||||||
sendLogEmail(throwable.stackTraceToString())
|
sendLogEmail(throwable.stackTraceToString())
|
||||||
|
|
Loading…
Reference in a new issue