@Test public void testAttachToNullRecyclerView() { final TestInteractor mockInteractor = mock(TestInteractor.class); final TestHelper helper = new TestHelper(mockInteractor); helper.attachToRecyclerView(null); verify(mockInteractor, times(0)).canAttachAdapter(any(RecyclerView.Adapter.class)); verify(mockInteractor, times(0)).onAdapterAttached(any(RecyclerView.Adapter.class)); verify(mockInteractor, times(0)).onAdapterDetached(any(RecyclerView.Adapter.class)); }
@Override public void attachToRecyclerView(@Nullable final RecyclerView recyclerView) { super.attachToRecyclerView(recyclerView); if (recyclerView == null) { this.interactor.attachAdapter(null); } else { final RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter == null || interactor.canAttachAdapter(adapter)) { this.interactor.attachAdapter(adapter); } else { throw new IllegalArgumentException("Cannot attach adapter(" + adapter + ") to this(" + this + ") item helper."); } } }
RecyclerViewItemHelper extends ItemTouchHelper { @Override public void attachToRecyclerView(@Nullable final RecyclerView recyclerView) { super.attachToRecyclerView(recyclerView); if (recyclerView == null) { this.interactor.attachAdapter(null); } else { final RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter == null || interactor.canAttachAdapter(adapter)) { this.interactor.attachAdapter(adapter); } else { throw new IllegalArgumentException("Cannot attach adapter(" + adapter + ") to this(" + this + ") item helper."); } } } }
RecyclerViewItemHelper extends ItemTouchHelper { @Override public void attachToRecyclerView(@Nullable final RecyclerView recyclerView) { super.attachToRecyclerView(recyclerView); if (recyclerView == null) { this.interactor.attachAdapter(null); } else { final RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter == null || interactor.canAttachAdapter(adapter)) { this.interactor.attachAdapter(adapter); } else { throw new IllegalArgumentException("Cannot attach adapter(" + adapter + ") to this(" + this + ") item helper."); } } } protected  RecyclerViewItemHelper(@NonNull final I interactor); }
RecyclerViewItemHelper extends ItemTouchHelper { @Override public void attachToRecyclerView(@Nullable final RecyclerView recyclerView) { super.attachToRecyclerView(recyclerView); if (recyclerView == null) { this.interactor.attachAdapter(null); } else { final RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter == null || interactor.canAttachAdapter(adapter)) { this.interactor.attachAdapter(adapter); } else { throw new IllegalArgumentException("Cannot attach adapter(" + adapter + ") to this(" + this + ") item helper."); } } } protected  RecyclerViewItemHelper(@NonNull final I interactor); @NonNull final I getInteractor(); @Override void attachToRecyclerView(@Nullable final RecyclerView recyclerView); }
RecyclerViewItemHelper extends ItemTouchHelper { @Override public void attachToRecyclerView(@Nullable final RecyclerView recyclerView) { super.attachToRecyclerView(recyclerView); if (recyclerView == null) { this.interactor.attachAdapter(null); } else { final RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter == null || interactor.canAttachAdapter(adapter)) { this.interactor.attachAdapter(adapter); } else { throw new IllegalArgumentException("Cannot attach adapter(" + adapter + ") to this(" + this + ") item helper."); } } } protected  RecyclerViewItemHelper(@NonNull final I interactor); @NonNull final I getInteractor(); @Override void attachToRecyclerView(@Nullable final RecyclerView recyclerView);  }