use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.
the class UserUtils method scheduleUserForDeletionWithId.
public boolean scheduleUserForDeletionWithId(long id) {
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.eq(id)).limit(1).get();
UserEntity userEntity;
if ((userEntity = (UserEntity) findUserQueryResult.firstOrNull()) != null) {
userEntity.setScheduledForDeletion(true);
userEntity.setCurrent(false);
dataStore.update(userEntity).blockingGet();
}
return getAnyUserAndSetAsActive() != null;
}
use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.
the class AccountUtils method findAccounts.
public static List<Account> findAccounts(List<UserEntity> userEntitiesList) {
Context context = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
final AccountManager accMgr = AccountManager.get(context);
final Account[] accounts = accMgr.getAccountsByType(context.getString(R.string.nc_import_account_type));
List<Account> accountsAvailable = new ArrayList<>();
ImportAccount importAccount;
UserEntity internalUserEntity;
boolean accountFound;
for (Account account : accounts) {
accountFound = false;
for (int i = 0; i < userEntitiesList.size(); i++) {
internalUserEntity = userEntitiesList.get(i);
importAccount = getInformationFromAccount(account);
if (importAccount.getBaseUrl().startsWith("http://") || importAccount.getBaseUrl().startsWith("https://")) {
if (internalUserEntity.getUsername().equals(importAccount.getUsername()) && internalUserEntity.getBaseUrl().equals(importAccount.getBaseUrl())) {
accountFound = true;
break;
}
} else {
if (internalUserEntity.getUsername().equals(importAccount.getUsername()) && (internalUserEntity.getBaseUrl().equals("http://" + importAccount.getBaseUrl()) || internalUserEntity.getBaseUrl().equals("https://" + importAccount.getBaseUrl()))) {
accountFound = true;
break;
}
}
}
if (!accountFound) {
accountsAvailable.add(account);
}
}
return accountsAvailable;
}
Aggregations