Search in sources :

Example 1 with FileCursor

use of org.nextcloud.providers.cursors.FileCursor in project android by nextcloud.

the class DocumentsStorageProvider method querySearchDocuments.

@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) {
    Log.d(TAG, "querySearchDocuments(), rootId=" + rootId);
    FileCursor result = new FileCursor(projection);
    FileDataStorageManager storageManager = getStorageManager(rootId);
    if (storageManager == null) {
        return result;
    }
    for (Document d : findFiles(new Document(storageManager, ROOT_PATH), query)) {
        result.addFile(d);
    }
    return result;
}
Also used : FileCursor(org.nextcloud.providers.cursors.FileCursor) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 2 with FileCursor

use of org.nextcloud.providers.cursors.FileCursor in project android by nextcloud.

the class DocumentsStorageProvider method queryChildDocuments.

@SuppressLint("LongLogTag")
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
    Log.d(TAG, "queryChildDocuments(), id=" + parentDocumentId);
    Context context = getNonNullContext();
    Document parentFolder = toDocument(parentDocumentId);
    FileDataStorageManager storageManager = parentFolder.getStorageManager();
    final FileCursor resultCursor = new FileCursor(projection);
    for (OCFile file : storageManager.getFolderContent(parentFolder.getFile(), false)) {
        resultCursor.addFile(new Document(storageManager, file));
    }
    boolean isLoading = false;
    if (parentFolder.isExpired()) {
        final ReloadFolderDocumentTask task = new ReloadFolderDocumentTask(parentFolder, result -> context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false));
        task.executeOnExecutor(executor);
        resultCursor.setLoadingTask(task);
        isLoading = true;
    }
    final Bundle extra = new Bundle();
    extra.putBoolean(DocumentsContract.EXTRA_LOADING, isLoading);
    resultCursor.setExtras(extra);
    resultCursor.setNotificationUri(context.getContentResolver(), toNotifyUri(parentFolder));
    return resultCursor;
}
Also used : Context(android.content.Context) OCFile(com.owncloud.android.datamodel.OCFile) Bundle(android.os.Bundle) FileCursor(org.nextcloud.providers.cursors.FileCursor) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) SuppressLint(android.annotation.SuppressLint)

Example 3 with FileCursor

use of org.nextcloud.providers.cursors.FileCursor in project android by nextcloud.

the class DocumentsStorageProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) {
    // always recreate storage manager collection, as it will change after account creation/removal
    // and we need to serve document(tree)s with persist permissions
    initiateStorageMap();
    Context context = MainApp.getAppContext();
    AppPreferences preferences = AppPreferencesImpl.fromContext(context);
    if (SettingsActivity.LOCK_PASSCODE.equals(preferences.getLockPreference()) || SettingsActivity.LOCK_DEVICE_CREDENTIALS.equals(preferences.getLockPreference())) {
        return new FileCursor();
    }
    final RootCursor result = new RootCursor(projection);
    for (int i = 0; i < rootIdToStorageManager.size(); i++) {
        result.addRoot(new Document(rootIdToStorageManager.valueAt(i), ROOT_PATH), getContext());
    }
    return result;
}
Also used : Context(android.content.Context) FileCursor(org.nextcloud.providers.cursors.FileCursor) AppPreferences(com.nextcloud.client.preferences.AppPreferences) RootCursor(org.nextcloud.providers.cursors.RootCursor) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 4 with FileCursor

use of org.nextcloud.providers.cursors.FileCursor in project android by nextcloud.

the class DocumentsStorageProvider method queryDocument.

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
    Log.d(TAG, "queryDocument(), id=" + documentId);
    Document document = toDocument(documentId);
    final FileCursor result = new FileCursor(projection);
    result.addFile(document);
    return result;
}
Also used : FileCursor(org.nextcloud.providers.cursors.FileCursor)

Aggregations

FileCursor (org.nextcloud.providers.cursors.FileCursor)4 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)2 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 AppPreferences (com.nextcloud.client.preferences.AppPreferences)1 OCFile (com.owncloud.android.datamodel.OCFile)1 RootCursor (org.nextcloud.providers.cursors.RootCursor)1