FileDocCategorySizeDatePackage
RootInfo.javaAPI DocAndroid 5.1 API8382Thu Mar 12 22:22:40 GMT 2015com.android.documentsui.model

RootInfo

public class RootInfo extends Object implements Durable, android.os.Parcelable
Representation of a {@link Root}.

Fields Summary
private static final int
VERSION_INIT
private static final int
VERSION_DROP_TYPE
public String
authority
public String
rootId
public int
flags
public int
icon
public String
title
public String
summary
public String
documentId
public long
availableBytes
public String
mimeTypes
public String
derivedPackageName
Derived fields that aren't persisted
public String[]
derivedMimeTypes
public int
derivedIcon
public static final Creator
CREATOR
Constructors Summary
public RootInfo()


      
        reset();
    
Methods Summary
private voidderiveFields()

        derivedMimeTypes = (mimeTypes != null) ? mimeTypes.split("\n") : null;

        // TODO: remove these special case icons
        if (isExternalStorage()) {
            derivedIcon = R.drawable.ic_root_sdcard;
        } else if (isDownloads()) {
            derivedIcon = R.drawable.ic_root_download;
        } else if (isImages()) {
            derivedIcon = R.drawable.ic_doc_image;
        } else if (isVideos()) {
            derivedIcon = R.drawable.ic_doc_video;
        } else if (isAudio()) {
            derivedIcon = R.drawable.ic_doc_audio;
        }
    
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object o)

        if (o instanceof RootInfo) {
            final RootInfo root = (RootInfo) o;
            return Objects.equals(authority, root.authority) && Objects.equals(rootId, root.rootId);
        } else {
            return false;
        }
    
public static com.android.documentsui.model.RootInfofromRootsCursor(java.lang.String authority, android.database.Cursor cursor)


           
        final RootInfo root = new RootInfo();
        root.authority = authority;
        root.rootId = getCursorString(cursor, Root.COLUMN_ROOT_ID);
        root.flags = getCursorInt(cursor, Root.COLUMN_FLAGS);
        root.icon = getCursorInt(cursor, Root.COLUMN_ICON);
        root.title = getCursorString(cursor, Root.COLUMN_TITLE);
        root.summary = getCursorString(cursor, Root.COLUMN_SUMMARY);
        root.documentId = getCursorString(cursor, Root.COLUMN_DOCUMENT_ID);
        root.availableBytes = getCursorLong(cursor, Root.COLUMN_AVAILABLE_BYTES);
        root.mimeTypes = getCursorString(cursor, Root.COLUMN_MIME_TYPES);
        root.deriveFields();
        return root;
    
public java.lang.StringgetDirectoryString()

        return !TextUtils.isEmpty(summary) ? summary : title;
    
public inthashCode()

        return Objects.hash(authority, rootId);
    
public booleanisAudio()

        return "com.android.providers.media.documents".equals(authority)
                && "audio_root".equals(rootId);
    
public booleanisDownloads()

        return "com.android.providers.downloads.documents".equals(authority);
    
public booleanisExternalStorage()

        return "com.android.externalstorage.documents".equals(authority);
    
public booleanisImages()

        return "com.android.providers.media.documents".equals(authority)
                && "images_root".equals(rootId);
    
public booleanisRecents()

        return authority == null && rootId == null;
    
public booleanisVideos()

        return "com.android.providers.media.documents".equals(authority)
                && "videos_root".equals(rootId);
    
public android.graphics.drawable.DrawableloadDrawerIcon(android.content.Context context)

        if (derivedIcon != 0) {
            return IconUtils.applyTintColor(context, derivedIcon, R.color.item_root_icon);
        } else {
            return IconUtils.loadPackageIcon(context, authority, icon);
        }
    
public android.graphics.drawable.DrawableloadGridIcon(android.content.Context context)

        if (derivedIcon != 0) {
            return IconUtils.applyTintAttr(context, derivedIcon,
                    android.R.attr.textColorPrimaryInverse);
        } else {
            return IconUtils.loadPackageIcon(context, authority, icon);
        }
    
public android.graphics.drawable.DrawableloadIcon(android.content.Context context)

        if (derivedIcon != 0) {
            return context.getDrawable(derivedIcon);
        } else {
            return IconUtils.loadPackageIcon(context, authority, icon);
        }
    
public android.graphics.drawable.DrawableloadToolbarIcon(android.content.Context context)

        if (derivedIcon != 0) {
            return IconUtils.applyTintAttr(context, derivedIcon,
                    android.R.attr.colorControlNormal);
        } else {
            return IconUtils.loadPackageIcon(context, authority, icon);
        }
    
public voidread(java.io.DataInputStream in)

        final int version = in.readInt();
        switch (version) {
            case VERSION_DROP_TYPE:
                authority = DurableUtils.readNullableString(in);
                rootId = DurableUtils.readNullableString(in);
                flags = in.readInt();
                icon = in.readInt();
                title = DurableUtils.readNullableString(in);
                summary = DurableUtils.readNullableString(in);
                documentId = DurableUtils.readNullableString(in);
                availableBytes = in.readLong();
                mimeTypes = DurableUtils.readNullableString(in);
                deriveFields();
                break;
            default:
                throw new ProtocolException("Unknown version " + version);
        }
    
public voidreset()

        authority = null;
        rootId = null;
        flags = 0;
        icon = 0;
        title = null;
        summary = null;
        documentId = null;
        availableBytes = -1;
        mimeTypes = null;

        derivedPackageName = null;
        derivedMimeTypes = null;
        derivedIcon = 0;
    
public java.lang.StringtoString()

        return "Root{authority=" + authority + ", rootId=" + rootId + ", title=" + title + "}";
    
public voidwrite(java.io.DataOutputStream out)

        out.writeInt(VERSION_DROP_TYPE);
        DurableUtils.writeNullableString(out, authority);
        DurableUtils.writeNullableString(out, rootId);
        out.writeInt(flags);
        out.writeInt(icon);
        DurableUtils.writeNullableString(out, title);
        DurableUtils.writeNullableString(out, summary);
        DurableUtils.writeNullableString(out, documentId);
        out.writeLong(availableBytes);
        DurableUtils.writeNullableString(out, mimeTypes);
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        DurableUtils.writeToParcel(dest, this);