Java Code Examples for com.example.android.common.logger.Log#v()

The following examples show how to use com.example.android.common.logger.Log#v() . 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: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 6 votes vote down vote up
@Override
public String createDocument(String documentId, String mimeType, String displayName)
        throws FileNotFoundException {
    Log.v(TAG, "createDocument");

    File parent = getFileForDocId(documentId);
    File file = new File(parent.getPath(), displayName);
    try {
        file.createNewFile();
        file.setWritable(true);
        file.setReadable(true);
    } catch (IOException e) {
        throw new FileNotFoundException("Failed to create document with name " +
                displayName +" and documentId " + documentId);
    }
    return getDocIdForFile(file);
}
 
Example 2
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 6 votes vote down vote up
@Override
public String createDocument(String documentId, String mimeType, String displayName)
        throws FileNotFoundException {
    Log.v(TAG, "createDocument");

    File parent = getFileForDocId(documentId);
    File file = new File(parent.getPath(), displayName);
    try {
        file.createNewFile();
        file.setWritable(true);
        file.setReadable(true);
    } catch (IOException e) {
        throw new FileNotFoundException("Failed to create document with name " +
                displayName +" and documentId " + documentId);
    }
    return getDocIdForFile(file);
}
 
Example 3
Source File: PermissionRequestFragment.java    From android-PermissionRequest with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onConsoleMessage(@NonNull ConsoleMessage message) {
    switch (message.messageLevel()) {
        case TIP:
            Log.v(TAG, message.message());
            break;
        case LOG:
            Log.i(TAG, message.message());
            break;
        case WARNING:
            Log.w(TAG, message.message());
            break;
        case ERROR:
            Log.e(TAG, message.message());
            break;
        case DEBUG:
            Log.d(TAG, message.message());
            break;
    }
    if (null != mConsoleMonitor) {
        mConsoleMonitor.onConsoleMessage(message);
    }
    return true;
}
 
Example 4
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
    Log.v(TAG, "deleteDocument");
    File file = getFileForDocId(documentId);
    if (file.delete()) {
        Log.i(TAG, "Deleted file with id " + documentId);
    } else {
        throw new FileNotFoundException("Failed to delete document with id " + documentId);
    }
}
 
Example 5
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
                                  String sortOrder) throws FileNotFoundException {
    Log.v(TAG, "queryChildDocuments, parentDocumentId: " +
            parentDocumentId +
            " sortOrder: " +
            sortOrder);

    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final File parent = getFileForDocId(parentDocumentId);
    for (File file : parent.listFiles()) {
        includeFile(result, null, file);
    }
    return result;
}
 
Example 6
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor queryDocument(String documentId, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "queryDocument");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, null);
    return result;
}
 
Example 7
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint,
                                                 CancellationSignal signal)
        throws FileNotFoundException {
    Log.v(TAG, "openDocumentThumbnail");

    final File file = getFileForDocId(documentId);
    final ParcelFileDescriptor pfd =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
}
 
Example 8
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "querySearchDocuments");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final File parent = getFileForDocId(rootId);

    // This example implementation searches file names for the query and doesn't rank search
    // results, so we can stop as soon as we find a sufficient number of matches.  Other
    // implementations might use other data about files, rather than the file name, to
    // produce a match; it might also require a network call to query a remote server.

    // Iterate through all files in the file structure under the root until we reach the
    // desired number of matches.
    final LinkedList<File> pending = new LinkedList<File>();

    // Start by adding the parent to the list of files to be processed
    pending.add(parent);

    // Do while we still have unexamined files, and fewer than the max search results
    while (!pending.isEmpty() && result.getCount() < MAX_SEARCH_RESULTS) {
        // Take a file from the list of unprocessed files
        final File file = pending.removeFirst();
        if (file.isDirectory()) {
            // If it's a directory, add all its children to the unprocessed list
            Collections.addAll(pending, file.listFiles());
        } else {
            // If it's a file and it matches, add it to the result cursor.
            if (file.getName().toLowerCase().contains(query)) {
                includeFile(result, null, file);
            }
        }
    }
    return result;
}
 
Example 9
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
    Log.v(TAG, "deleteDocument");
    File file = getFileForDocId(documentId);
    if (file.delete()) {
        Log.i(TAG, "Deleted file with id " + documentId);
    } else {
        throw new FileNotFoundException("Failed to delete document with id " + documentId);
    }
}
 
Example 10
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
                                  String sortOrder) throws FileNotFoundException {
    Log.v(TAG, "queryChildDocuments, parentDocumentId: " +
            parentDocumentId +
            " sortOrder: " +
            sortOrder);

    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final File parent = getFileForDocId(parentDocumentId);
    for (File file : parent.listFiles()) {
        includeFile(result, null, file);
    }
    return result;
}
 
Example 11
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor queryDocument(String documentId, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "queryDocument");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, null);
    return result;
}
 
Example 12
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint,
                                                 CancellationSignal signal)
        throws FileNotFoundException {
    Log.v(TAG, "openDocumentThumbnail");

    final File file = getFileForDocId(documentId);
    final ParcelFileDescriptor pfd =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
}
 
