From 1fbec382597eb9721b79aa5e801fce3a503c1d1f Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Mon, 4 Sep 2017 21:04:07 +0200 Subject: make filtered list item activity survive roations --- .../de/pixart/messenger/ui/AbstractSearchableListItemActivity.java | 7 ++++++- src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java b/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java index 768e738ba..df0708f7e 100644 --- a/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java +++ b/src/main/java/de/pixart/messenger/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/de/pixart/messenger/ui/ChooseContactActivity.java b/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java index 86f7902c9..9d51a1c1d 100644 --- a/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java +++ b/src/main/java/de/pixart/messenger/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()) { -- cgit v1.2.3