/**
* This method should be called only from Singletons so the lifecycle
* is tied with the application, so we don't have to cleanup the listeners
*
* @param callback to be called on accounts updated
*/
public void addOnAccountsUpdatedListener(OnAccountsUpdatedListener callback) {
try {
OnAccountsUpdateListener listener = accounts -> {
Set<MovirtAccount> filtered = new HashSet<>();
for (Account account : accounts) {
if (Constants.ACCOUNT_TYPE.equals(account.type)) {
try {
filtered.add(asMoAccount(account));
} catch (IllegalStateException incompatibleAccount) {
removeAccount(new MovirtAccount("", account), null); // remove old account
}
}
}
callback.onAccountsUpdated(filtered);
};
accountManager.addOnAccountsUpdatedListener(listener, null, true);
} catch (SecurityException e) {
commonMessageHelper.showError(ErrorType.NORMAL, resources.getMissingAccountsPermissionError());
}
}
AccountManagerHelper.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:moVirt
作者:
评论列表
文章目录