use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class ExternalStorageProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(parentDocumentId) || DocumentArchiveHelper.isSupportedArchiveType(getDocumentType(parentDocumentId))) {
return mArchiveHelper.queryChildDocuments(parentDocumentId, projection, sortOrder);
}
final File parent = getFileForDocId(parentDocumentId);
final MatrixCursor result = new DirectoryCursor(resolveDocumentProjection(projection), parentDocumentId, parent);
updateSettings();
for (File file : parent.listFiles()) {
includeFile(result, null, file);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class ExternalStorageProvider method querySearchDocuments.
@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final File parent;
synchronized (mRootsLock) {
parent = mRoots.get(rootId).path;
}
updateSettings();
for (File file : FileUtils.searchDirectory(parent.getPath(), query)) {
includeFile(result, null, file);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class MediaDocumentsProvider method queryDocument.
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final Ident ident = getIdentForDocId(docId);
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
if (TYPE_IMAGES_ROOT.equals(ident.type)) {
// single root
includeImagesRootDocument(result);
} else if (TYPE_IMAGES_BUCKET.equals(ident.type)) {
// single bucket
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI, ImagesBucketQuery.PROJECTION, ImageColumns.BUCKET_ID + "=" + ident.id, null, ImagesBucketQuery.SORT_ORDER);
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeImagesBucket(result, cursor);
}
} else if (TYPE_IMAGE.equals(ident.type)) {
// single image
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI, ImageQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null, null);
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeImage(result, cursor);
}
} else if (TYPE_VIDEOS_ROOT.equals(ident.type)) {
// single root
includeVideosRootDocument(result);
} else if (TYPE_VIDEOS_BUCKET.equals(ident.type)) {
// single bucket
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI, VideosBucketQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + ident.id, null, VideosBucketQuery.SORT_ORDER);
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeVideosBucket(result, cursor);
}
} else if (TYPE_VIDEO.equals(ident.type)) {
// single video
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI, VideoQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null, null);
copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeVideo(result, cursor);
}
} else if (TYPE_AUDIO_ROOT.equals(ident.type)) {
// single root
includeAudioRootDocument(result);
} else if (TYPE_ARTIST.equals(ident.type)) {
// single artist
cursor = resolver.query(Artists.EXTERNAL_CONTENT_URI, ArtistQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null, null);
copyNotificationUri(result, Artists.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeArtist(result, cursor);
}
} else if (TYPE_ALBUM.equals(ident.type)) {
// single album
cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI, AlbumQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null, null);
copyNotificationUri(result, Albums.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeAlbum(result, cursor);
}
} else if (TYPE_AUDIO.equals(ident.type)) {
// single song
cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI, SongQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null, null);
copyNotificationUri(result, Audio.Media.EXTERNAL_CONTENT_URI);
if (cursor.moveToFirst()) {
includeAudio(result, cursor);
}
} else {
throw new UnsupportedOperationException("Unsupported document " + docId);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class NetworkStorageProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
synchronized (mRootsLock) {
for (Map.Entry<String, NetworkConnection> root : mRoots.entrySet()) {
NetworkConnection networkConnection = root.getValue();
String documentId = getDocIdForFile(networkConnection.file);
int flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_IS_CHILD;
boolean isServer = networkConnection.getType().compareToIgnoreCase(SERVER) == 0;
if (isServer) {
if (!Utils.hasWiFi(getContext())) {
continue;
}
flags |= Root.FLAG_CONNECTION_SERVER;
}
final RowBuilder row = result.newRow();
// These columns are required
row.add(Root.COLUMN_ROOT_ID, root.getKey());
row.add(Root.COLUMN_DOCUMENT_ID, documentId);
row.add(Root.COLUMN_TITLE, networkConnection.name);
row.add(Root.COLUMN_FLAGS, flags);
// These columns are optional
row.add(Root.COLUMN_SUMMARY, isServer ? networkConnection.getPath() : networkConnection.getSummary());
row.add(Root.COLUMN_PATH, networkConnection.getPath());
}
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class HeatMapProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
final File parent = getFileForDocId(parentDocumentId);
final MatrixCursor result = new DirectoryCursor(resolveDocumentProjection(projection), parentDocumentId, parent);
for (File file : parent.listFiles()) {
includeFile(result, null, file);
}
return result;
}
Aggregations