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;
}
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;
}
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;
}
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;
}
Aggregations