本文整理匯總了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();
}
}
}