VLCRemoteBrowsingTVCell+CloudStorage.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*****************************************************************************
  2. * VLCRemoteBrowsingTVCell+CloudStorage.m
  3. * VLC for tvOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <nitz.carola # googlemail.com>
  9. * Felix Paul Kühne <fkuehne # videolan.org>
  10. *
  11. * Refer to the COPYING file of the official project for license.
  12. *****************************************************************************/
  13. #import "VLCRemoteBrowsingTVCell+CloudStorage.h"
  14. @implementation VLCRemoteBrowsingTVCell (CloudStorage)
  15. - (void)setDropboxFile:(DBFILESMetadata *)dropboxFile
  16. {
  17. [self performSelectorOnMainThread:@selector(_updateDropboxRepresentation:)
  18. withObject:dropboxFile waitUntilDone:NO];
  19. }
  20. - (void)setBoxFile:(BoxItem *)boxFile
  21. {
  22. [self performSelectorOnMainThread:@selector(_updateBoxRepresentation:)
  23. withObject:boxFile waitUntilDone:NO];
  24. }
  25. //- (void)setOneDriveFile:(VLCOneDriveObject *)oneDriveFile
  26. //{
  27. // [self performSelectorOnMainThread:@selector(_updateOneDriveRepresentation:)
  28. // withObject:oneDriveFile waitUntilDone:NO];
  29. //}
  30. - (void)_updateDropboxRepresentation:(DBFILESMetadata *)dropboxFile
  31. {
  32. if (dropboxFile != nil) {
  33. if ([dropboxFile isKindOfClass: [DBFILESFolderMetadata class]]) {
  34. self.isDirectory = YES;
  35. self.thumbnailImage = [UIImage imageNamed:@"folder"];
  36. } else {
  37. DBFILESFileMetadata *file = (DBFILESFileMetadata *)dropboxFile;
  38. self.isDirectory = NO;
  39. self.subtitle = (file.size.integerValue > 0) ? [NSByteCountFormatter stringFromByteCount:file.size.longLongValue countStyle:NSByteCountFormatterCountStyleFile] : @"";
  40. self.thumbnailImage = [UIImage imageNamed:@"folder"];
  41. }
  42. self.title = dropboxFile.name;
  43. }
  44. }
  45. - (void)_updateBoxRepresentation:(BoxItem *)boxFile
  46. {
  47. if (boxFile != nil) {
  48. BOOL isDirectory = [boxFile.type isEqualToString:@"folder"];
  49. if (isDirectory) {
  50. self.isDirectory = YES;
  51. self.thumbnailImage = [UIImage imageNamed:@"folder"];
  52. } else {
  53. self.isDirectory = NO;
  54. self.subtitle = (boxFile.size.intValue > 0) ? [NSByteCountFormatter stringFromByteCount:[boxFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]: @"";
  55. self.thumbnailImage = [UIImage imageNamed:@"blank"];
  56. }
  57. self.title = boxFile.name;
  58. }
  59. }
  60. //- (void)_updateOneDriveRepresentation:(VLCOneDriveObject *)oneDriveFile
  61. //{
  62. // if (oneDriveFile != nil) {
  63. // if (oneDriveFile.isFolder) {
  64. // self.isDirectory = YES;
  65. // self.thumbnailImage = [UIImage imageNamed:@"folder"];
  66. // } else {
  67. // self.isDirectory = NO;
  68. //
  69. // NSMutableString *subtitle = [[NSMutableString alloc] init];
  70. // self.thumbnailImage = [UIImage imageNamed:@"blank"];
  71. //
  72. // if (oneDriveFile.isVideo) {
  73. // NSString *thumbnailURLString = oneDriveFile.thumbnailURL;
  74. // if (thumbnailURLString) {
  75. // [self setThumbnailURL:[NSURL URLWithString:thumbnailURLString]];
  76. // }
  77. // }
  78. //
  79. // if (oneDriveFile.size.intValue > 0) {
  80. // [subtitle appendString:[NSByteCountFormatter stringFromByteCount:[oneDriveFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]];
  81. // if (oneDriveFile.duration.intValue > 0) {
  82. // VLCTime *time = [VLCTime timeWithNumber:oneDriveFile.duration];
  83. // [subtitle appendFormat:@" — %@", [time verboseStringValue]];
  84. // }
  85. // } else if (oneDriveFile.duration.intValue > 0) {
  86. // VLCTime *time = [VLCTime timeWithNumber:oneDriveFile.duration];
  87. // [subtitle appendString:[time verboseStringValue]];
  88. // }
  89. // self.subtitle = subtitle;
  90. // }
  91. // self.title = oneDriveFile.name;
  92. // }
  93. //}
  94. @end