I run the code belows and got error at return anything();
error: incompatible types
required: Matcher <View>
found: Matcher <Object>
/**
* Perform action of waiting until UI thread is free. <p/> E.g.: onView(isRoot()).perform(waitUntilIdle());
* @return
*/
public static ViewAction waitUntilIdle(){
return new ViewAction(){
@Override public Matcher<View> getConstraints(){
return anything();
}
@Override public String getDescription(){
return "wait until UI thread is free";
}
@Override public void perform( final UiController uiController, final View view){
uiController.loopMainThreadUntilIdle();
}
}
;
}
Any ideas?
anything() is not a generic method, so you will always get a Matcher<Object>.
Internally anything() uses the IsAnything class. You can make your own anyView() method to return a Matcher<View>.
public static ViewAction waitUntilIdle(){
return new ViewAction(){
@Override public Matcher<View> getConstraints(){
return anyView();
}
@NonNull
private Matcher<View> anyView() {
return new IsAnything<>();
}
@Override public String getDescription(){
return "wait until UI thread is free";
}
@Override public void perform( final UiController uiController, final View view){
uiController.loopMainThreadUntilIdle();
}
}
;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With