use of com.owncloud.android.ui.adapter.AccountListAdapter in project android by nextcloud.
the class ManageAccountsActivity method createAccount.
@Override
public void createAccount() {
AccountManager am = AccountManager.get(getApplicationContext());
am.addAccount(MainApp.getAccountType(), null, null, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
if (future != null) {
try {
Bundle result = future.getResult();
String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), name);
mAccountListAdapter = new AccountListAdapter(ManageAccountsActivity.this, getAccountListItems(), mTintedCheck);
mListView.setAdapter(mAccountListAdapter);
runOnUiThread(new Runnable() {
@Override
public void run() {
mAccountListAdapter.notifyDataSetChanged();
}
});
} catch (OperationCanceledException e) {
Log_OC.d(TAG, "Account creation canceled");
} catch (Exception e) {
Log_OC.e(TAG, "Account creation finished in exception: ", e);
}
}
}
}, mHandler);
}
use of com.owncloud.android.ui.adapter.AccountListAdapter in project android by owncloud.
the class ManageAccountsActivity method createAccount.
@Override
public void createAccount() {
AccountManager am = AccountManager.get(getApplicationContext());
am.addAccount(MainApp.Companion.getAccountType(), null, null, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
if (future != null) {
try {
Bundle result = future.getResult();
String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), name);
mAccountListAdapter = new AccountListAdapter(ManageAccountsActivity.this, getAccountListItems(), mTintedCheck);
mListView.setAdapter(mAccountListAdapter);
runOnUiThread(new Runnable() {
@Override
public void run() {
mAccountListAdapter.notifyDataSetChanged();
}
});
} catch (OperationCanceledException e) {
Timber.e(e, "Account creation canceled");
} catch (Exception e) {
Timber.e(e, "Account creation finished in exception");
}
}
}
}, mHandler);
}
use of com.owncloud.android.ui.adapter.AccountListAdapter in project android by owncloud.
the class ManageAccountsActivity method run.
/**
* Callback executed after the {@link AccountManager} removed an account
*
* @param future Result of the removal; future.getResult() is true if account was removed correctly.
*/
@Override
public void run(AccountManagerFuture<Boolean> future) {
if (future != null && future.isDone()) {
Account account = new Account(mAccountBeingRemoved, MainApp.Companion.getAccountType());
if (!AccountUtils.exists(account.name, MainApp.Companion.getAppContext())) {
// Cancel transfers of the removed account
if (mUploaderBinder != null) {
mUploaderBinder.cancel(account);
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(account);
}
CancelUploadFromAccountUseCase cancelUploadFromAccountUseCase = new CancelUploadFromAccountUseCase(WorkManager.getInstance(getBaseContext()));
cancelUploadFromAccountUseCase.execute(new CancelUploadFromAccountUseCase.Params(account.name));
}
mAccountListAdapter = new AccountListAdapter(this, getAccountListItems(), mTintedCheck);
mListView.setAdapter(mAccountListAdapter);
AccountManager am = AccountManager.get(this);
if (am.getAccountsByType(MainApp.Companion.getAccountType()).length == 0) {
// Show create account screen if there isn't any account
am.addAccount(MainApp.Companion.getAccountType(), null, null, null, this, null, null);
} else {
// at least one account left
if (AccountUtils.getCurrentOwnCloudAccount(this) == null) {
// current account was removed - set another as current
String accountName = "";
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.Companion.getAccountType());
if (accounts.length != 0) {
accountName = accounts[0].name;
}
AccountUtils.setCurrentOwnCloudAccount(this, accountName);
}
}
}
}
use of com.owncloud.android.ui.adapter.AccountListAdapter in project android by owncloud.
the class ManageAccountsActivity method onStart.
@Override
protected void onStart() {
super.onStart();
mAccountListAdapter = new AccountListAdapter(this, getAccountListItems(), mTintedCheck);
mListView.setAdapter(mAccountListAdapter);
}
Aggregations