make filtered list item activity survive roations

This commit is contained in:
Daniel Gultsch 2017-08-28 18:30:39 +02:00
parent ccb47c5727
commit 0f39ad0f04
2 changed files with 10 additions and 2 deletions

View file

@ -112,8 +112,13 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity {
} }
protected void filterContacts() { protected void filterContacts() {
final String needle = mSearchEditText != null ? mSearchEditText.getText().toString() : null;
if (needle != null && !needle.isEmpty()) {
filterContacts(needle);
} else {
filterContacts(null); filterContacts(null);
} }
}
protected abstract void filterContacts(final String needle); protected abstract void filterContacts(final String needle);

View file

@ -161,6 +161,10 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
protected void filterContacts(final String needle) { protected void filterContacts(final String needle) {
getListItems().clear(); getListItems().clear();
if (xmppConnectionService == null) {
getListItemAdapter().notifyDataSetChanged();
return;
}
for (final Account account : xmppConnectionService.getAccounts()) { for (final Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) { if (account.getStatus() != Account.State.DISABLED) {
for (final Contact contact : account.getRoster().getContacts()) { for (final Contact contact : account.getRoster().getContacts()) {
@ -230,7 +234,6 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
@Override @Override
void onBackendConnected() { void onBackendConnected() {
filterContacts(); filterContacts();
this.mActivatedAccounts.clear(); this.mActivatedAccounts.clear();
for (Account account : xmppConnectionService.getAccounts()) { for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) { if (account.getStatus() != Account.State.DISABLED) {