mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-26 01:28:50 -05:00
Added code to only return newly created Account objects once they have been saved to the database (or are requested by UUID). This will allow the account creation process to be aborted without the application crashing (see issue 1375).
I don't particularly like this fix and hope to find a more elegant solution to this problem. Kind of fixes issue 1375
This commit is contained in:
parent
f911b0e436
commit
0a4577c930
@ -32,6 +32,7 @@ public class Preferences
|
|||||||
|
|
||||||
private Storage mStorage;
|
private Storage mStorage;
|
||||||
private List<Account> accounts;
|
private List<Account> accounts;
|
||||||
|
private Account newAccount;
|
||||||
|
|
||||||
private Preferences(Context context)
|
private Preferences(Context context)
|
||||||
{
|
{
|
||||||
@ -74,6 +75,12 @@ public class Preferences
|
|||||||
loadAccounts();
|
loadAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((newAccount != null) && newAccount.getAccountNumber() != -1)
|
||||||
|
{
|
||||||
|
accounts.add(newAccount);
|
||||||
|
newAccount = null;
|
||||||
|
}
|
||||||
|
|
||||||
return accounts.toArray(new Account[0]);
|
return accounts.toArray(new Account[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,21 +99,30 @@ public class Preferences
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((newAccount != null) && newAccount.getUuid().equals(uuid))
|
||||||
|
{
|
||||||
|
return newAccount;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Account newAccount()
|
public synchronized Account newAccount()
|
||||||
{
|
{
|
||||||
Account account = new Account(K9.app);
|
newAccount = new Account(K9.app);
|
||||||
accounts.add(account);
|
|
||||||
|
|
||||||
return account;
|
return newAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void deleteAccount(Account account)
|
public synchronized void deleteAccount(Account account)
|
||||||
{
|
{
|
||||||
accounts.remove(account);
|
accounts.remove(account);
|
||||||
account.delete(this);
|
account.delete(this);
|
||||||
|
|
||||||
|
if (newAccount == account)
|
||||||
|
{
|
||||||
|
newAccount = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user