VLCDropboxTableViewCell.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #import "VLCDropboxTableViewCell.h"
  9. @implementation VLCDropboxTableViewCell
  10. + (VLCDropboxTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
  11. {
  12. NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCDropboxTableViewCell" owner:nil options:nil];
  13. NSAssert([nibContentArray count] == 1, @"meh");
  14. NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCDropboxTableViewCell class]], @"meh meh");
  15. VLCDropboxTableViewCell *cell = (VLCDropboxTableViewCell *)[nibContentArray lastObject];
  16. CGRect frame = [cell frame];
  17. UIView *background = [[UIView alloc] initWithFrame:frame];
  18. background.backgroundColor = [UIColor colorWithWhite:.05 alpha:1.];
  19. cell.backgroundView = background;
  20. UIView *highlightedBackground = [[UIView alloc] initWithFrame:frame];
  21. highlightedBackground.backgroundColor = [UIColor colorWithWhite:.2 alpha:1.];
  22. cell.selectedBackgroundView = highlightedBackground;
  23. return cell;
  24. }
  25. - (void)setFileMetadata:(DBMetadata *)fileMetadata
  26. {
  27. if (fileMetadata != _fileMetadata)
  28. _fileMetadata = fileMetadata;
  29. [self _updatedDisplayedInformation];
  30. }
  31. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  32. {
  33. [super setSelected:selected animated:animated];
  34. // Configure the view for the selected state
  35. }
  36. - (void)_updatedDisplayedInformation
  37. {
  38. self.titleLabel.text = self.fileMetadata.filename;
  39. self.subtitleLabel.text = (self.fileMetadata.totalBytes > 0) ? self.fileMetadata.humanReadableSize : @"";
  40. self.thumbnailView.image = [UIImage imageNamed:self.fileMetadata.icon];
  41. if (!self.thumbnailView.image)
  42. APLog(@"missing icon for type '%@'", self.fileMetadata.icon);
  43. self.itemIsaFolderView.hidden = !self.fileMetadata.isDirectory;
  44. [self setNeedsDisplay];
  45. }
  46. + (CGFloat)heightOfCell
  47. {
  48. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  49. return 80.;
  50. return 48.;
  51. }
  52. @end