Search in sources :

Example 11 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeVideo.

private void includeVideo(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(VideoQuery._ID);
    final String docId = getDocIdForIdent(TYPE_VIDEO, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(VideoQuery.DISPLAY_NAME));
    row.add(Document.COLUMN_SIZE, cursor.getLong(VideoQuery.SIZE));
    row.add(Document.COLUMN_MIME_TYPE, cursor.getString(VideoQuery.MIME_TYPE));
    row.add(Document.COLUMN_PATH, cursor.getString(VideoQuery.DATA));
    row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(VideoQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_SUPPORTS_DELETE);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 12 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeImagesRoot.

private void includeImagesRoot(MatrixCursor result) {
    int flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS;
    if (isEmpty(Images.Media.EXTERNAL_CONTENT_URI)) {
        flags |= Root.FLAG_EMPTY;
        sReturnedImagesEmpty = true;
    }
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, TYPE_IMAGES_ROOT);
    row.add(Root.COLUMN_FLAGS, flags);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_images));
    row.add(Root.COLUMN_DOCUMENT_ID, TYPE_IMAGES_ROOT);
    row.add(Root.COLUMN_MIME_TYPES, IMAGE_MIME_TYPES);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) Point(android.graphics.Point)

Example 13 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeImage.

private void includeImage(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(ImageQuery._ID);
    final String docId = getDocIdForIdent(TYPE_IMAGE, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(ImageQuery.DISPLAY_NAME));
    row.add(Document.COLUMN_SIZE, cursor.getLong(ImageQuery.SIZE));
    row.add(Document.COLUMN_MIME_TYPE, cursor.getString(ImageQuery.MIME_TYPE));
    row.add(Document.COLUMN_PATH, cursor.getString(ImageQuery.DATA));
    row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(ImageQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_SUPPORTS_DELETE);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 14 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeImagesRootDocument.

private void includeImagesRootDocument(MatrixCursor result) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, TYPE_IMAGES_ROOT);
    row.add(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_images));
    row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID | Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_SUPPORTS_DELETE);
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 15 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class NetworkStorageProvider method includeFile.

/**
 * Add a representation of a file to a cursor.
 *
 * @param result the cursor to modify
 * @param docId  the document ID representing the desired file (may be null if given file)
 * @param file   the File object representing the desired file (may be null if given docID)
 * @throws java.io.FileNotFoundException
 */
private void includeFile(MatrixCursor result, String docId, NetworkFile file) throws FileNotFoundException {
    if (docId == null) {
        docId = getDocIdForFile(file);
    } else {
        file = getFileForDocId(docId);
    }
    int flags = 0;
    if (file.canWrite()) {
        if (file.isDirectory()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
        } else {
            flags |= Document.FLAG_SUPPORTS_WRITE;
        }
    /*            flags |= Document.FLAG_SUPPORTS_DELETE;
            flags |= Document.FLAG_SUPPORTS_RENAME;
            flags |= Document.FLAG_SUPPORTS_MOVE;
            flags |= Document.FLAG_SUPPORTS_EDIT;*/
    }
    final String mimeType = getTypeForFile(file);
    final String displayName = file.getName();
    if (!TextUtils.isEmpty(displayName)) {
        if (displayName.charAt(0) == '.') {
            return;
        }
    }
    if (MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType)) {
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    }
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, displayName);
    row.add(Document.COLUMN_SIZE, file.getSize());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_PATH, file.getAbsolutePath());
    row.add(Document.COLUMN_FLAGS, flags);
    // Only publish dates reasonably after epoch
    long lastModified = file.lastModified();
    if (lastModified > 31536000000L) {
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
    }
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Aggregations

RowBuilder (dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)34 Point (android.graphics.Point)11 SuppressLint (android.annotation.SuppressLint)7 MatrixCursor (dev.dworks.apps.anexplorer.cursor.MatrixCursor)7 ApplicationInfo (android.content.pm.ApplicationInfo)4 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 DocumentFile (android.support.provider.DocumentFile)2 ArrayMap (android.support.v4.util.ArrayMap)1 FileUtils.getTypeForFile (dev.dworks.apps.anexplorer.misc.FileUtils.getTypeForFile)1 StorageUtils (dev.dworks.apps.anexplorer.misc.StorageUtils)1 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)1 NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)1 Map (java.util.Map)1