use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class MediaDocumentsProvider method queryRecentDocuments.
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection) throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
if (TYPE_IMAGES_ROOT.equals(rootId)) {
// include all unique buckets
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI, ImageQuery.PROJECTION, null, null, ImageColumns.DATE_MODIFIED + " DESC");
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext() && result.getCount() < 64) {
includeImage(result, cursor);
}
} else if (TYPE_VIDEOS_ROOT.equals(rootId)) {
// include all unique buckets
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI, VideoQuery.PROJECTION, null, null, VideoColumns.DATE_MODIFIED + " DESC");
copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext() && result.getCount() < 64) {
includeVideo(result, cursor);
}
} else {
throw new UnsupportedOperationException("Unsupported root " + rootId);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class MediaDocumentsProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder) 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)) {
// include all unique buckets
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI, ImagesBucketQuery.PROJECTION, null, null, ImagesBucketQuery.SORT_ORDER);
// multiple orders
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
long lastId = Long.MIN_VALUE;
while (cursor.moveToNext()) {
final long id = cursor.getLong(ImagesBucketQuery.BUCKET_ID);
if (lastId != id) {
includeImagesBucket(result, cursor);
lastId = id;
}
}
} else if (TYPE_IMAGES_BUCKET.equals(ident.type)) {
// include images under bucket
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI, ImageQuery.PROJECTION, ImageColumns.BUCKET_ID + "=" + ident.id, null, null);
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext()) {
includeImage(result, cursor);
}
} else if (TYPE_VIDEOS_ROOT.equals(ident.type)) {
// include all unique buckets
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI, VideosBucketQuery.PROJECTION, null, null, VideosBucketQuery.SORT_ORDER);
copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
long lastId = Long.MIN_VALUE;
while (cursor.moveToNext()) {
final long id = cursor.getLong(VideosBucketQuery.BUCKET_ID);
if (lastId != id) {
includeVideosBucket(result, cursor);
lastId = id;
}
}
} else if (TYPE_VIDEOS_BUCKET.equals(ident.type)) {
// include videos under bucket
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI, VideoQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + ident.id, null, null);
copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext()) {
includeVideo(result, cursor);
}
} else if (TYPE_AUDIO_ROOT.equals(ident.type)) {
/* // include all artists
cursor = resolver.query(Audio.Artists.EXTERNAL_CONTENT_URI,
ArtistQuery.PROJECTION, null, null, null);
copyNotificationUri(result, Artists.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext()) {
includeArtist(result, cursor);
}*/
// include all albums under artist
cursor = resolver.query(Audio.Albums.EXTERNAL_CONTENT_URI, AlbumQuery.PROJECTION, null, null, null);
copyNotificationUri(result, Audio.Albums.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext()) {
includeAlbum(result, cursor);
}
} else if (TYPE_ARTIST.equals(ident.type)) {
// include all albums under artist
cursor = resolver.query(Artists.Albums.getContentUri("external", ident.id), AlbumQuery.PROJECTION, null, null, null);
copyNotificationUri(result, Artists.Albums.getContentUri("external", ident.id));
while (cursor.moveToNext()) {
includeAlbum(result, cursor);
}
} else if (TYPE_ALBUM.equals(ident.type)) {
// include all songs under album
cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI, SongQuery.PROJECTION, AudioColumns.ALBUM_ID + "=" + ident.id, null, null);
copyNotificationUri(result, Audio.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext()) {
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 MediaDocumentsProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
includeImagesRoot(result);
includeVideosRoot(result);
includeAudioRoot(result);
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class NetworkStorageProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final NetworkFile parent = getFileForDocId(parentDocumentId);
final NetworkConnection connection = getNetworkConnection(parentDocumentId);
try {
connection.getConnectedClient().changeWorkingDirectory(parent.getPath());
for (FTPFile file : connection.getConnectedClient().listFiles()) {
includeFile(result, null, new NetworkFile(parent, file));
}
} catch (IOException e) {
CrashReportingManager.logException(e);
}
return result;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor in project AnExplorer by 1hakr.
the class NetworkStorageProvider method queryDocument.
@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
includeFile(result, documentId, null);
return result;
}
Aggregations