Fix potential memory leak in ReviewHelper
There was a static reference to the currentActivity that was unnecessary
This commit is contained in:
parent
eb756e8525
commit
96e7b7c6b3
1 changed files with 0 additions and 4 deletions
|
@ -27,8 +27,6 @@ object ReviewHelper : Application.ActivityLifecycleCallbacks {
|
||||||
private lateinit var application: Application
|
private lateinit var application: Application
|
||||||
private lateinit var reviewManager: ReviewManager
|
private lateinit var reviewManager: ReviewManager
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private val errorHandler: ErrorHandler by errorHandlerImpl()
|
|
||||||
private var currentActivity: Activity? = null
|
|
||||||
private var activityCount = 0
|
private var activityCount = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = if (value < 0) {
|
field = if (value < 0) {
|
||||||
|
@ -60,7 +58,6 @@ object ReviewHelper : Application.ActivityLifecycleCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityStarted(activity: Activity) {
|
override fun onActivityStarted(activity: Activity) {
|
||||||
currentActivity = activity
|
|
||||||
if (activityCount++ == 0) {
|
if (activityCount++ == 0) {
|
||||||
activeTime = SystemClock.elapsedRealtime()
|
activeTime = SystemClock.elapsedRealtime()
|
||||||
}
|
}
|
||||||
|
@ -101,7 +98,6 @@ object ReviewHelper : Application.ActivityLifecycleCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityStopped(activity: Activity) {
|
override fun onActivityStopped(activity: Activity) {
|
||||||
currentActivity = null
|
|
||||||
if (--activityCount == 0) {
|
if (--activityCount == 0) {
|
||||||
sharedPreferences.edit {
|
sharedPreferences.edit {
|
||||||
putLong(KEY_TIME_IN_APP, SystemClock.elapsedRealtime() - activeTime)
|
putLong(KEY_TIME_IN_APP, SystemClock.elapsedRealtime() - activeTime)
|
||||||
|
|
Loading…
Reference in a new issue