Fixed clearing focus on search view

This commit is contained in:
Martijn Brekhof 2018-08-31 22:36:55 +02:00 committed by Synced Synapse
parent 9999f37869
commit 3c7c4afea7
2 changed files with 7 additions and 3 deletions

View File

@ -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());
}
/**

View File

@ -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;