AccountAdapter: Allow hiding of state button
This commit is contained in:
parent
b8b7cc2635
commit
a7927d181b
|
@ -29,10 +29,18 @@ import eu.siacs.conversations.utils.UIHelper;
|
||||||
public class AccountAdapter extends ArrayAdapter<Account> {
|
public class AccountAdapter extends ArrayAdapter<Account> {
|
||||||
|
|
||||||
private XmppActivity activity;
|
private XmppActivity activity;
|
||||||
|
private boolean showStateButton;
|
||||||
|
|
||||||
|
public AccountAdapter(XmppActivity activity, List<Account> objects, boolean showStateButton) {
|
||||||
|
super(activity, 0, objects);
|
||||||
|
this.activity = activity;
|
||||||
|
this.showStateButton = showStateButton;
|
||||||
|
}
|
||||||
|
|
||||||
public AccountAdapter(XmppActivity activity, List<Account> objects) {
|
public AccountAdapter(XmppActivity activity, List<Account> objects) {
|
||||||
super(activity, 0, objects);
|
super(activity, 0, objects);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
this.showStateButton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,6 +76,11 @@ public class AccountAdapter extends ArrayAdapter<Account> {
|
||||||
final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status);
|
final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status);
|
||||||
final boolean isDisabled = (account.getStatus() == Account.State.DISABLED);
|
final boolean isDisabled = (account.getStatus() == Account.State.DISABLED);
|
||||||
tglAccountState.setChecked(!isDisabled,false);
|
tglAccountState.setChecked(!isDisabled,false);
|
||||||
|
if (this.showStateButton) {
|
||||||
|
tglAccountState.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
tglAccountState.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
|
Loading…
Reference in a new issue