PagedList extends PagerBase<Type> { @MainThread public <Key> void triggerInitialLoad(final Key initialLoadKey) { if (mInitialized) { return; } mInitialized = true; mBackgroundThreadExecutor.execute(new Runnable() { @Override public void run() { if (mInvalid.get()) { return; } final List<Type> initialData = mDataSource.loadAfterInitial(initialLoadKey, mConfig.mPageSize); if (initialData != null) { mMainThreadExecutor.execute(new Runnable() { @Override public void run() { if (mInvalid.get()) { return; } setInitialDataAndDispatch(initialData); } }); } else { freeze(); } } }); } @WorkerThread <Key> PagedList(@NonNull DataSource<Key, Type> dataSource,
            @NonNull Executor mainThreadExecutor, @NonNull Executor backgroundThreadExecutor,
            @NonNull ListConfig config); @Override @NonNull Type get(int index); @Override @NonNull Type access(int index); @Override int size(); @MainThread void triggerInitialLoad(final Key initialLoadKey); @WorkerThread boolean initializeFrom(PagedList<Type> old); @SuppressWarnings("WeakerAccess") void addCallback(ChangeCallback callback); @SuppressWarnings("WeakerAccess") void removeCallback(ChangeCallback callback);  }
@Test public void initial() { PagedList<User> pagedList = createPagedList(20, 5); pagedList.triggerInitialLoad(null); drain(); TestDataSource.verifyRange(pagedList, 0, 20); pagedList = createPagedList(10, 5); pagedList.triggerInitialLoad(null); drain(); TestDataSource.verifyRange(pagedList, 0, 10); }