// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
@NonNull
    @Override
    public final ListenableFuture<InitialResult<T>> loadInitial(
            @NonNull final ListenablePositionalDataSource.LoadInitialParams params) {
        final ResolvableFuture<InitialResult<T>> future = ResolvableFuture.create();
        getExecutor().execute(new Runnable() {
            @Override
            public void run() {
                final LoadInitialParams newParams = new LoadInitialParams(
                        params.requestedStartPosition,
                        params.requestedLoadSize,
                        params.pageSize,
                        params.placeholdersEnabled);
                LoadInitialCallback<T> callback = new LoadInitialCallback<T>() {
                    @Override
                    public void onResult(@NonNull List<T> data, int position, int totalCount) {
                        if (isInvalid()) {
                            // NOTE: this isInvalid() check works around
                            // https://issuetracker.google.com/issues/124511903
                            future.set(new InitialResult<>(Collections.<T>emptyList(), 0, 0));
                        } else {
                            setFuture(newParams, new InitialResult<>(data, position, totalCount));
                        }
                    }
                    @Override
                    public void onResult(@NonNull List<T> data, int position) {
                        if (isInvalid()) {
                            // NOTE: this isInvalid() check works around
                            // https://issuetracker.google.com/issues/124511903
                            future.set(new InitialResult<>(Collections.<T>emptyList(), 0));
                        } else {
                            setFuture(newParams, new InitialResult<>(data, position));
                        }
                    }
                    private void setFuture(
                            @NonNull ListenablePositionalDataSource.LoadInitialParams params,
                            @NonNull InitialResult<T> result) {
                        if (params.placeholdersEnabled) {
                            result.validateForInitialTiling(params.pageSize);
                        }
                        future.set(result);
                    }
                    @Override
                    public void onError(@NonNull Throwable error) {
                        future.setException(error);
                    }
                };
                loadInitial(newParams,
                        callback);
            }
        });
        return future;
    }
public void onResult(@NonNull List<T> data, int position, int totalCount) {
if (isInvalid()) {
// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
future.set(new InitialResult<>(Collections.<T>emptyList(), 0, 0));
} else {
public void run() {
final LoadInitialParams newParams = new LoadInitialParams(
params.requestedStartPosition,
params.requestedLoadSize,
params.pageSize,
params.placeholdersEnabled);
LoadInitialCallback<T> callback = new LoadInitialCallback<T>() {
@Override
public void onResult(@NonNull List<T> data, int position, int totalCount) {
if (isInvalid()) {
// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
future.set(new InitialResult<>(Collections.<T>emptyList(), 0, 0));
} else {
setFuture(newParams, new InitialResult<>(data, position, totalCount));
}
}
@Override
public void onResult(@NonNull List<T> data, int position) {
if (isInvalid()) {
// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
@NonNull
@Override
public final ListenableFuture<InitialResult<T>> loadInitial(
@NonNull final ListenablePositionalDataSource.LoadInitialParams params) {
final ResolvableFuture<InitialResult<T>> future = ResolvableFuture.create();
getExecutor().execute(new Runnable() {
@Override
public void run() {
final LoadInitialParams newParams = new LoadInitialParams(
params.requestedStartPosition,
params.requestedLoadSize,
params.pageSize,
params.placeholdersEnabled);
LoadInitialCallback<T> callback = new LoadInitialCallback<T>() {
@Override
public void onResult(@NonNull List<T> data, int position, int totalCount) {
if (isInvalid()) {
// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
future.set(new InitialResult<>(Collections.<T>emptyList(), 0, 0));
} else {
setFuture(newParams, new InitialResult<>(data, position, totalCount));
}
}
@Override
public void onResult(@NonNull List<T> data, int position) {
if (isInvalid()) {
// NOTE: this isInvalid() check works around
// https://issuetracker.google.com/issues/124511903
future.set(new InitialResult<>(Collections.<T>emptyList(), 0));
} else {
setFuture(newParams, new InitialResult<>(data, position));
}
}
private void setFuture(
@NonNull ListenablePositionalDataSource.LoadInitialParams params,
@NonNull InitialResult<T> result) {
if (params.placeholdersEnabled) {
result.validateForInitialTiling(params.pageSize);