VLCGoogleDriveTableViewCell.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // VLCGoogleDriveTableViewCell.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 24.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCGoogleDriveTableViewCell.h"
  11. @implementation VLCGoogleDriveTableViewCell
  12. + (VLCGoogleDriveTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
  13. {
  14. NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCGoogleDriveTableViewCell" owner:nil options:nil];
  15. NSAssert([nibContentArray count] == 1, @"meh");
  16. NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCGoogleDriveTableViewCell class]], @"meh meh");
  17. VLCGoogleDriveTableViewCell *cell = (VLCGoogleDriveTableViewCell *)[nibContentArray lastObject];
  18. return cell;
  19. }
  20. - (void)setDriveFile:(GTLDriveFile *)driveFile
  21. {
  22. if (driveFile != _driveFile)
  23. _driveFile = driveFile;
  24. [self _updatedDisplayedInformation];
  25. }
  26. - (void)_updatedDisplayedInformation
  27. {
  28. BOOL isDirectory = [self.driveFile.mimeType isEqualToString:@"application/vnd.google-apps.folder"];
  29. if (isDirectory) {
  30. self.folderTitleLabel.text = self.driveFile.title;
  31. self.titleLabel.text = @"";
  32. self.subtitleLabel.text = @"";
  33. } else {
  34. self.titleLabel.text = self.driveFile.title;
  35. self.subtitleLabel.text = (self.driveFile.fileSize > 0) ? [NSByteCountFormatter stringFromByteCount:[self.driveFile.fileSize longLongValue] countStyle:NSByteCountFormatterCountStyleFile]: @"";
  36. self.folderTitleLabel.text = @"";
  37. }
  38. NSString *iconName = self.driveFile.iconLink;
  39. 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"]) {
  40. self.thumbnailView.image = [UIImage imageNamed:@"folder"];
  41. } else if ([iconName isEqualToString:@"https://ssl.gstatic.com/docs/doclist/images/icon_10_audio_list.png"]) {
  42. self.thumbnailView.image = [UIImage imageNamed:@"blank"];
  43. } else if ([iconName isEqualToString:@"https://ssl.gstatic.com/docs/doclist/images/icon_11_video_list.png"]) {
  44. self.thumbnailView.image = [UIImage imageNamed:@"movie"];
  45. } else {
  46. self.thumbnailView.image = [UIImage imageNamed:@"blank"];
  47. APLog(@"missing icon for type '%@'", self.driveFile.iconLink);
  48. }
  49. [self setNeedsDisplay];
  50. }
  51. + (CGFloat)heightOfCell
  52. {
  53. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  54. return 80.;
  55. return 48.;
  56. }
  57. @end