Methods Summary |
---|
public static java.io.FileNotFoundException | asFileNotFoundException(java.lang.Throwable t)
if (t instanceof FileNotFoundException) {
throw (FileNotFoundException) t;
}
final FileNotFoundException fnfe = new FileNotFoundException(t.getMessage());
fnfe.initCause(t);
throw fnfe;
|
public static int | compareToIgnoreCaseNullable(java.lang.String lhs, java.lang.String rhs)Compare two strings against each other using system default collator in a
case-insensitive mode. Clusters strings prefixed with {@link #DIR_PREFIX}
before other items.
final boolean leftEmpty = TextUtils.isEmpty(lhs);
final boolean rightEmpty = TextUtils.isEmpty(rhs);
if (leftEmpty && rightEmpty) return 0;
if (leftEmpty) return -1;
if (rightEmpty) return 1;
final boolean leftDir = (lhs.charAt(0) == DIR_PREFIX);
final boolean rightDir = (rhs.charAt(0) == DIR_PREFIX);
if (leftDir && !rightDir) return -1;
if (rightDir && !leftDir) return 1;
return sCollator.compare(lhs, rhs);
|
private void | deriveFields()
derivedUri = DocumentsContract.buildDocumentUri(authority, documentId);
|
public int | describeContents()
return 0;
|
public static com.android.documentsui.model.DocumentInfo | fromCursor(android.database.Cursor cursor, java.lang.String authority)
final DocumentInfo info = new DocumentInfo();
info.updateFromCursor(cursor, authority);
return info;
|
public static com.android.documentsui.model.DocumentInfo | fromDirectoryCursor(android.database.Cursor cursor)
final String authority = getCursorString(cursor, RootCursorWrapper.COLUMN_AUTHORITY);
return fromCursor(cursor, authority);
|
public static com.android.documentsui.model.DocumentInfo | fromUri(android.content.ContentResolver resolver, android.net.Uri uri)
final DocumentInfo info = new DocumentInfo();
info.updateFromUri(resolver, uri);
return info;
|
public static int | getCursorInt(android.database.Cursor cursor, java.lang.String columnName)Missing or null values are returned as 0.
final int index = cursor.getColumnIndex(columnName);
return (index != -1) ? cursor.getInt(index) : 0;
|
public static long | getCursorLong(android.database.Cursor cursor, java.lang.String columnName)Missing or null values are returned as -1.
final int index = cursor.getColumnIndex(columnName);
if (index == -1) return -1;
final String value = cursor.getString(index);
if (value == null) return -1;
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
return -1;
}
|
public static java.lang.String | getCursorString(android.database.Cursor cursor, java.lang.String columnName)
final int index = cursor.getColumnIndex(columnName);
return (index != -1) ? cursor.getString(index) : null;
|
public boolean | isCreateSupported()
return (flags & Document.FLAG_DIR_SUPPORTS_CREATE) != 0;
|
public boolean | isDeleteSupported()
return (flags & Document.FLAG_SUPPORTS_DELETE) != 0;
|
public boolean | isDirectory()
return Document.MIME_TYPE_DIR.equals(mimeType);
|
public boolean | isGridPreferred()
return (flags & Document.FLAG_DIR_PREFERS_GRID) != 0;
|
public boolean | isGridTitlesHidden()
return (flags & Document.FLAG_DIR_HIDE_GRID_TITLES) != 0;
|
public boolean | isThumbnailSupported()
return (flags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
|
public void | read(java.io.DataInputStream in)
final int version = in.readInt();
switch (version) {
case VERSION_INIT:
throw new ProtocolException("Ignored upgrade");
case VERSION_SPLIT_URI:
authority = DurableUtils.readNullableString(in);
documentId = DurableUtils.readNullableString(in);
mimeType = DurableUtils.readNullableString(in);
displayName = DurableUtils.readNullableString(in);
lastModified = in.readLong();
flags = in.readInt();
summary = DurableUtils.readNullableString(in);
size = in.readLong();
icon = in.readInt();
deriveFields();
break;
default:
throw new ProtocolException("Unknown version " + version);
}
|
public void | reset()
authority = null;
documentId = null;
mimeType = null;
displayName = null;
lastModified = -1;
flags = 0;
summary = null;
size = -1;
icon = 0;
derivedUri = null;
|
public java.lang.String | toString()
return "Document{docId=" + documentId + ", name=" + displayName + "}";
|
public void | updateFromCursor(android.database.Cursor cursor, java.lang.String authority)
this.authority = authority;
this.documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID);
this.mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
this.documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID);
this.mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
this.displayName = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME);
this.lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
this.flags = getCursorInt(cursor, Document.COLUMN_FLAGS);
this.summary = getCursorString(cursor, Document.COLUMN_SUMMARY);
this.size = getCursorLong(cursor, Document.COLUMN_SIZE);
this.icon = getCursorInt(cursor, Document.COLUMN_ICON);
this.deriveFields();
|
public void | updateFromUri(android.content.ContentResolver resolver, android.net.Uri uri)
ContentProviderClient client = null;
Cursor cursor = null;
try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(
resolver, uri.getAuthority());
cursor = client.query(uri, null, null, null, null);
if (!cursor.moveToFirst()) {
throw new FileNotFoundException("Missing details for " + uri);
}
updateFromCursor(cursor, uri.getAuthority());
} catch (Throwable t) {
throw asFileNotFoundException(t);
} finally {
IoUtils.closeQuietly(cursor);
ContentProviderClient.releaseQuietly(client);
}
|
public void | updateSelf(android.content.ContentResolver resolver)Update a possibly stale restored document against a live
{@link DocumentsProvider}.
updateFromUri(resolver, derivedUri);
|
public void | write(java.io.DataOutputStream out)
out.writeInt(VERSION_SPLIT_URI);
DurableUtils.writeNullableString(out, authority);
DurableUtils.writeNullableString(out, documentId);
DurableUtils.writeNullableString(out, mimeType);
DurableUtils.writeNullableString(out, displayName);
out.writeLong(lastModified);
out.writeInt(flags);
DurableUtils.writeNullableString(out, summary);
out.writeLong(size);
out.writeInt(icon);
|
public void | writeToParcel(android.os.Parcel dest, int flags)
DurableUtils.writeToParcel(dest, this);
|