VLCDropboxTableViewCell.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // VLCDropboxTableViewCell.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 "VLCDropboxTableViewCell.h"
  11. @implementation VLCDropboxTableViewCell
  12. + (VLCDropboxTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
  13. {
  14. NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCDropboxTableViewCell" owner:nil options:nil];
  15. NSAssert([nibContentArray count] == 1, @"meh");
  16. NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCDropboxTableViewCell class]], @"meh meh");
  17. VLCDropboxTableViewCell *cell = (VLCDropboxTableViewCell *)[nibContentArray lastObject];
  18. return cell;
  19. }
  20. - (void)setFileMetadata:(DBMetadata *)fileMetadata
  21. {
  22. if (fileMetadata != _fileMetadata)
  23. _fileMetadata = fileMetadata;
  24. [self _updatedDisplayedInformation];
  25. }
  26. - (void)_updatedDisplayedInformation
  27. {
  28. if (self.fileMetadata.isDirectory) {
  29. self.folderTitleLabel.text = self.fileMetadata.filename;
  30. self.titleLabel.text = @"";
  31. self.subtitleLabel.text = @"";
  32. } else {
  33. self.titleLabel.text = self.fileMetadata.filename;
  34. self.subtitleLabel.text = (self.fileMetadata.totalBytes > 0) ? self.fileMetadata.humanReadableSize : @"";
  35. self.folderTitleLabel.text = @"";
  36. }
  37. self.downloadButton.hidden = NO;
  38. NSString *iconName = self.fileMetadata.icon;
  39. if ([iconName isEqualToString:@"folder_user"] || [iconName isEqualToString:@"folder"] || [iconName isEqualToString:@"folder_public"] || [iconName isEqualToString:@"folder_photos"] || [iconName isEqualToString:@"package"]) {
  40. self.thumbnailView.image = [UIImage imageNamed:@"folder"];
  41. self.downloadButton.hidden = YES;
  42. } else if ([iconName isEqualToString:@"page_white"] || [iconName isEqualToString:@"page_white_text"])
  43. self.thumbnailView.image = [UIImage imageNamed:@"blank"];
  44. else if ([iconName isEqualToString:@"page_white_film"])
  45. self.thumbnailView.image = [UIImage imageNamed:@"movie"];
  46. else
  47. APLog(@"missing icon for type '%@'", self.fileMetadata.icon);
  48. [self setNeedsDisplay];
  49. }
  50. - (IBAction)triggerDownload:(id)sender
  51. {
  52. if ([self.delegate respondsToSelector:@selector(triggerDownloadForCell:)])
  53. [self.delegate triggerDownloadForCell:self];
  54. }
  55. + (CGFloat)heightOfCell
  56. {
  57. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  58. return 80.;
  59. return 48.;
  60. }
  61. @end