Home | History | Annotate | Download | only in content

Lines Matching refs:query

111  * {@link ContentResolver#query(Uri, String[], String, String[], String)}. If the underlying
142 * <p>Note that projection is ignored when determining the identity of a query. When
203 private final @GuardedBy("mContentLock") Set<Query> mActiveQueries = new HashSet<>();
222 * query argument creates a new Uri.
224 * @param queryRunner The query running to use. This provides a means of executing
242 public @Nullable Cursor runQueryInBackground(Query query) {
243 return loadContentInBackground(query);
248 public void onQueryFinished(Query query, Cursor cursor) {
249 ContentPager.this.onCursorReady(query, cursor);
259 * {@link ContentResolver#query(Uri, String[], Bundle, CancellationSignal)}.
265 * @param queryArgs A Bundle containing any arguments to the query.
268 * when the query is executed.
269 * @param callback The callback that will receive the query results.
271 * @return A Query object describing the query.
274 public @NonNull Query query(
285 Query query = new Query(uri, projection, queryArgs, cancellationSignal, callback);
287 if (DEBUG) Log.d(TAG, "Handling query: " + query);
289 if (!mQueryRunner.isRunning(query)) {
291 mActiveQueries.add(query);
293 mQueryRunner.query(query, mQueryCallback);
296 return query;
309 for (Query query : mActiveQueries) {
310 if (DEBUG) Log.d(TAG, "Canceling running query: " + query);
311 mQueryRunner.cancel(query);
312 query.cancel();
320 private Cursor loadContentInBackground(Query query) {
321 if (DEBUG) Log.v(TAG, "Loading cursor for query: " + query);
325 // We have a existing unpaged-cursor for this query. Instead of running a new query
328 if (mCursorCache.hasEntry(query.getUri())) {
329 if (DEBUG) Log.d(TAG, "Found unpaged results in cache for: " + query);
330 return createPagedCursor(query);
334 // We don't have an unpaged query, so we run the query using ContentResolver.
335 // It may be that no query for this URI has ever been run, so no unpaged
339 Cursor cursor = query.run(mResolver);
344 Log.e(TAG, "Query resulted in null cursor. " + query);
349 return processProviderPagedCursor(query, cursor);
354 mCursorCache.put(query.getUri(), cursor);
355 return createPagedCursor(query);
361 private Cursor createPagedCursor(Query query) {
362 Cursor unpaged = mCursorCache.get(query.getUri());
367 if (DEBUG) Log.d(TAG, "Synthesizing cursor for page: " + query);
368 int count = Math.min(query.getLimit(), unpaged.getCount());
371 if (query.getOffset() + query.getLimit() > unpaged.getCount()) {
372 count = unpaged.getCount() % query.getLimit();
381 if (query.getOffset() == 0 && unpaged.getCount() < query.getLimit()) {
389 unpaged, query.getOffset(), count, CURSOR_DISPOSITION_COPIED);
397 private @Nullable Cursor processProviderPagedCursor(Query query, Cursor cursor) {
428 extras.putInt(EXTRA_REQUESTED_LIMIT, query.getLimit());
450 private void onCursorReady(Query query, Cursor cursor) {
452 mActiveQueries.remove(query);
455 query.getCallback().onCursorReady(query, cursor);
516 * {@link #query(Uri, String[], Bundle, CancellationSignal, ContentCallback)}.
535 * Callback by which a client receives results of a query.
539 * Called when paged cursor is ready. Null, if query failed.
540 * @param query The query having been executed.
541 * @param cursor the query results. Null if query couldn't be executed.
544 void onCursorReady(@NonNull Query query, @Nullable Cursor cursor);
579 * not the entire query. Cursors that are pre-paged by the provider
610 * Execute a query.
611 * @param query The query that will be run. This value should be handed
614 * the query (in the background) and to receive the results
617 void query(@NonNull Query query, @NonNull Callback callback);
620 * @param query The query in question.
621 * @return true if the query is already running.
623 boolean isRunning(@NonNull Query query);
626 * Attempt to cancel a (presumably) running query.
627 * @param query The query in question.
629 void cancel(@NonNull Query query);
632 * Callback that receives a cursor once a query as been executed on the Runner.
636 * Method called on background thread where actual query is executed. This is provided
638 * @param query The query to be executed.
640 @Nullable Cursor runQueryInBackground(@NonNull Query query);
643 * Called on main thread when query has completed.
644 * @param query The completed query.
647 void onQueryFinished(@NonNull Query query, @Nullable Cursor cursor);