# LoaderQueryRunner

Artifact: [androidx.contentpager:contentpager](https://developer.android.com/jetpack/androidx/releases/contentpager) [View Source](https://cs.android.com/search?q=file:androidx/contentpager/content/LoaderQueryRunner.java+class:androidx.contentpager.content.LoaderQueryRunner) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/contentpager#1.0.0)

*** ** * ** ***


```
public final class LoaderQueryRunner implements ContentPager.QueryRunner
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/contentpager/content/ContentPager.QueryRunner` that executes queries using a `https://developer.android.com/reference/android/app/LoaderManager.html`. Use this when preparing `https://developer.android.com/reference/androidx/contentpager/content/ContentPager` to run in an Activity or Fragment scope.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/contentpager/content/LoaderQueryRunner#LoaderQueryRunner(android.content.Context,android.app.LoaderManager)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/LoaderManager.html loaderMgr )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/contentpager/content/LoaderQueryRunner#cancel(androidx.contentpager.content.Query)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query)` Attempt to cancel a (presumably) running query. |
| `boolean` | `https://developer.android.com/reference/androidx/contentpager/content/LoaderQueryRunner#isRunning(androidx.contentpager.content.Query)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query)` |
| `void` | `https://developer.android.com/reference/androidx/contentpager/content/LoaderQueryRunner#query(androidx.contentpager.content.Query,androidx.contentpager.content.ContentPager.QueryRunner.Callback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/ContentPager.QueryRunner.Callback callback )` Execute a query. |

## Public constructors

### LoaderQueryRunner

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/contentpager#1.0.0)

```
public LoaderQueryRunner(
    @NonNull Context context,
    @NonNull LoaderManager loaderMgr
)
```

## Public methods

### cancel

Added in [1.1.0-alpha01](https://developer.android.com/jetpack/androidx/releases/contentpager#1.1.0-alpha01)

```
public void cancel(@NonNull Query query)
```

Attempt to cancel a (presumably) running query.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query` | The query in question. |

### isRunning

Added in [1.1.0-alpha01](https://developer.android.com/jetpack/androidx/releases/contentpager#1.1.0-alpha01)

```
public boolean isRunning(@NonNull Query query)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query` | The query in question. |

| Returns |
|---|---|
| `boolean` | true if the query is already running. |

### query

Added in [1.1.0-alpha01](https://developer.android.com/jetpack/androidx/releases/contentpager#1.1.0-alpha01)

```
public void query(
    @NonNull Query query,
    @NonNull ContentPager.QueryRunner.Callback callback
)
```

Execute a query.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/Query query` | The query that will be run. This value should be handed back to the callback when ready to run in the background. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/contentpager/content/ContentPager.QueryRunner.Callback callback` | The callback that should be called to both execute the query (in the background) and to receive the results (in the foreground). |