Java Code Examples for android.support.v4.util.ArrayMap#Entry

The following examples show how to use android.support.v4.util.ArrayMap#Entry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsbStorageProvider.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    for (ArrayMap.Entry<String, UsbPartition> root : mRoots.entrySet()) {
        UsbPartition usbPartition = root.getValue();
        UsbDevice usbDevice = usbPartition.device;
        FileSystem fileSystem = usbPartition.fileSystem;
        UsbFile rootDirectory = null;
        String volumeLabel = null;
        Long availableBytes = 0L;
        Long capactityBytes = 0L;
        String documentId = root.getKey() + ROOT_SEPERATOR;

        if(null != fileSystem){
            rootDirectory = fileSystem.getRootDirectory();
            volumeLabel = fileSystem.getVolumeLabel();
            availableBytes = fileSystem.getFreeSpace();
            capactityBytes = fileSystem.getCapacity();
            documentId = getDocIdForFile(rootDirectory);
        }

        String title = UsbUtils.getName(usbDevice);
        if(TextUtils.isEmpty(title)) {
            title = getContext().getString(R.string.root_usb);
        }

        int flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY
                | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_IS_CHILD;

        final MatrixCursor.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, title);
        row.add(Root.COLUMN_FLAGS, flags);
        // These columns are optional
        row.add(Root.COLUMN_SUMMARY, volumeLabel);
        row.add(Root.COLUMN_AVAILABLE_BYTES, availableBytes);
        row.add(Root.COLUMN_CAPACITY_BYTES, capactityBytes);
        row.add(Root.COLUMN_PATH, UsbUtils.getPath(usbDevice));
        // Root.COLUMN_MIME_TYPE is another optional column and useful if you have multiple roots with different
        // types of mime types (roots that don't match the requested mime type are automatically hidden)
    }

    return result;
}
 
Example 2
Source File: UsbStorageProvider.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    for (ArrayMap.Entry<String, UsbPartition> root : mRoots.entrySet()) {
        UsbPartition usbPartition = root.getValue();
        UsbDevice usbDevice = usbPartition.device;
        FileSystem fileSystem = usbPartition.fileSystem;
        UsbFile rootDirectory = null;
        String volumeLabel = null;
        Long availableBytes = 0L;
        Long capactityBytes = 0L;
        String documentId = root.getKey() + ROOT_SEPERATOR;

        if(null != fileSystem){
            rootDirectory = fileSystem.getRootDirectory();
            volumeLabel = fileSystem.getVolumeLabel();
            availableBytes = fileSystem.getFreeSpace();
            capactityBytes = fileSystem.getCapacity();
            documentId = getDocIdForFile(rootDirectory);
        }

        String title = UsbUtils.getName(usbDevice);
        if(TextUtils.isEmpty(title)) {
            title = getContext().getString(R.string.root_usb);
        }

        int flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY
                | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_IS_CHILD;

        final MatrixCursor.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, title);
        row.add(Root.COLUMN_FLAGS, flags);
        // These columns are optional
        row.add(Root.COLUMN_SUMMARY, volumeLabel);
        row.add(Root.COLUMN_AVAILABLE_BYTES, availableBytes);
        row.add(Root.COLUMN_CAPACITY_BYTES, capactityBytes);
        row.add(Root.COLUMN_PATH, UsbUtils.getPath(usbDevice));
        // Root.COLUMN_MIME_TYPE is another optional column and useful if you have multiple roots with different
        // types of mime types (roots that don't match the requested mime type are automatically hidden)
    }

    return result;
}
 
Example 3
Source File: UsbStorageProvider.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    for (ArrayMap.Entry<String, UsbPartition> root : mRoots.entrySet()) {
        UsbPartition usbPartition = root.getValue();
        UsbDevice usbDevice = usbPartition.device;
        FileSystem fileSystem = usbPartition.fileSystem;
        UsbFile rootDirectory = null;
        String volumeLabel = null;
        Long availableBytes = 0L;
        Long capactityBytes = 0L;
        String documentId = root.getKey() + ROOT_SEPERATOR;

        if(null != fileSystem){
            rootDirectory = fileSystem.getRootDirectory();
            volumeLabel = fileSystem.getVolumeLabel();
            availableBytes = fileSystem.getFreeSpace();
            capactityBytes = fileSystem.getCapacity();
            documentId = getDocIdForFile(rootDirectory);
        }

        String title = UsbUtils.getName(usbDevice);
        if(TextUtils.isEmpty(title)) {
            title = getContext().getString(R.string.root_usb);
        }

        int flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY
                | Root.FLAG_ADVANCED | Root.FLAG_SUPPORTS_IS_CHILD;

        final MatrixCursor.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, title);
        row.add(Root.COLUMN_FLAGS, flags);
        // These columns are optional
        row.add(Root.COLUMN_SUMMARY, volumeLabel);
        row.add(Root.COLUMN_AVAILABLE_BYTES, availableBytes);
        row.add(Root.COLUMN_CAPACITY_BYTES, capactityBytes);
        row.add(Root.COLUMN_PATH, UsbUtils.getPath(usbDevice));
        // Root.COLUMN_MIME_TYPE is another optional column and useful if you have multiple roots with different
        // types of mime types (roots that don't match the requested mime type are automatically hidden)
    }

    return result;
}