Example 13
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "querySearchDocuments");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final File parent = getFileForDocId(rootId);

    // This example implementation searches file names for the query and doesn't rank search
    // results, so we can stop as soon as we find a sufficient number of matches.  Other
    // implementations might use other data about files, rather than the file name, to
    // produce a match; it might also require a network call to query a remote server.

    // Iterate through all files in the file structure under the root until we reach the
    // desired number of matches.
    final LinkedList<File> pending = new LinkedList<File>();

    // Start by adding the parent to the list of files to be processed
    pending.add(parent);

    // Do while we still have unexamined files, and fewer than the max search results
    while (!pending.isEmpty() && result.getCount() < MAX_SEARCH_RESULTS) {
        // Take a file from the list of unprocessed files
        final File file = pending.removeFirst();
        if (file.isDirectory()) {
            // If it's a directory, add all its children to the unprocessed list
            Collections.addAll(pending, file.listFiles());
        } else {
            // If it's a file and it matches, add it to the result cursor.
            if (file.getName().toLowerCase().contains(query)) {
                includeFile(result, null, file);
            }
        }
    }
    return result;
}
 
Example 14
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    Log.v(TAG, "queryRoots");

    // Create a cursor with either the requested fields, or the default projection.  This
    // cursor is returned to the Android system picker UI and used to display all roots from
    // this provider.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    // If user is not logged in, return an empty root cursor.  This removes our provider from
    // the list entirely.
    if (!isUserLoggedIn()) {
        return result;
    }

    // It's possible to have multiple roots (e.g. for multiple accounts in the same app) -
    // just add multiple cursor rows.
    // Construct one row for a root called "MyCloud".
    final MatrixCursor.RowBuilder row = result.newRow();

    row.add(Root.COLUMN_ROOT_ID, ROOT);
    row.add(Root.COLUMN_SUMMARY, getContext().getString(R.string.root_summary));

    // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating
    // documents.  FLAG_SUPPORTS_RECENTS means your application's most recently used
    // documents will show up in the "Recents" category.  FLAG_SUPPORTS_SEARCH allows users
    // to search all documents the application shares.
    row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE |
            Root.FLAG_SUPPORTS_RECENTS |
            Root.FLAG_SUPPORTS_SEARCH);

    // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider).
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.app_name));

    // This document id must be unique within this provider and consistent across time.  The
    // system picker UI may save it and refer to it later.
    row.add(Root.COLUMN_DOCUMENT_ID, getDocIdForFile(mBaseDir));

    // The child MIME types are used to filter the roots and only present to the user roots
    // that contain the desired type somewhere in their file hierarchy.
    row.add(Root.COLUMN_MIME_TYPES, getChildMimeTypes(mBaseDir));
    row.add(Root.COLUMN_AVAILABLE_BYTES, mBaseDir.getFreeSpace());
    row.add(Root.COLUMN_ICON, R.drawable.ic_launcher);

    return result;
}
 
Example 15
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    Log.v(TAG, "queryRoots");

    // Create a cursor with either the requested fields, or the default projection.  This
    // cursor is returned to the Android system picker UI and used to display all roots from
    // this provider.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    // If user is not logged in, return an empty root cursor.  This removes our provider from
    // the list entirely.
    if (!isUserLoggedIn()) {
        return result;
    }

    // It's possible to have multiple roots (e.g. for multiple accounts in the same app) -
    // just add multiple cursor rows.
    // Construct one row for a root called "MyCloud".
    final MatrixCursor.RowBuilder row = result.newRow();

    row.add(Root.COLUMN_ROOT_ID, ROOT);
    row.add(Root.COLUMN_SUMMARY, getContext().getString(R.string.root_summary));

    // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating
    // documents.  FLAG_SUPPORTS_RECENTS means your application's most recently used
    // documents will show up in the "Recents" category.  FLAG_SUPPORTS_SEARCH allows users
    // to search all documents the application shares.
    row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE |
            Root.FLAG_SUPPORTS_RECENTS |
            Root.FLAG_SUPPORTS_SEARCH);

    // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider).
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.app_name));

    // This document id must be unique within this provider and consistent across time.  The
    // system picker UI may save it and refer to it later.
    row.add(Root.COLUMN_DOCUMENT_ID, getDocIdForFile(mBaseDir));

    // The child MIME types are used to filter the roots and only present to the user roots
    // that contain the desired type somewhere in their file hierarchy.
    row.add(Root.COLUMN_MIME_TYPES, getChildMimeTypes(mBaseDir));
    row.add(Root.COLUMN_AVAILABLE_BYTES, mBaseDir.getFreeSpace());
    row.add(Root.COLUMN_ICON, R.drawable.ic_launcher);

    return result;
}
 
Example 16
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 3 votes vote down vote up
@Override
public boolean onCreate() {
    Log.v(TAG, "onCreate");

    mBaseDir = getContext().getFilesDir();

    writeDummyFilesToStorage();

    return true;
}
 
Example 17
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 3 votes vote down vote up
@Override
public boolean onCreate() {
    Log.v(TAG, "onCreate");

    mBaseDir = getContext().getFilesDir();

    writeDummyFilesToStorage();

    return true;
}