Search in sources :

Example 1 with AdvancedUserItem

use of com.nextcloud.talk.adapters.items.AdvancedUserItem in project talk-android by nextcloud.

the class SwitchAccountController method onViewBound.

@Override
protected void onViewBound(@NonNull View view) {
    super.onViewBound(view);
    NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
    swipeRefreshLayout.setEnabled(false);
    if (adapter == null) {
        adapter = new FlexibleAdapter<>(userItems, getActivity(), false);
        UserEntity userEntity;
        Participant participant;
        if (!isAccountImport) {
            for (Object userEntityObject : userUtils.getUsers()) {
                userEntity = (UserEntity) userEntityObject;
                if (!userEntity.getCurrent()) {
                    participant = new Participant();
                    participant.setName(userEntity.getDisplayName());
                    String userId;
                    if (userEntity.getUserId() != null) {
                        userId = userEntity.getUserId();
                    } else {
                        userId = userEntity.getUsername();
                    }
                    participant.setUserId(userId);
                    userItems.add(new AdvancedUserItem(participant, userEntity, null));
                }
            }
            adapter.addListener(onSwitchItemClickListener);
            adapter.updateDataSet(userItems, false);
        } else {
            if (getActionBar() != null) {
                getActionBar().show();
            }
            Account account;
            ImportAccount importAccount;
            for (Object accountObject : AccountUtils.findAccounts(userUtils.getUsers())) {
                account = (Account) accountObject;
                importAccount = AccountUtils.getInformationFromAccount(account);
                participant = new Participant();
                participant.setName(importAccount.getUsername());
                participant.setUserId(importAccount.getUsername());
                userEntity = new UserEntity();
                userEntity.setBaseUrl(importAccount.getBaseUrl());
                userItems.add(new AdvancedUserItem(participant, userEntity, account));
            }
            adapter.addListener(onImportItemClickListener);
            adapter.updateDataSet(userItems, false);
        }
    }
    prepareViews();
}
Also used : ImportAccount(com.nextcloud.talk.models.ImportAccount) Account(android.accounts.Account) Participant(com.nextcloud.talk.models.json.participants.Participant) ImportAccount(com.nextcloud.talk.models.ImportAccount) AdvancedUserItem(com.nextcloud.talk.adapters.items.AdvancedUserItem) UserEntity(com.nextcloud.talk.models.database.UserEntity)

Aggregations

Account (android.accounts.Account)1 AdvancedUserItem (com.nextcloud.talk.adapters.items.AdvancedUserItem)1 ImportAccount (com.nextcloud.talk.models.ImportAccount)1 UserEntity (com.nextcloud.talk.models.database.UserEntity)1 Participant (com.nextcloud.talk.models.json.participants.Participant)1