VLCLocalNetworkListCell.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // VLCLocalNetworkListCell.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 10.08.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 "VLCLocalNetworkListCell.h"
  11. @implementation VLCLocalNetworkListCell
  12. + (VLCLocalNetworkListCell *)cellWithReuseIdentifier:(NSString *)ident
  13. {
  14. NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCLocalNetworkListCell" owner:nil options:nil];
  15. NSAssert([nibContentArray count] == 1, @"meh");
  16. NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCLocalNetworkListCell class]], @"meh meh");
  17. VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[nibContentArray lastObject];
  18. return cell;
  19. }
  20. - (void)awakeFromNib
  21. {
  22. self.titleLabel.text = @"";
  23. self.subtitleLabel.text = @"";
  24. self.thumbnailView.contentMode = UIViewContentModeScaleAspectFit;
  25. self.downloadButton.hidden = YES;
  26. }
  27. - (void)setIsDirectory:(BOOL)isDirectory
  28. {
  29. self.titleLabel.hidden = self.subtitleLabel.hidden = isDirectory;
  30. self.folderTitleLabel.hidden = !isDirectory;
  31. _isDirectory = isDirectory;
  32. }
  33. - (void)setTitle:(NSString *)title
  34. {
  35. BOOL isDir = self.isDirectory;
  36. self.folderTitleLabel.text = self.titleLabel.text = title;
  37. self.titleLabel.hidden = self.subtitleLabel.hidden = isDir;
  38. self.folderTitleLabel.hidden = !isDir;
  39. _title = title;
  40. }
  41. - (void)setSubtitle:(NSString *)subtitle
  42. {
  43. self.subtitleLabel.text = subtitle;
  44. }
  45. - (void)setIcon:(UIImage *)icon
  46. {
  47. self.thumbnailView.image = icon;
  48. }
  49. - (void)setIsDownloadable:(BOOL)isDownloadable
  50. {
  51. self.downloadButton.hidden = !isDownloadable;
  52. }
  53. - (void)triggerDownload:(id)sender
  54. {
  55. if ([self.delegate respondsToSelector:@selector(triggerDownloadForCell:)])
  56. [self.delegate triggerDownloadForCell:self];
  57. }
  58. + (CGFloat)heightOfCell
  59. {
  60. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  61. return 80.;
  62. return 68.;
  63. }
  64. @end