From 0f39ad0f04a47180a95d5800cf813d344603339d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 28 Aug 2017 18:30:39 +0200 Subject: [PATCH] make filtered list item activity survive roations --- .../ui/AbstractSearchableListItemActivity.java | 7 ++++++- .../eu/siacs/conversations/ui/ChooseContactActivity.java | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java index 1a9fc95c2..8d6f093d7 100644 --- a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java @@ -112,7 +112,12 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity { } protected void filterContacts() { - filterContacts(null); + final String needle = mSearchEditText != null ? mSearchEditText.getText().toString() : null; + if (needle != null && !needle.isEmpty()) { + filterContacts(needle); + } else { + filterContacts(null); + } } protected abstract void filterContacts(final String needle); diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index 199936e14..53f628ec0 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -161,6 +161,10 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity { protected void filterContacts(final String needle) { getListItems().clear(); + if (xmppConnectionService == null) { + getListItemAdapter().notifyDataSetChanged(); + return; + } for (final Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED) { for (final Contact contact : account.getRoster().getContacts()) { @@ -230,7 +234,6 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity { @Override void onBackendConnected() { filterContacts(); - this.mActivatedAccounts.clear(); for (Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED) {