Java Code Examples for android.content.ContentResolver#QUERY_ARG_OFFSET
The following examples show how to use
android.content.ContentResolver#QUERY_ARG_OFFSET .
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: ImageProvider.java From storage-samples with Apache License 2.0 | 4 votes |
@Override public Cursor query(Uri uri, String[] projection, Bundle queryArgs, CancellationSignal cancellationSignal) { int match = sUriMatcher.match(uri); // We only support a query for multiple images, return null for other form of queries // including a query for a single image. switch (match) { case IMAGES: break; default: return null; } MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection)); File[] files = mBaseDir.listFiles(); int offset = queryArgs.getInt(ContentResolver.QUERY_ARG_OFFSET, 0); int limit = queryArgs.getInt(ContentResolver.QUERY_ARG_LIMIT, Integer.MAX_VALUE); Log.d(TAG, "queryChildDocuments with Bundle, Uri: " + uri + ", offset: " + offset + ", limit: " + limit); if (offset < 0) { throw new IllegalArgumentException("Offset must not be less than 0"); } if (limit < 0) { throw new IllegalArgumentException("Limit must not be less than 0"); } if (offset >= files.length) { return result; } for (int i = offset, maxIndex = Math.min(offset + limit, files.length); i < maxIndex; i++) { includeFile(result, files[i]); } Bundle bundle = new Bundle(); bundle.putInt(ContentResolver.EXTRA_SIZE, files.length); String[] honoredArgs = new String[2]; int size = 0; if (queryArgs.containsKey(ContentResolver.QUERY_ARG_OFFSET)) { honoredArgs[size++] = ContentResolver.QUERY_ARG_OFFSET; } if (queryArgs.containsKey(ContentResolver.QUERY_ARG_LIMIT)) { honoredArgs[size++] = ContentResolver.QUERY_ARG_LIMIT; } if (size != honoredArgs.length) { honoredArgs = Arrays.copyOf(honoredArgs, size); } bundle.putStringArray(ContentResolver.EXTRA_HONORED_ARGS, honoredArgs); result.setExtras(bundle); return result; }
Example 2
Source File: ImageProvider.java From android-ContentProviderPaging with Apache License 2.0 | 4 votes |
@Override public Cursor query(Uri uri, String[] projection, Bundle queryArgs, CancellationSignal cancellationSignal) { int match = sUriMatcher.match(uri); // We only support a query for multiple images, return null for other form of queries // including a query for a single image. switch (match) { case IMAGES: break; default: return null; } MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection)); File[] files = mBaseDir.listFiles(); int offset = queryArgs.getInt(ContentResolver.QUERY_ARG_OFFSET, 0); int limit = queryArgs.getInt(ContentResolver.QUERY_ARG_LIMIT, Integer.MAX_VALUE); Log.d(TAG, "queryChildDocuments with Bundle, Uri: " + uri + ", offset: " + offset + ", limit: " + limit); if (offset < 0) { throw new IllegalArgumentException("Offset must not be less than 0"); } if (limit < 0) { throw new IllegalArgumentException("Limit must not be less than 0"); } if (offset >= files.length) { return result; } for (int i = offset, maxIndex = Math.min(offset + limit, files.length); i < maxIndex; i++) { includeFile(result, files[i]); } Bundle bundle = new Bundle(); bundle.putInt(ContentResolver.EXTRA_TOTAL_SIZE, files.length); String[] honoredArgs = new String[2]; int size = 0; if (queryArgs.containsKey(ContentResolver.QUERY_ARG_OFFSET)) { honoredArgs[size++] = ContentResolver.QUERY_ARG_OFFSET; } if (queryArgs.containsKey(ContentResolver.QUERY_ARG_LIMIT)) { honoredArgs[size++] = ContentResolver.QUERY_ARG_LIMIT; } if (size != honoredArgs.length) { honoredArgs = Arrays.copyOf(honoredArgs, size); } bundle.putStringArray(ContentResolver.EXTRA_HONORED_ARGS, honoredArgs); result.setExtras(bundle); return result; }