fixed some memory leaks, close #744

This commit is contained in:
Mariotaku Lee 2017-04-04 11:42:45 +08:00
parent 952dddba03
commit ab96713b8e
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 3 additions and 3 deletions

View File

@ -611,7 +611,6 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
context: Context,
val firsSyncLoad: Boolean
) : FixedAsyncTaskLoader<AccountsInfo>(context) {
private val am = AccountManager.get(context)
private var contentObserver: ContentObserver? = null
set(value) {
@ -624,6 +623,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
}
private var accountListener: OnAccountsUpdateListener? = null
set(value) {
val am = AccountManager.get(context)
field?.let {
am.removeOnAccountsUpdatedListenerSafe(it)
}

View File

@ -18,10 +18,9 @@ class AccountDetailsLoader(
val filter: (AccountDetails.() -> Boolean)? = null
) : FixedAsyncTaskLoader<List<AccountDetails>>(context) {
private val am: AccountManager = AccountManager.get(context)
private var accountUpdateListener: OnAccountsUpdateListener? = null
set(value) {
val am: AccountManager = AccountManager.get(context)
field?.let {
am.removeOnAccountsUpdatedListenerSafe(it)
}
@ -31,6 +30,7 @@ class AccountDetailsLoader(
}
override fun loadInBackground(): List<AccountDetails> {
val am: AccountManager = AccountManager.get(context)
return AccountUtils.getAllAccountDetails(am, true).filter {
filter?.invoke(it) ?: true
}.sortedBy(AccountDetails::position)