issue#103 Removing item animations
This commit is contained in:
parent
4f6bba6cb1
commit
00c222b461
2 changed files with 39 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
package org.fnives.test.showcase.android.testutil.viewaction.recycler
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.UiController
|
||||
import androidx.test.espresso.ViewAction
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
/**
|
||||
* Sets the [RecyclerView]'s [itemAnimator][RecyclerView.setItemAnimator] to null, thus disabling animations.
|
||||
*/
|
||||
class RemoveItemAnimations : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> =
|
||||
ViewMatchers.isAssignableFrom(RecyclerView::class.java)
|
||||
|
||||
override fun getDescription(): String =
|
||||
"Remove item animations"
|
||||
|
||||
override fun perform(uiController: UiController, view: View) {
|
||||
val recycler: RecyclerView = view as RecyclerView
|
||||
recycler.itemAnimator = null
|
||||
uiController.loopMainThreadUntilIdle()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue