当前位置: 首页>>代码示例>>Java>>正文


Java MtpConstants类代码示例

本文整理汇总了Java中android.mtp.MtpConstants的典型用法代码示例。如果您正苦于以下问题:Java MtpConstants类的具体用法?Java MtpConstants怎么用?Java MtpConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MtpConstants类属于android.mtp包,在下文中一共展示了MtpConstants类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: indexDevice

import android.mtp.MtpConstants; //导入依赖的package包/类
private void indexDevice() throws IndexingException {
    synchronized (MtpDeviceIndex.this) {
        mProgress = Progress.Started;
    }
    mBucketsTemp = new HashMap<SimpleDate, DateBucket>();
    for (int storageId : mDevice.getStorageIds()) {
        if (mDevice != getDevice()) throw new IndexingException();
        Stack<Integer> pendingDirectories = new Stack<Integer>();
        pendingDirectories.add(0xFFFFFFFF); // start at the root of the device
        while (!pendingDirectories.isEmpty()) {
            if (mDevice != getDevice()) throw new IndexingException();
            int dirHandle = pendingDirectories.pop();
            for (int objectHandle : mDevice.getObjectHandles(storageId, 0, dirHandle)) {
                MtpObjectInfo objectInfo = mDevice.getObjectInfo(objectHandle);
                if (objectInfo == null) throw new IndexingException();
                int format = objectInfo.getFormat();
                if (format == MtpConstants.FORMAT_ASSOCIATION) {
                    pendingDirectories.add(objectHandle);
                } else if (SUPPORTED_IMAGE_FORMATS.contains(format)
                        || SUPPORTED_VIDEO_FORMATS.contains(format)) {
                    addObject(objectInfo);
                }
            }
        }
    }
    Collection<DateBucket> values = mBucketsTemp.values();
    mBucketsTemp = null;
    mBuckets = values.toArray(new DateBucket[values.size()]);
    values = null;
    synchronized (MtpDeviceIndex.this) {
        mProgress = Progress.Sorting;
        if (mProgressListener != null) {
            mProgressListener.onSorting();
        }
    }
    sortAll();
    buildLookupIndex();
    synchronized (MtpDeviceIndex.this) {
        if (mDevice != getDevice()) throw new IndexingException();
        copyResults();

        /*
         * In order for getBuckets to operate in constant time for descending
         * order, we must precompute a reversed array of the buckets, mainly
         * because the android.widget.SectionIndexer interface which adapters
         * that call getBuckets implement depends on section numbers to be
         * ascending relative to the scroll position, so we must have this for
         * descending order or the scrollbar goes crazy.
         */
        computeReversedBuckets();

        mProgress = Progress.Finished;
        if (mProgressListener != null) {
            mProgressListener.onIndexFinish();
        }
    }
}
 
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:58,代码来源:MtpDeviceIndex.java


注:本文中的android.mtp.MtpConstants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。