Search in sources :

Example 1 with ChildViewsIterable

use of com.beloo.widget.chipslayoutmanager.ChildViewsIterable in project ChipsLayoutManager by BelooS.

the class RecyclerViewEspressoFactory method orderMatcher.

///////////////////////////////////////////////////////////////////////////
// Matcher
///////////////////////////////////////////////////////////////////////////
private static Matcher<View> orderMatcher() {
    return new TypeSafeMatcher<View>() {

        @Override
        public void describeTo(Description description) {
            description.appendText("with correct position order");
        }

        @Override
        public boolean matchesSafely(View v) {
            RecyclerView view = (RecyclerView) v;
            if (view.getLayoutManager() == null)
                return false;
            ChildViewsIterable childViews = new ChildViewsIterable(view.getLayoutManager());
            int pos = view.getChildAdapterPosition(childViews.iterator().next());
            for (View child : childViews) {
                if (pos != view.getChildAdapterPosition(child)) {
                    return false;
                }
                pos++;
            }
            return true;
        }
    };
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ChildViewsIterable(com.beloo.widget.chipslayoutmanager.ChildViewsIterable)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ChildViewsIterable (com.beloo.widget.chipslayoutmanager.ChildViewsIterable)1 Description (org.hamcrest.Description)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1