private boolean removeAccountInternal(int userId, Account account) { List<VAccount> accounts = accountsByUserId.get(userId); if (accounts != null) { Iterator<VAccount> iterator = accounts.iterator(); while (iterator.hasNext()) { VAccount vAccount = iterator.next(); if (userId == vAccount.userId && TextUtils.equals(vAccount.name, account.name) && TextUtils.equals(account.type, vAccount.type)) { iterator.remove(); saveAllAccounts(); sendAccountsChangedBroadcast(userId); return true; } } } return false; }
private void setPasswordInternal(int userId, Account account, String password) { synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.password = password; vAccount.authTokens.clear(); saveAllAccounts(); synchronized (authTokenRecords) { Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator(); while (iterator.hasNext()) { AuthTokenRecord record = iterator.next(); if (record.userId == userId && record.account.equals(account)) { iterator.remove(); } } } sendAccountsChangedBroadcast(userId); } } }
private boolean insertAccountIntoDatabase(int userId, Account account, String password, Bundle extras) { if (account == null) { return false; } synchronized (accountsByUserId) { VAccount vAccount = new VAccount(userId, account); vAccount.password = password; // convert the [Bundle] to [Map<String, String>] if (extras != null) { for (String key : extras.keySet()) { Object value = extras.get(key); if (value instanceof String) { vAccount.userDatas.put(key, (String) value); } } } List<VAccount> accounts = accountsByUserId.get(userId); if (accounts == null) { accounts = new ArrayList<>(); accountsByUserId.put(userId, accounts); } accounts.add(vAccount); saveAllAccounts(); sendAccountsChangedBroadcast(vAccount.userId); return true; } }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
private boolean removeAccountInternal(int userId, Account account) { List<VAccount> accounts = accountsByUserId.get(userId); if (accounts != null) { Iterator<VAccount> iterator = accounts.iterator(); while (iterator.hasNext()) { VAccount vAccount = iterator.next(); if (userId == vAccount.userId && TextUtils.equals(vAccount.name, account.name) && TextUtils.equals(account.type, vAccount.type)) { iterator.remove(); saveAllAccounts(); sendAccountsChangedBroadcast(userId); return true; } } } return false; }
private boolean removeAccountInternal(int userId, Account account) { List<VAccount> accounts = accountsByUserId.get(userId); if (accounts != null) { Iterator<VAccount> iterator = accounts.iterator(); while (iterator.hasNext()) { VAccount vAccount = iterator.next(); if (userId == vAccount.userId && TextUtils.equals(vAccount.name, account.name) && TextUtils.equals(account.type, vAccount.type)) { iterator.remove(); saveAllAccounts(); sendAccountsChangedBroadcast(userId); return true; } } } return false; }
private void setPasswordInternal(int userId, Account account, String password) { synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.password = password; vAccount.authTokens.clear(); saveAllAccounts(); synchronized (authTokenRecords) { Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator(); while (iterator.hasNext()) { AuthTokenRecord record = iterator.next(); if (record.userId == userId && record.account.equals(account)) { iterator.remove(); } } } sendAccountsChangedBroadcast(userId); } } }
private void setPasswordInternal(int userId, Account account, String password) { synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.password = password; vAccount.authTokens.clear(); saveAllAccounts(); synchronized (authTokenRecords) { Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator(); while (iterator.hasNext()) { AuthTokenRecord record = iterator.next(); if (record.userId == userId && record.account.equals(account)) { iterator.remove(); } } } sendAccountsChangedBroadcast(userId); } } }
private boolean insertAccountIntoDatabase(int userId, Account account, String password, Bundle extras) { if (account == null) { return false; } synchronized (accountsByUserId) { VAccount vAccount = new VAccount(userId, account); vAccount.password = password; // convert the [Bundle] to [Map<String, String>] if (extras != null) { for (String key : extras.keySet()) { Object value = extras.get(key); if (value instanceof String) { vAccount.userDatas.put(key, (String) value); } } } List<VAccount> accounts = accountsByUserId.get(userId); if (accounts == null) { accounts = new ArrayList<>(); accountsByUserId.put(userId, accounts); } accounts.add(vAccount); saveAllAccounts(); sendAccountsChangedBroadcast(vAccount.userId); return true; } }
private boolean insertAccountIntoDatabase(int userId, Account account, String password, Bundle extras) { if (account == null) { return false; } synchronized (accountsByUserId) { VAccount vAccount = new VAccount(userId, account); vAccount.password = password; // convert the [Bundle] to [Map<String, String>] if (extras != null) { for (String key : extras.keySet()) { Object value = extras.get(key); if (value instanceof String) { vAccount.userDatas.put(key, (String) value); } } } List<VAccount> accounts = accountsByUserId.get(userId); if (accounts == null) { accounts = new ArrayList<>(); accountsByUserId.put(userId, accounts); } accounts.add(vAccount); saveAllAccounts(); sendAccountsChangedBroadcast(vAccount.userId); return true; } }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }