Parcourir la source

GDrive:show thumbnails for files where possible

Carola Nitz il y a 11 ans
Parent
commit
591c3e9974
2 fichiers modifiés avec 17 ajouts et 2 suppressions
  1. 16 1
      Sources/VLCCloudStorageTableViewCell.m
  2. 1 1
      Sources/VLCGoogleDriveController.m

+ 16 - 1
Sources/VLCCloudStorageTableViewCell.m

@@ -12,6 +12,11 @@
  *****************************************************************************/
 
 #import "VLCCloudStorageTableViewCell.h"
+@interface VLCCloudStorageTableViewCell ()
+{
+    NSURL *_iconURL;
+}
+@end
 
 @implementation VLCCloudStorageTableViewCell
 
@@ -80,7 +85,10 @@
             self.titleLabel.hidden = self.subtitleLabel.hidden = NO;
             self.folderTitleLabel.hidden = YES;
         }
-
+        if (_driveFile.thumbnailLink != nil) {
+            _iconURL = [NSURL URLWithString:_driveFile.thumbnailLink];
+            [self performSelectorInBackground:@selector(_updateIconFromURL) withObject:@""];
+        }
         NSString *iconName = self.driveFile.iconLink;
         if ([iconName isEqualToString:@"https://ssl.gstatic.com/docs/doclist/images/icon_11_shared_collection_list.png"] || [iconName isEqualToString:@"https://ssl.gstatic.com/docs/doclist/images/icon_11_collection_list.png"]) {
             self.thumbnailView.image = [UIImage imageNamed:@"folder"];
@@ -97,6 +105,13 @@
     [self setNeedsDisplay];
 }
 
+- (void)_updateIconFromURL
+{
+    NSData* imageData = [[NSData alloc]initWithContentsOfURL:_iconURL];
+    UIImage* image = [[UIImage alloc] initWithData:imageData];
+    self.thumbnailView.image = image;
+}
+
 - (IBAction)triggerDownload:(id)sender
 {
     if ([self.delegate respondsToSelector:@selector(triggerDownloadForCell:)])

+ 1 - 1
Sources/VLCGoogleDriveController.m

@@ -121,7 +121,7 @@
     GTLQueryDrive *query;
 
     query = [GTLQueryDrive queryForFilesList];
-    query.fields = @"items(originalFilename,title,mimeType,fileExtension,fileSize,iconLink,downloadUrl,webContentLink),nextPageToken";
+    query.fields = @"items(originalFilename,title,mimeType,fileExtension,fileSize,iconLink,downloadUrl,webContentLink,thumbnailLink),nextPageToken";
     query.pageToken = _nextPageToken;
     query.maxResults = 100;