1
0
mirror of https://github.com/etesync/android synced 2024-11-22 07:58:09 +00:00

Account list: workaround rare crash when listing accounts.

This commit is contained in:
Tom Hacohen 2019-05-05 17:45:44 +01:00
parent 2758821e5b
commit 58b54f9d66

View File

@ -77,8 +77,13 @@ class AccountListFragment : ListFragment(), LoaderManager.LoaderCallbacks<Array<
override fun onStartLoading() = override fun onStartLoading() =
accountManager.addOnAccountsUpdatedListener(this, null, true) accountManager.addOnAccountsUpdatedListener(this, null, true)
override fun onStopLoading() = override fun onStopLoading() {
try {
accountManager.removeOnAccountsUpdatedListener(this) accountManager.removeOnAccountsUpdatedListener(this)
} catch (e: IllegalArgumentException) {
// Do nothing. Just handle the case where for some reason the listener is not registered.
}
}
override fun onAccountsUpdated(accounts: Array<Account>) { override fun onAccountsUpdated(accounts: Array<Account>) {
forceLoad() forceLoad()