use of com.owncloud.android.ui.adapter.UserListItem in project android by nextcloud.
the class ManageAccountsActivity method run.
@Override
public void run(AccountManagerFuture<Boolean> future) {
if (future.isDone()) {
// after remove account
Account account = new Account(accountName, MainApp.getAccountType(this));
if (!accountManager.exists(account)) {
// Cancel transfers of the removed account
if (mUploaderBinder != null) {
mUploaderBinder.cancel(account);
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(account);
}
}
User user = getUserAccountManager().getUser();
if (user.isAnonymous()) {
String accountName = "";
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
if (accounts.length != 0) {
accountName = accounts[0].name;
}
accountManager.setCurrentOwnCloudAccount(accountName);
}
List<UserListItem> userListItemArray = getUserListItems();
if (userListItemArray.size() > SINGLE_ACCOUNT) {
userListAdapter = new UserListAdapter(this, accountManager, userListItemArray, this, multipleAccountsSupported, false);
recyclerView.setAdapter(userListAdapter);
} else {
onBackPressed();
}
}
}
use of com.owncloud.android.ui.adapter.UserListItem in project android by nextcloud.
the class ManageAccountsActivity method performAccountRemoval.
private void performAccountRemoval(User user) {
// disable account in recycler view
for (int i = 0; i < userListAdapter.getItemCount(); i++) {
UserListItem item = userListAdapter.getItem(i);
if (item != null && item.getUser().getAccountName().equalsIgnoreCase(user.getAccountName())) {
item.setEnabled(false);
break;
}
userListAdapter.notifyDataSetChanged();
}
// store pending account removal
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), PENDING_FOR_REMOVAL, String.valueOf(true));
// Cancel transfers
if (mUploaderBinder != null) {
mUploaderBinder.cancel(user.toPlatformAccount());
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(user.toPlatformAccount());
}
backgroundJobManager.startAccountRemovalJob(user.getAccountName(), false);
// immediately select a new account
List<User> users = accountManager.getAllUsers();
String newAccountName = "";
for (User u : users) {
if (!u.getAccountName().equalsIgnoreCase(u.getAccountName())) {
newAccountName = u.getAccountName();
break;
}
}
if (newAccountName.isEmpty()) {
Log_OC.d(TAG, "new account set to null");
accountManager.resetOwnCloudAccount();
} else {
Log_OC.d(TAG, "new account set to: " + newAccountName);
accountManager.setCurrentOwnCloudAccount(newAccountName);
}
// only one to be (deleted) account remaining
if (users.size() < MIN_MULTI_ACCOUNT_SIZE) {
Intent resultIntent = new Intent();
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, true);
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, true);
setResult(RESULT_OK, resultIntent);
super.onBackPressed();
}
}
use of com.owncloud.android.ui.adapter.UserListItem in project android by nextcloud.
the class MultipleAccountsDialog method getAccountListItems.
/**
* creates the account list items list including the add-account action in case
* multiaccount_support is enabled.
*
* @return list of account list items
*/
private List<UserListItem> getAccountListItems() {
List<User> users = accountManager.getAllUsers();
List<UserListItem> adapterUserList = new ArrayList<>(users.size());
for (User user : users) {
adapterUserList.add(new UserListItem(user));
}
return adapterUserList;
}
use of com.owncloud.android.ui.adapter.UserListItem in project android by nextcloud.
the class ManageAccountsActivity method getUserListItems.
private List<UserListItem> getUserListItems() {
List<User> users = accountManager.getAllUsers();
List<UserListItem> userListItems = new ArrayList<>(users.size());
for (User user : users) {
boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(user, PENDING_FOR_REMOVAL);
userListItems.add(new UserListItem(user, !pendingForRemoval));
}
if (getResources().getBoolean(R.bool.multiaccount_support)) {
userListItems.add(new UserListItem());
}
return userListItems;
}
Aggregations