fix ConcurrentModificationException when sorting accounts

main
Conny Duck 5 years ago
parent 2b466dc2e4
commit fea8426908
  1. 5
      app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt

@ -160,7 +160,8 @@ class AccountManager(db: AppDatabase) {
* @return an immutable list of all accounts in the database with the active account first
*/
fun getAllAccountsOrderedByActive(): List<AccountEntity> {
accounts.sortWith(Comparator { l, r ->
val accountsCopy = accounts.toMutableList()
accountsCopy.sortWith(Comparator { l, r ->
when {
l.isActive && !r.isActive -> -1
r.isActive && !l.isActive -> 1
@ -168,7 +169,7 @@ class AccountManager(db: AppDatabase) {
}
})
return accounts.toList()
return accountsCopy
}
/**

Loading…
Cancel
Save