Browse Source

onedrive: prevent exceptions

(cherry picked from commit 285dff5176422dd6ac887d24af9b5d9caf4fdd23)
Felix Paul Kühne 10 years ago
parent
commit
cae75e7414
2 changed files with 10 additions and 4 deletions
  1. 4 2
      Sources/VLCCloudStorageTableViewCell.m
  2. 6 2
      Sources/VLCOneDriveTableViewController.m

+ 4 - 2
Sources/VLCCloudStorageTableViewCell.m

@@ -174,8 +174,10 @@
             else if (self.oneDriveFile.isVideo) {
                 self.thumbnailView.image = [UIImage imageNamed:@"movie"];
                 if (_oneDriveFile.thumbnailURL != nil) {
-                    _iconURL = [NSURL URLWithString:_oneDriveFile.thumbnailURL];
-                    [self performSelectorInBackground:@selector(_updateIconFromURL) withObject:@""];
+                    if (_oneDriveFile.thumbnailURL.length > 0) {
+                        _iconURL = [NSURL URLWithString:_oneDriveFile.thumbnailURL];
+                        [self performSelectorInBackground:@selector(_updateIconFromURL) withObject:@""];
+                    }
                 }
             } else
                 self.thumbnailView.image = [UIImage imageNamed:@"blank"];

+ 6 - 2
Sources/VLCOneDriveTableViewController.m

@@ -77,8 +77,12 @@
     if (cell == nil)
         cell = [VLCCloudStorageTableViewCell cellWithReuseIdentifier:CellIdentifier];
 
-    cell.oneDriveFile = _oneDriveController.currentFolder.items[indexPath.row];
-    cell.delegate = self;
+    NSArray *items = _oneDriveController.currentFolder.items;
+
+    if (indexPath.row < items.count) {
+        cell.oneDriveFile = _oneDriveController.currentFolder.items[indexPath.row];
+        cell.delegate = self;
+    }
 
     return cell;
 }