Example usage for android.provider DocumentsContract buildSearchDocumentsUri

List of usage examples for android.provider DocumentsContract buildSearchDocumentsUri

Introduction

In this page you can find the example usage for android.provider DocumentsContract buildSearchDocumentsUri.

Prototype

public static Uri buildSearchDocumentsUri(String authority, String rootId, String query) 

Source Link

Document

Build URI representing a search for matching documents under a specific root in a document provider.

Usage

From source file:org.alfresco.mobile.android.application.providers.storage.StorageAccessDocumentsProvider.java

@Override
public Cursor querySearchDocuments(String rootId, final String query, String[] projection)
        throws FileNotFoundException {
    final DocumentFolderCursor documentFolderCursor = new DocumentFolderCursor(
            resolveDocumentProjection(projection));
    Uri uri = DocumentsContract.buildSearchDocumentsUri(mAuthority, rootId, query);
    final EncodedQueryUri cUri = new EncodedQueryUri(rootId);

    Boolean active = mLoadingUris.get(uri);

    if (active != null) {
        for (Entry<String, Node> nodeEntry : nodesIndex.entrySet()) {
            addNodeRow(documentFolderCursor, nodeEntry.getValue());
        }/*from   w  w  w.j a  va2  s  .c  o m*/
        if (!active) {
            // loading request is finished and refreshed
            mLoadingUris.remove(uri);
        }
    }

    if (active == null) {
        new StorageProviderAsyncTask(uri, documentFolderCursor, true) {
            @Override
            protected Void doInBackground(Void... params) {
                checkSession(cUri);

                List<Node> nodes = session.getServiceRegistry().getSearchService().keywordSearch(query,
                        new KeywordSearchOptions());

                for (Node node : nodes) {
                    nodesIndex.put(NodeRefUtils.getVersionIdentifier(node.getIdentifier()), node);
                }

                return null;
            }
        }.execute();
    }
    return documentFolderCursor;
}