Search in sources :

Example 1 with ManageAccountActivity

use of eu.siacs.conversations.ui.ManageAccountActivity in project Conversations by siacs.

the class AccountAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    final Account account = getItem(position);
    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.account_row, parent, false);
    }
    TextView jid = (TextView) view.findViewById(R.id.account_jid);
    if (Config.DOMAIN_LOCK != null) {
        jid.setText(account.getJid().getLocalpart());
    } else {
        jid.setText(account.getJid().toBareJid().toString());
    }
    TextView statusView = (TextView) view.findViewById(R.id.account_status);
    ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
    loadAvatar(account, imageView);
    statusView.setText(getContext().getString(account.getStatus().getReadableId()));
    switch(account.getStatus()) {
        case ONLINE:
            statusView.setTextColor(activity.getOnlineColor());
            break;
        case DISABLED:
        case CONNECTING:
            statusView.setTextColor(activity.getSecondaryTextColor());
            break;
        default:
            statusView.setTextColor(activity.getWarningTextColor());
            break;
    }
    final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status);
    final boolean isDisabled = (account.getStatus() == Account.State.DISABLED);
    tglAccountState.setChecked(!isDisabled, false);
    tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == isDisabled && activity instanceof ManageAccountActivity) {
                ((ManageAccountActivity) activity).onClickTglAccountState(account, b);
            }
        }
    });
    return view;
}
Also used : Account(eu.siacs.conversations.entities.Account) Switch(eu.siacs.conversations.ui.widget.Switch) LayoutInflater(android.view.LayoutInflater) ManageAccountActivity(eu.siacs.conversations.ui.ManageAccountActivity) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Account (eu.siacs.conversations.entities.Account)1 ManageAccountActivity (eu.siacs.conversations.ui.ManageAccountActivity)1 Switch (eu.siacs.conversations.ui.widget.Switch)1