Index: ui/file_manager/gallery/js/gallery.js |
diff --git a/ui/file_manager/gallery/js/gallery.js b/ui/file_manager/gallery/js/gallery.js |
index 3ed781726c8ecd712d72aea52728693581152a4f..5588849dbc8bd183615ec0e6c42912a189bf57c1 100644 |
--- a/ui/file_manager/gallery/js/gallery.js |
+++ b/ui/file_manager/gallery/js/gallery.js |
@@ -57,6 +57,11 @@ function Gallery(volumeManager) { |
* @const |
*/ |
this.metadataModel_ = MetadataModel.create(volumeManager); |
+ /** |
+ * @private {!ThumbnailModel} |
+ * @const |
+ */ |
+ this.thumbnailModel_ = new ThumbnailModel(this.metadataModel_); |
this.selectedEntry_ = null; |
this.metadataCacheObserverId_ = null; |
this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this); |
@@ -163,6 +168,8 @@ function Gallery(volumeManager) { |
this.errorBanner_, |
this.dataModel_, |
this.selectionModel_, |
+ this.metadataModel_, |
+ this.thumbnailModel_, |
this.context_, |
this.volumeManager_, |
this.toggleMode_.bind(this), |
@@ -310,12 +317,12 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
// Obtains max chank size. |
var maxChunkSize = 20; |
var volumeInfo = this.volumeManager_.getVolumeInfo(entries[0]); |
- if (volumeInfo && |
- volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP) { |
- maxChunkSize = 1; |
+ if (volumeInfo) { |
+ if (volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP) |
+ maxChunkSize = 1; |
+ if (volumeInfo.isReadOnly) |
+ this.context_.readonlyDirName = volumeInfo.label; |
} |
- if (volumeInfo.isReadOnly) |
- this.context_.readonlyDirName = volumeInfo.label; |
// Make loading list. |
var entrySet = {}; |
@@ -361,17 +368,21 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
var chunk = loadingList.splice(0, maxChunkSize); |
if (!chunk.length) |
return; |
- |
- return new Promise(function(fulfill) { |
+ var entries = chunk.map(function(chunkItem) { |
+ return chunkItem.entry; |
+ }); |
+ var oldMetadataPromise = new Promise(function(fulfill) { |
// Obtains metadata for chunk. |
- var entries = chunk.map(function(chunkItem) { |
- return chunkItem.entry; |
- }); |
self.metadataCache_.get(entries, Gallery.METADATA_TYPE, fulfill); |
}).then(function(metadataList) { |
if (chunk.length !== metadataList.length) |
return Promise.reject('Failed to load metadata.'); |
- |
+ return metadataList; |
+ }); |
+ var metadataPromise = self.metadataModel_.get( |
+ entries, ['imageWidth', 'imageHeight', 'size']); |
+ return Promise.all([oldMetadataPromise, metadataPromise]).then( |
+ function(metadataList) { |
yawano
2015/03/03 04:14:50
very small nit: We uses metadataList in this funct
hirono
2015/03/04 05:07:04
Done.
|
// Remove all the previous items if it's the first chunk. |
// Do it here because prevent a flicker between removing all the items |
// and adding new ones. |
@@ -386,11 +397,13 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry); |
if (!locationInfo) // Skip the item, since gone. |
return; |
- var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]); |
+ var clonedMetadata = |
+ MetadataCache.cloneMetadata(metadataList[0][index]); |
items.push(new Gallery.Item( |
chunkItem.entry, |
locationInfo, |
clonedMetadata, |
+ metadataList[1][index], |
self.metadataCache_, |
self.metadataModel_, |
/* original */ true)); |