use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class ViewPagerActions method scrollToPage.
/** Moves <code>ViewPager</code> to specific page. */
public static ViewAction scrollToPage(final int page) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "ViewPager move to a specific page";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
ViewPager viewPager = (ViewPager) view;
viewPager.setCurrentItem(page, false);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class ViewPagerActions method scrollToFirst.
/** Moves <code>ViewPager</code> to the first page. */
public static ViewAction scrollToFirst() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "ViewPager scroll to first page";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
ViewPager viewPager = (ViewPager) view;
int size = viewPager.getAdapter().getCount();
if (size > 0) {
viewPager.setCurrentItem(0, false);
}
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class ViewPagerActions method scrollToLast.
/** Moves <code>ViewPager</code> to the last page. */
public static ViewAction scrollToLast() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "ViewPager scroll to last page";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
ViewPager viewPager = (ViewPager) view;
int size = viewPager.getAdapter().getCount();
if (size > 0) {
viewPager.setCurrentItem(size - 1, false);
}
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class ViewPagerActions method setAdapter.
/** Sets the specified adapter on <code>ViewPager</code>. */
public static ViewAction setAdapter(@Nullable final PagerAdapter adapter) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(ViewPager.class);
}
@Override
public String getDescription() {
return "ViewPager set adapter";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
ViewPager viewPager = (ViewPager) view;
viewPager.setAdapter(adapter);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class BottomNavigationViewActions method setItemIconTintList.
/** Sets item icon tint list on the content of the bottom navigation view. */
public static ViewAction setItemIconTintList(@Nullable final ColorStateList tint) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Set item icon tint list";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
BottomNavigationView navigationView = (BottomNavigationView) view;
navigationView.setItemIconTintList(tint);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations