androidx.recyclerview.widget.AsyncDifferConfig Java Examples
The following examples show how to use
androidx.recyclerview.widget.AsyncDifferConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncListDifferDelegationAdapterTest.java From AdapterDelegates with Apache License 2.0 | 6 votes |
@Test @Ignore("Why does Mockito can't mock the final class anymore?") public void checkDelegatesManagerInstance() { final AdapterDelegatesManager<List<Object>> manager = new AdapterDelegatesManager<>(); AsyncDifferConfig<Object> config = Mockito.mock(AsyncDifferConfig.class); AsyncListDifferDelegationAdapter<Object> adapter = new AsyncListDifferDelegationAdapter<Object>(config, manager) { @Override public int getItemCount() { // Hacky but does the job Assert.assertTrue(manager == this.delegatesManager); return 0; } }; adapter.getItemCount(); }
Example #2
Source File: PagedListDelegationAdapterTest.java From AdapterDelegates with Apache License 2.0 | 6 votes |
@Test @Ignore("Why does Mockito can't mock the final class anymore?") public void checkDelegatesManagerInstance() { final AdapterDelegatesManager<List<Object>> manager = new AdapterDelegatesManager<>(); AsyncDifferConfig<Object> config = Mockito.mock(AsyncDifferConfig.class); PagedListDelegationAdapter<Object> adapter = new PagedListDelegationAdapter<Object>(manager, config) { @Override public int getItemCount() { // Hacky but does the job Assert.assertTrue(manager == this.delegatesManager); return 0; } }; adapter.getItemCount(); }
Example #3
Source File: AsyncListDifferDelegationAdapter.java From AdapterDelegates with Apache License 2.0 | 5 votes |
public AsyncListDifferDelegationAdapter(@NonNull AsyncDifferConfig differConfig, @NonNull AdapterDelegatesManager<List<T>> delegatesManager) { if (differConfig == null) { throw new NullPointerException("AsyncDifferConfig is null"); } if (delegatesManager == null) { throw new NullPointerException("AdapterDelegatesManager is null"); } this.differ = new AsyncListDiffer<T>(new AdapterListUpdateCallback(this), differConfig); this.delegatesManager = delegatesManager; }
Example #4
Source File: AsyncListDifferDelegationAdapter.java From AdapterDelegates with Apache License 2.0 | 5 votes |
/** * Adds a list of {@link AdapterDelegate}s * * @param delegates * @since 4.2.0 */ public AsyncListDifferDelegationAdapter(@NonNull AsyncDifferConfig differConfig, @NonNull AdapterDelegate<List<T>>... delegates) { if (differConfig == null) { throw new NullPointerException("AsyncDifferConfig is null"); } this.differ = new AsyncListDiffer<T>(new AdapterListUpdateCallback(this), differConfig); this.delegatesManager = new AdapterDelegatesManager<List<T>>(delegates); }
Example #5
Source File: PagedListDelegationAdapter.java From AdapterDelegates with Apache License 2.0 | 5 votes |
public PagedListDelegationAdapter(@NonNull AdapterDelegatesManager<List<T>> delegatesManager, @NonNull AsyncDifferConfig<T> config) { super(config); if (config == null) { throw new NullPointerException("AsyncDifferConfig is null"); } if (delegatesManager == null) { throw new NullPointerException("AdapterDelegatesManager is null"); } this.delegatesManager = delegatesManager; }
Example #6
Source File: RVListRendererAdapter.java From Renderers with Apache License 2.0 | 5 votes |
public RVListRendererAdapter(RendererBuilder<T> rendererBuilder, @NonNull AsyncDifferConfig config, AdapteeCollection<T> collection) { super(config); this.rendererBuilder = rendererBuilder; this.collection = collection; }
Example #7
Source File: DifferFlapAdapter.java From Flap with Apache License 2.0 | 4 votes |
public DifferFlapAdapter(@NonNull AsyncDifferConfig<T> config) { differ = new AsyncListDiffer(new AdapterListUpdateCallback(this), config); }
Example #8
Source File: AsyncListDifferDelegationAdapterTest.java From AdapterDelegates with Apache License 2.0 | 4 votes |
@Test @Ignore("Why does Mockito can't mock the final class anymore?") public void callAllMethods() { final SpyableAdapterDelegate<List<Object>> delegate1 = new SpyableAdapterDelegate<>(0); final SpyableAdapterDelegate<List<Object>> delegate2 = new SpyableAdapterDelegate<>(1); final AdapterDelegatesManager<List<Object>> manager = new AdapterDelegatesManager<List<Object>>() .addDelegate(delegate1) .addDelegate(delegate2); AsyncDifferConfig<Object> config = Mockito.mock(AsyncDifferConfig.class); AsyncListDifferDelegationAdapter<Object> adapter = new AsyncListDifferDelegationAdapter<Object>(config, manager); ViewGroup parent = Mockito.mock(ViewGroup.class); // CreateViewHolder adapter.onCreateViewHolder(parent, 0); Assert.assertTrue(delegate1.onCreateViewHolderCalled); Assert.assertFalse(delegate2.onCreateViewHolderCalled); // BindViewHolder adapter.onBindViewHolder(delegate1.viewHolder, 1); Assert.assertTrue(delegate1.onBindViewHolderCalled); Assert.assertFalse(delegate2.onBindViewHolderCalled); // bind with payload delegate1.onBindViewHolderCalled = false; // reset adapter.onBindViewHolder(delegate1.viewHolder, 1, Collections.emptyList()); Assert.assertTrue(delegate1.onBindViewHolderCalled); Assert.assertFalse(delegate2.onBindViewHolderCalled); // On view AttachedToWindow adapter.onViewAttachedToWindow(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewAtachedToWindowCalled); Assert.assertFalse(delegate2.onViewAtachedToWindowCalled); // On view Detached from window adapter.onViewDetachedFromWindow(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewDetachedFromWindowCalled); Assert.assertFalse(delegate2.onViewDetachedFromWindowCalled); // failed to recycle view holder Assert.assertFalse(adapter.onFailedToRecycleView(delegate1.viewHolder)); Assert.assertTrue(delegate1.onFailedToRecycleViewCalled); Assert.assertFalse(delegate2.onFailedToRecycleViewCalled); // view recycle view holder adapter.onViewRecycled(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewRecycledCalled); Assert.assertFalse(delegate2.onViewRecycledCalled); }
Example #9
Source File: PagedListDelegationAdapter.java From AdapterDelegates with Apache License 2.0 | 4 votes |
public PagedListDelegationAdapter(@NonNull AsyncDifferConfig<T> config) { this(new AdapterDelegatesManager<List<T>>(), config); }
Example #10
Source File: PagedListDelegationAdapterTest.java From AdapterDelegates with Apache License 2.0 | 4 votes |
@Test @Ignore("Why does Mockito can't mock the final class anymore?") public void callAllMethods() { final SpyableAdapterDelegate<List<Object>> delegate1 = new SpyableAdapterDelegate<>(0); final SpyableAdapterDelegate<List<Object>> delegate2 = new SpyableAdapterDelegate<>(1); final AdapterDelegatesManager<List<Object>> manager = new AdapterDelegatesManager<List<Object>>() .addDelegate(delegate1) .addDelegate(delegate2); AsyncDifferConfig<Object> config = Mockito.mock(AsyncDifferConfig.class); AsyncListDifferDelegationAdapter<Object> adapter = new AsyncListDifferDelegationAdapter<Object>(config, manager); ViewGroup parent = Mockito.mock(ViewGroup.class); // CreateViewHolder adapter.onCreateViewHolder(parent, 0); Assert.assertTrue(delegate1.onCreateViewHolderCalled); Assert.assertFalse(delegate2.onCreateViewHolderCalled); // BindViewHolder adapter.onBindViewHolder(delegate1.viewHolder, 1); Assert.assertTrue(delegate1.onBindViewHolderCalled); Assert.assertFalse(delegate2.onBindViewHolderCalled); // bind with payload delegate1.onBindViewHolderCalled = false; // reset adapter.onBindViewHolder(delegate1.viewHolder, 1, Collections.emptyList()); Assert.assertTrue(delegate1.onBindViewHolderCalled); Assert.assertFalse(delegate2.onBindViewHolderCalled); // On view AttachedToWindow adapter.onViewAttachedToWindow(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewAtachedToWindowCalled); Assert.assertFalse(delegate2.onViewAtachedToWindowCalled); // On view Detached from window adapter.onViewDetachedFromWindow(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewDetachedFromWindowCalled); Assert.assertFalse(delegate2.onViewDetachedFromWindowCalled); // failed to recycle view holder Assert.assertFalse(adapter.onFailedToRecycleView(delegate1.viewHolder)); Assert.assertTrue(delegate1.onFailedToRecycleViewCalled); Assert.assertFalse(delegate2.onFailedToRecycleViewCalled); // view recycle view holder adapter.onViewRecycled(delegate1.viewHolder); Assert.assertTrue(delegate1.onViewRecycledCalled); Assert.assertFalse(delegate2.onViewRecycledCalled); }
Example #11
Source File: AssemblyPagedListAdapter.java From assembly-adapter with Apache License 2.0 | 4 votes |
public AssemblyPagedListAdapter(@NonNull AsyncDifferConfig<T> config) { mDiffer = new AsyncPagedListDiffer<T>(new AdapterListUpdateCallback(this), config); mDiffer.addPagedListListener(mListener); }
Example #12
Source File: RVListRendererAdapter.java From Renderers with Apache License 2.0 | 4 votes |
public RVListRendererAdapter(RendererBuilder<T> rendererBuilder, @NonNull AsyncDifferConfig config) { this(rendererBuilder, config, new ListAdapteeCollection<T>()); }