From 3c7c4afea7bd9d38ee27c534d5e4b1a5f8b6d101 Mon Sep 17 00:00:00 2001 From: Martijn Brekhof Date: Fri, 31 Aug 2018 22:36:55 +0200 Subject: [PATCH] Fixed clearing focus on search view --- .../java/org/xbmc/kore/testhelpers/EspressoTestUtils.java | 4 ++-- .../java/org/xbmc/kore/ui/AbstractCursorListFragment.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/java/org/xbmc/kore/testhelpers/EspressoTestUtils.java b/app/src/androidTest/java/org/xbmc/kore/testhelpers/EspressoTestUtils.java index 4838ee8..dde1e4c 100644 --- a/app/src/androidTest/java/org/xbmc/kore/testhelpers/EspressoTestUtils.java +++ b/app/src/androidTest/java/org/xbmc/kore/testhelpers/EspressoTestUtils.java @@ -49,7 +49,6 @@ import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant; import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.isRoot; -import static android.support.test.espresso.matcher.ViewMatchers.withClassName; import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withParent; @@ -113,7 +112,8 @@ public class EspressoTestUtils { EspressoTestUtils.clickMenuItem(activity, activity.getString(R.string.action_search), R.id.action_search); onView(isAssignableFrom(AutoCompleteTextView.class)) - .perform(click(), typeText(query), clearFocus(), closeSoftKeyboard()); + .perform(click(), typeText(query), closeSoftKeyboard()); + onView(isRoot()).perform(clearFocus()); } /** diff --git a/app/src/main/java/org/xbmc/kore/ui/AbstractCursorListFragment.java b/app/src/main/java/org/xbmc/kore/ui/AbstractCursorListFragment.java index e8eb1fc..4a5a470 100644 --- a/app/src/main/java/org/xbmc/kore/ui/AbstractCursorListFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/AbstractCursorListFragment.java @@ -287,7 +287,11 @@ public abstract class AbstractCursorListFragment extends AbstractListFragment /** * When this fragment is paused, onQueryTextChange is called with an empty string. - * This causes problems restoring the list fragment when returning. + * This causes problems restoring the list fragment when returning. On return the fragment + * is recreated, which will cause the cursor adapter to be recreated. Although + * the search view will have the query restored to its saved state, the CursorAdapter + * will use the empty search filter. This is due to the fact that we don't restart the + * loader when it is still loading after its been created. */ if (isPaused) return true;