mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Refactor code to remove remote store references when deleting accounts
This commit is contained in:
parent
231367b448
commit
01336944ec
@ -12,7 +12,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.Store;
|
||||||
import com.fsck.k9.preferences.Editor;
|
import com.fsck.k9.preferences.Editor;
|
||||||
import com.fsck.k9.preferences.Storage;
|
import com.fsck.k9.preferences.Storage;
|
||||||
|
|
||||||
@ -126,11 +126,9 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
account.getRemoteStore().resetRemoteStore(account);
|
Store.removeRemoteInstance(account);
|
||||||
} catch (MessagingException e) {
|
} catch (Exception e) {
|
||||||
Log.e(K9.LOG_TAG, "Failed to reset remote store for account "
|
Log.e(K9.LOG_TAG, "Failed to reset remote store for account " + account.getUuid(), e);
|
||||||
+ account.getUuid());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
account.delete(this);
|
account.delete(this);
|
||||||
|
@ -111,6 +111,23 @@ public abstract class Store {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release reference to a remote mail store instance.
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* {@link Account} instance that is used to get the remote mail store instance.
|
||||||
|
*/
|
||||||
|
public synchronized static void removeRemoteInstance(Account account) {
|
||||||
|
String uri = account.getStoreUri();
|
||||||
|
|
||||||
|
if (uri.startsWith("local")) {
|
||||||
|
throw new RuntimeException("Asked to get non-local Store object but given " +
|
||||||
|
"LocalStore URI");
|
||||||
|
}
|
||||||
|
|
||||||
|
sStores.remove(uri);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes the contents of store-specific URIs and puts them into a {@link ServerSettings}
|
* Decodes the contents of store-specific URIs and puts them into a {@link ServerSettings}
|
||||||
* object.
|
* object.
|
||||||
@ -208,14 +225,4 @@ public abstract class Store {
|
|||||||
public Account getAccount() {
|
public Account getAccount() {
|
||||||
return mAccount;
|
return mAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetRemoteStore(Account account) {
|
|
||||||
String uri = account.getStoreUri();
|
|
||||||
if (uri.startsWith("local")) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Asked to get non-local Store object but given LocalStore URI");
|
|
||||||
}
|
|
||||||
sStores.remove(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user