use of android.support.design.widget.SwipeDismissBehavior in project RxBinding by JakeWharton.
the class SwipeDismissBehaviorObservable method subscribeActual.
@Override
protected void subscribeActual(Observer<? super View> observer) {
if (!checkMainThread(observer)) {
return;
}
if (!(view.getLayoutParams() instanceof LayoutParams)) {
throw new IllegalArgumentException("The view is not in a Coordinator Layout.");
}
LayoutParams params = (LayoutParams) view.getLayoutParams();
final SwipeDismissBehavior behavior = (SwipeDismissBehavior) params.getBehavior();
if (behavior == null) {
throw new IllegalStateException("There's no behavior set on this view.");
}
Listener listener = new Listener(behavior, observer);
observer.onSubscribe(listener);
behavior.setListener(listener);
}
use of android.support.design.widget.SwipeDismissBehavior in project RxBinding by JakeWharton.
the class RxSwipeDismissBehaviorTest method dismisses.
@Test
public void dismisses() {
((CoordinatorLayout.LayoutParams) view.getLayoutParams()).setBehavior(new SwipeDismissBehavior());
RecordingObserver<View> o = new RecordingObserver<>();
RxSwipeDismissBehavior.dismisses(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o);
// No initial value.
o.assertNoMoreEvents();
onView(withId(1)).perform(swipeRight());
assertEquals(view, o.takeNext());
o.dispose();
onView(withId(1)).perform(swipeRight());
o.assertNoMoreEvents();
}
Aggregations