From 8240d7ff1040f317ee419d9173636139084e7645 Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 13 Apr 2011 03:44:43 +0200 Subject: [PATCH] Always reload all accounts after importing one or more accounts --- src/com/fsck/k9/Preferences.java | 23 ++++--------------- .../fsck/k9/preferences/StorageImporter.java | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/com/fsck/k9/Preferences.java b/src/com/fsck/k9/Preferences.java index 6ee07f538..462d37e63 100644 --- a/src/com/fsck/k9/Preferences.java +++ b/src/com/fsck/k9/Preferences.java @@ -49,36 +49,23 @@ public class Preferences { } } - private synchronized void loadAccounts() { + public synchronized void loadAccounts() { accounts = new HashMap(); - refreshAccounts(); - } - - public synchronized void refreshAccounts() { - Map newAccountMap = new HashMap(); accountsInOrder = new LinkedList(); String accountUuids = getPreferences().getString("accountUuids", null); if ((accountUuids != null) && (accountUuids.length() != 0)) { String[] uuids = accountUuids.split(","); for (String uuid : uuids) { - Account account = accounts.get(uuid); - if (account != null) { - newAccountMap.put(uuid, account); - accountsInOrder.add(account); - } else { - Account newAccount = new Account(this, uuid); - newAccountMap.put(uuid, newAccount); - accountsInOrder.add(newAccount); - } + Account newAccount = new Account(this, uuid); + accounts.put(uuid, newAccount); + accountsInOrder.add(newAccount); } } if ((newAccount != null) && newAccount.getAccountNumber() != -1) { - newAccountMap.put(newAccount.getUuid(), newAccount); + accounts.put(newAccount.getUuid(), newAccount); accountsInOrder.add(newAccount); newAccount = null; } - - accounts = newAccountMap; } /** diff --git a/src/com/fsck/k9/preferences/StorageImporter.java b/src/com/fsck/k9/preferences/StorageImporter.java index 47f15fa08..8f7412cc1 100644 --- a/src/com/fsck/k9/preferences/StorageImporter.java +++ b/src/com/fsck/k9/preferences/StorageImporter.java @@ -178,7 +178,7 @@ public class StorageImporter { throw new StorageImportExportException("Couldn't save imported settings"); } - preferences.refreshAccounts(); + preferences.loadAccounts(); DateFormatter.clearChosenFormat(); K9.loadPrefs(preferences); K9.setServicesEnabled(context);