use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.
the class ManageAccountsActivity method startAccountCreation.
@Override
public void startAccountCreation() {
AccountManager am = AccountManager.get(getApplicationContext());
am.addAccount(MainApp.getAccountType(this), null, null, null, this, future -> {
if (future != null) {
try {
Bundle result = future.getResult();
String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
accountManager.setCurrentOwnCloudAccount(name);
userListAdapter = new UserListAdapter(this, accountManager, getUserListItems(), this, multipleAccountsSupported, false);
recyclerView.setAdapter(userListAdapter);
runOnUiThread(() -> userListAdapter.notifyDataSetChanged());
} catch (OperationCanceledException e) {
Log_OC.d(TAG, "Account creation canceled");
} catch (Exception e) {
Log_OC.e(TAG, "Account creation finished in exception: ", e);
}
}
}, handler);
}
use of com.owncloud.android.ui.adapter.UserListAdapter 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.UserListAdapter in project android by nextcloud.
the class FileDetailFragment method updateListOfUserGroups.
private void updateListOfUserGroups() {
// Update list of users/groups
// TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
UserListAdapter mUserGroupsAdapter = new UserListAdapter(getActivity().getApplicationContext(), R.layout.share_user_item, mShares);
// Show data
ListView usersList = getView().findViewById(R.id.fdshareUsersList);
// No data
TextView noList = getView().findViewById(R.id.fdShareNoUsers);
if (mShares.size() > 0) {
usersList.setVisibility(View.VISIBLE);
usersList.setAdapter(mUserGroupsAdapter);
noList.setVisibility(View.GONE);
setListViewHeightBasedOnChildren(usersList);
} else {
usersList.setVisibility(View.GONE);
noList.setVisibility(View.VISIBLE);
}
}
use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.
the class ManageAccountsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accounts_layout);
recyclerView = findViewById(R.id.account_list);
setupToolbar();
// set the back button from action bar
ActionBar actionBar = getSupportActionBar();
// check if is not null
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
// set title Action bar
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.prefs_manage_accounts));
ThemeToolbarUtils.tintBackButton(actionBar, this);
List<User> users = accountManager.getAllUsers();
originalUsers = toAccountNames(users);
Optional<User> currentUser = getUser();
if (currentUser.isPresent()) {
originalCurrentUser = currentUser.get().getAccountName();
}
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
multipleAccountsSupported = getResources().getBoolean(R.bool.multiaccount_support);
userListAdapter = new UserListAdapter(this, accountManager, getUserListItems(), this, multipleAccountsSupported, true);
recyclerView.setAdapter(userListAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
initializeComponentGetters();
}
use of com.owncloud.android.ui.adapter.UserListAdapter in project android by nextcloud.
the class MultipleAccountsDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Activity activity = getActivity();
if (activity == null) {
throw new IllegalArgumentException("Activity may not be null");
}
// Inflate the layout for the dialog
LayoutInflater inflater = activity.getLayoutInflater();
MultipleAccountsBinding binding = MultipleAccountsBinding.inflate(inflater, null, false);
final ReceiveExternalFilesActivity parent = (ReceiveExternalFilesActivity) getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(parent);
UserListAdapter adapter = new UserListAdapter(parent, accountManager, getAccountListItems(), this, false, false);
binding.list.setHasFixedSize(true);
binding.list.setLayoutManager(new LinearLayoutManager(activity));
binding.list.setAdapter(adapter);
builder.setView(binding.getRoot()).setTitle(R.string.common_choose_account);
Dialog dialog = builder.create();
Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
return dialog;
}
Aggregations